Changeset 39

Show
Ignore:
Timestamp:
04/02/08 06:44:59 (8 months ago)
Author:
kaarna
Message:

No more crashes (less anyway). VideoViewer? widget. Resizable windows.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/pihlaja/src/dsss.conf

    r37 r39  
    3131    #Another but: but it will crash without it too. 
    3232    #We need to not do anything else while playing? 
    33     buildflags += -version=noGCOnPlay 
     33    #buildflags += -version=noGCOnPlay 
    3434 
    3535##debugs: 
     
    3737    buildflags += -debug=logging 
    3838     
    39     #buildflags += -debug=GC 
     39    #buildflags += -debug=audio 
     40    #buildflags += -debug=arrange 
     41    buildflags += -debug=GC 
    4042    #buildflags += -debug=Shiraz 
    4143    #buildflags += -debug=ProjectWindow 
  • trunk/pihlaja/src/pihlaja/PihlajaMain.d

    r38 r39  
    6464 
    6565 
    66 class VideoViewer : public IVideoWriter 
     66class VideoViewer : public Widget, public IVideoWriter 
    6767{ 
    6868 
    6969    IPlaybackCore playbackCore = null; 
    7070     
     71    /* 
    7172    //Move to SubWindow or similar: 
    7273    float width = 1.0f;//512;//1024/2 
     
    8081        //resize(); 
    8182    } 
    82  
     83    */ 
    8384 
    8485    //My stuff: 
     
    99100    } 
    100101     
     102    void seekToStart() 
     103    { 
     104        m_seekPosition = 0; 
     105        fs = qtvideo[2].getFrame( m_seekPosition ); 
     106    } 
     107     
     108    void seekToEnd() 
     109    { 
     110        m_seekPosition = qtvideo[2].length - qtvideo[2].ticksPerFrame(); 
     111        Trace.formatln("video end is at: {}", qtvideo[2].length ); 
     112        Trace.formatln("m_seekPosition: {}", m_seekPosition ); 
     113        fs = qtvideo[2].getFrame( m_seekPosition ); 
     114    } 
     115     
     116    void seekFrameForward() 
     117    { 
     118        m_seekPosition += qtvideo[2].ticksPerFrame(); 
     119        fs = qtvideo[2].getFrame( m_seekPosition ); 
     120        Trace.formatln("m_seekPosition: {}", m_seekPosition ); 
     121    } 
     122     
     123    void seekFrameBackward() 
     124    { 
     125        m_seekPosition -= qtvideo[2].ticksPerFrame(); 
     126        fs = qtvideo[2].getFrame( m_seekPosition ); 
     127        Trace.formatln("m_seekPosition: {}", m_seekPosition ); 
     128    } 
     129     
    101130    void play() 
    102131    { 
     
    113142    uint currentVideo = 0; 
    114143    int64_t m_seekPosition = 0; 
     144     
    115145    float x_aspect = 1.78f; 
    116146    float y_aspect = 1.0f; 
    117147 
     148    /* 
    118149    //To be removed or changed stuff: 
    119150    GLfloat xpos = 0.0f; 
    120151    GLfloat ypos = 0.0f; 
    121     GLfloat xrot = 0.0f;      /* X Rotation */ 
    122     GLfloat yrot = 0.0f;      /* Y Rotation */ 
    123     GLfloat xspeed = 0.0f;    /* X Rotation Speed */ 
    124     GLfloat yspeed = 0.0f;    /* Y Rotation Speed */ 
    125     GLfloat z = 0.0f; /* Depth Into The Screen */ 
    126  
     152    GLfloat xrot = 0.0f;      // X Rotation  
     153    GLfloat yrot = 0.0f;      // Y Rotation  
     154    GLfloat xspeed = 0.0f;    // X Rotation Speed  
     155    GLfloat yspeed = 0.0f;    // Y Rotation Speed  
     156    GLfloat z = 0.0f; // Depth Into The Screen  
     157    */ 
    127158     
    128159 
     
    135166        scope(exit) Trace.formatln("VideoViewer.this() END."); 
    136167         
     168        super(); 
     169         
    137170        initVideo(); 
    138171        initAudio(); 
     172         
     173        initVideoGL(); 
     174         
     175        //colour(1.0f, 0.3f, 0.1f, 1.0f); 
    139176    } 
    140177     
     
    179216    const TEXTURE_HEIGHT = 1024.0; 
    180217     
     218    //Smaller sizes don't seem to work at all. 
     219    //Propably because of the openGL call that 
     220    //is being used for resizing the texture. 
    181221    /* 
    182222    const T_W_F = 512.0; 
     
    306346     
    307347     
     348    /* 
    308349    void resize() 
    309     {/* 
     350    { 
    310351        if( height == 0.0f ) 
    311352            height = 1.0f; 
     
    326367        //gluPerspective( 45.0f, 1.0f, 0.1f, 100.0f ); 
    327368        glMatrixMode( GL_MODELVIEW ); 
    328         glLoadIdentity();*/ 
    329     } 
     369        glLoadIdentity(); 
     370    } 
     371    */ 
    330372     
    331373    //rename to render() draw() or similar. 
    332     bool drawGL() 
     374    void render() 
    333375    { 
    334376        glPushMatrix(); 
     377     
     378            applyPosition(); 
     379            applyRotation(); 
     380            applyScale(); 
     381            applyColour(); 
     382            applyClipping(); 
    335383     
    336384        /*GLdouble eqn[4] = [0.0, 1.0, 0.0, 0.0];    // y < 0 
     
    356404 
    357405    /* Translate Into/Out Of The Screen By z */ 
     406     
     407    /* 
     408     
    358409    glTranslatef( 0.0f, 0.0f, z ); 
    359410 
    360411        glTranslatef( xpos, ypos, 0.0f ); 
    361412 
    362     glRotatef( xrot, 1.0f, 0.0f, 0.0f); /* Rotate On The X Axis By xrot */ 
    363     glRotatef( yrot, 0.0f, 1.0f, 0.0f); /* Rotate On The Y Axis By yrot */ 
     413    glRotatef( xrot, 1.0f, 0.0f, 0.0f); // Rotate On The X Axis By xrot 
     414    glRotatef( yrot, 0.0f, 1.0f, 0.0f); // Rotate On The Y Axis By yrot 
     415 
     416        */ 
    364417 
    365418        drawVideo(); 
    366419 
     420        /* 
    367421        //Move these to idle: 
    368         xrot += xspeed; /* Add xspeed To xrot */ 
    369     yrot += yspeed; /* Add yspeed To yrot */ 
     422        xrot += xspeed; // Add xspeed To xrot 
     423    yrot += yspeed; // Add yspeed To yrot  
    370424         
    371425        if( xspeed > 0.1f ) 
     
    379433            yspeed += 0.1f; 
    380434        else yspeed = 0.0f; 
     435        */ 
     436         
    381437         
    382438        glPopMatrix(); 
    383          
    384         return true; 
    385     } 
    386      
    387     void pushFrame( frame_struct* frame, bool move_cursor = true ) 
    388     { 
    389         //Trace.formatln("pushFrame...Umm."); 
    390         fs = frame; 
    391         drawVideo(); 
    392     } 
    393      
    394     void pushFrameStack( frame_struct** set_fs, bool move_cursor = true ) 
    395     { 
    396         Trace.formatln("pushFrameStack...Umm."); 
    397         if( set_fs !is null ) 
    398             pushFrame(set_fs[0]); 
    399         //drawVideo(); 
    400     } 
    401      
    402     void exporter( IVideoFileWriter fwriter ) 
    403     { 
    404         uint vid_num = 0; 
    405          
    406         if( vid_num >= nro_videos ) 
    407             return; 
    408                  
    409         for( uint i = 0; i < nro_videos; i++ ) 
    410         { 
    411             Trace.formatln("Processing clip nro: {}", i); 
    412              
    413             Trace.formatln("ticksPerFrame: {}", qtvideo[i].ticksPerFrame() ); 
    414             Trace.formatln("NLE_TIME_BASE: {}", NLE_TIME_BASE); 
    415              
    416             int64_t tempvidpos = 25 * qtvideo[i].ticksPerFrame(); 
    417             int64_t tempaudiopos = tempvidpos / (NLE_TIME_BASE / 48000 ); 
    418              
    419             //Trace.formatln("tempvidpos: ")(tempvidpos); 
    420             //Trace.formatln("tempaudiopos: ")(tempaudiopos); 
    421              
    422             int64_t framesPerBuffer = qtvideo[i].ticksPerFrame() / (NLE_TIME_BASE / 48000 ); 
    423              
    424             Trace.formatln("framesPerBuffer: {}", framesPerBuffer); 
    425              
    426             scope float[] outputBuffer = new float[framesPerBuffer*2]; 
    427              
    428              
    429              
    430             for( m_seekPosition = 0; m_seekPosition < qtvideo[i].length(); m_seekPosition += qtvideo[i].ticksPerFrame() ) 
    431             { 
    432                 //m_seekPosition += qtvideo[currentVideo].ticksPerFrame();//400000l;//frame_duration; 
    433                 fs = qtvideo[i].getFrame( m_seekPosition ); 
    434              
    435                 fwriter.encodeVideoFrame( fs ); 
    436                  
    437                 int64_t m_audioPosition = m_seekPosition / (NLE_TIME_BASE / 48000); 
    438                  
    439                 //Trace.formatln( "videopos: ")(m_seekPosition); 
    440                 //Trace.formatln("audiopos: ")(m_audioPosition); 
    441                  
    442                 if( audioFile !is null ) 
    443                 { 
    444                     /*Trace.formatln( "seekpos: ")(m_seekPosition); 
    445                     Trace.formatln( "lenght: ")( qtvideo[i].length() ); 
    446                  
    447                     Trace.formatln("Trying sampleseek: ")(m_audioPosition);*/ 
    448                  
    449                     audioFile.sampleseek( 0, m_audioPosition ); 
    450                 } 
    451                  
    452                  
    453                 /*foreach( float a; outputBuffer ) 
    454                 { 
    455                     a = 0.0f; 
    456                 }*/ 
    457                  
    458                 uint next_move; 
    459                 if( audioFile !is null ) 
    460                 { 
    461                     //Trace.formatln("Trying fillBuffer: "); 
    462                     next_move = audioFile.fillBuffer( outputBuffer.ptr, framesPerBuffer ); 
    463                 } 
    464                  
    465                 foreach( float a; outputBuffer ) 
    466                 { 
    467                     //a = 0.0f; 
    468                     if( a > 0.1f || a < -0.1f ) 
    469                     //if( a != 0.0f ) 
    470                         Trace.formatln("a: {}", cast(double)a); 
    471                 } 
    472                  
    473                 fwriter.encodeAudioFrame( outputBuffer.ptr, framesPerBuffer ); 
    474             } 
    475              
    476         } 
    477439    } 
    478440     
     
    548510                */ 
    549511                 
    550                 gl_w = x_aspect * 0.2;//4.0f; 
    551                 gl_h = y_aspect * 0.2;//3.0f; 
     512                //gl_w = x_aspect * 0.2;//4.0f; 
     513                //gl_h = y_aspect * 0.2;//3.0f; 
     514                gl_w = x_aspect * h;//4.0f; 
     515                gl_h = h;//3.0f; 
    552516                gl_x = -gl_w * 0.5f;//-2.0f; 
    553517                gl_y = -gl_h * 0.5f;//-1.5f; 
     
    573537    } 
    574538     
     539    void pushFrame( frame_struct* frame, bool move_cursor = true ) 
     540    { 
     541        //Trace.formatln("pushFrame...Umm."); 
     542        fs = frame; 
     543        drawVideo(); 
     544    } 
     545     
     546    void pushFrameStack( frame_struct** set_fs, bool move_cursor = true ) 
     547    { 
     548        Trace.formatln("pushFrameStack...Umm."); 
     549        if( set_fs !is null ) 
     550            pushFrame(set_fs[0]); 
     551        //drawVideo(); 
     552    } 
     553     
     554    void exporter( IVideoFileWriter fwriter ) 
     555    { 
     556        uint vid_num = 0; 
     557         
     558        if( vid_num >= nro_videos ) 
     559            return; 
     560                 
     561        for( uint i = 0; i < nro_videos; i++ ) 
     562        { 
     563            Trace.formatln("Processing clip nro: {}", i); 
     564             
     565            Trace.formatln("ticksPerFrame: {}", qtvideo[i].ticksPerFrame() ); 
     566            Trace.formatln("NLE_TIME_BASE: {}", NLE_TIME_BASE); 
     567             
     568            int64_t tempvidpos = 25 * qtvideo[i].ticksPerFrame(); 
     569            int64_t tempaudiopos = tempvidpos / (NLE_TIME_BASE / 48000 ); 
     570             
     571            //Trace.formatln("tempvidpos: ")(tempvidpos); 
     572            //Trace.formatln("tempaudiopos: ")(tempaudiopos); 
     573             
     574            int64_t framesPerBuffer = qtvideo[i].ticksPerFrame() / (NLE_TIME_BASE / 48000 ); 
     575             
     576            Trace.formatln("framesPerBuffer: {}", framesPerBuffer); 
     577             
     578            scope float[] outputBuffer = new float[framesPerBuffer*2]; 
     579             
     580             
     581             
     582            for( m_seekPosition = 0; m_seekPosition < qtvideo[i].length(); m_seekPosition += qtvideo[i].ticksPerFrame() ) 
     583            { 
     584                //m_seekPosition += qtvideo[currentVideo].ticksPerFrame();//400000l;//frame_duration; 
     585                fs = qtvideo[i].getFrame( m_seekPosition ); 
     586             
     587                fwriter.encodeVideoFrame( fs ); 
     588                 
     589                int64_t m_audioPosition = m_seekPosition / (NLE_TIME_BASE / 48000); 
     590                 
     591                //Trace.formatln( "videopos: ")(m_seekPosition); 
     592                //Trace.formatln("audiopos: ")(m_audioPosition); 
     593                 
     594                if( audioFile !is null ) 
     595                { 
     596                    /*Trace.formatln( "seekpos: ")(m_seekPosition); 
     597                    Trace.formatln( "lenght: ")( qtvideo[i].length() ); 
     598                 
     599                    Trace.formatln("Trying sampleseek: ")(m_audioPosition);*/ 
     600                 
     601                    audioFile.sampleseek( 0, m_audioPosition ); 
     602                } 
     603                 
     604                 
     605                /*foreach( float a; outputBuffer ) 
     606                { 
     607                    a = 0.0f; 
     608                }*/ 
     609                 
     610                uint next_move; 
     611                if( audioFile !is null ) 
     612                { 
     613                    //Trace.formatln("Trying fillBuffer: "); 
     614                    next_move = audioFile.fillBuffer( outputBuffer.ptr, framesPerBuffer ); 
     615                } 
     616                 
     617                foreach( float a; outputBuffer ) 
     618                { 
     619                    //a = 0.0f; 
     620                    if( a > 0.1f || a < -0.1f ) 
     621                    //if( a != 0.0f ) 
     622                        Trace.formatln("a: {}", cast(double)a); 
     623                } 
     624                 
     625                fwriter.encodeAudioFrame( outputBuffer.ptr, framesPerBuffer ); 
     626            } 
     627             
     628        } 
     629    } 
     630     
     631     
     632     
    575633     
    576634 
     
    599657                case GDK_Up: 
    600658                //case GDK_r: 
    601                     m_seekPosition = 0; 
    602                     fs = qtvideo[2].getFrame( m_seekPosition ); 
     659                    seekToStart(); 
    603660                break; 
    604661                case GDK_Left: 
    605                     m_seekPosition -= qtvideo[2].ticksPerFrame(); 
    606                     fs = qtvideo[2].getFrame( m_seekPosition ); 
     662                    seekFrameBackward(); 
    607663                    //currentVideo--; 
    608664                break; 
    609665                case GDK_Right: 
    610                     m_seekPosition += qtvideo[2].ticksPerFrame(); 
    611                     fs = qtvideo[2].getFrame( m_seekPosition ); 
     666                    seekFrameForward(); 
    612667                    //currentVideo++; 
    613668                break; 
     
    628683                break; 
    629684                case GDK_z: 
    630                     xrot = 0.0f; 
    631                     yrot = 0.0f; 
    632                     xspeed = 0.0f; 
    633                     yspeed = 0.0f; 
     685                    xRot = 0.0f; 
     686                    yRot = 0.0f; 
     687                    //xspeed = 0.0f; 
     688                    //yspeed = 0.0f; 
    634689                break; 
    635690                case GDK_u: 
    636                     z -= 0.01f; 
     691                    //z -= 0.01f; 
    637692                break; 
    638693                case GDK_o: 
    639                     z += 0.01f; 
     694                    //z += 0.01f; 
    640695                break; 
    641696                 
    642697                case GDK_w: 
    643                     ypos -= 0.005f; 
     698                    //ypos -= 0.005f; 
    644699                break; 
    645700                case GDK_s: 
    646                     ypos += 0.005f; 
     701                    //ypos += 0.005f; 
    647702                break; 
    648703                case GDK_a: 
    649                     xpos -= 0.005f; 
     704                    //xpos -= 0.005f; 
    650705                break; 
    651706                case GDK_d: 
    652                     xpos += 0.005f; 
     707                    //xpos += 0.005f; 
    653708                break; 
    654709                 
     
    665720                 
    666721                case GDK_i: 
    667                     xspeed += 0.5f; 
     722                    //xspeed += 0.5f; 
    668723                    //Trace.formatln("i pressed.")("xspeed: ")(xspeed); 
    669724                break; 
    670725                case GDK_k: 
    671                     xspeed -= 0.5f; 
     726                    //xspeed -= 0.5f; 
    672727                    //Trace.formatln("k pressed.")("xspeed: ")(xspeed); 
    673728                break; 
    674729                case GDK_l: 
    675                     yspeed += 0.5f; 
     730                    //yspeed += 0.5f; 
    676731                    //Trace.formatln("l pressed.")("yspeed: ")(yspeed); 
    677732                break; 
    678733                case GDK_j: 
    679                     yspeed -= 0.5f; 
     734                    //yspeed -= 0.5f; 
    680735                    //Trace.formatln("j pressed.")("yspeed: ")(yspeed); 
    681736                break; 
     
    734789        */ 
    735790        videoViewer = new VideoViewer(); 
    736         videoViewer.defaultSize( 0.5f, 0.5f ); 
    737         videoViewer.initVideoGL(); 
     791        //videoViewer.defaultSize( 0.5f, 0.5f ); 
     792        //videoViewer.initVideoGL(); 
    738793        //add( videoViewer ); 
    739794         
     
    741796         
    742797         
    743         myWindow2 = new SubWindow("0.5windowrect"); 
     798        myWindow2 = new SubWindow("Viewer"); 
    744799        //myWindow2.isRotate = true; 
    745800        Trace.formatln("{}", myWindow2 ); 
    746         myWindow2.defaultSize( 0.5, 0.5 ); 
     801        myWindow2.defaultSize( 0.8, 0.4 ); 
    747802        Trace.formatln("{}", myWindow2 ); 
    748803        //myWindow2.colour( 0.2, 0.5, 0.3, 0.5 ); 
    749804        myWindow2.signalMouseButtonPress.attach(&clickHandler); 
    750805         
     806        myWindow2.add(videoViewer); 
     807         
    751808        add(myWindow2); 
    752809         
     
    754811 
    755812         
    756         myWindow3 = new SubWindow("upleftwindow"); 
     813        myWindow3 = new SubWindow("Pihlaja"); 
    757814        //myWindow2.isRotate = true; 
    758815        Trace.formatln("{}", myWindow3 ); 
     
    818875        myWindow3.add(insideButton);*/ 
    819876         
    820         myWindow4 = new SubWindow("rightsmallwindow"); 
     877        myWindow4 = new SubWindow("Timeline"); 
    821878        myWindow4.moveTo( 0.3f, 0.0f ); 
    822879        myWindow4.defaultSize( 0.2f, 0.1f ); 
     
    844901         
    845902        playButton = new Button("Play"); 
    846         playButton.moveTo(-0.5f, 0.0f ); 
     903        //playButton.moveTo(-0.5f, 0.0f ); 
    847904        playButton.defaultSize( 0.1f, 0.05f ); 
    848905        //playButton.colour( 0.3f, 0.3f, 0.3f, 0.7f ); 
    849906        playButton.signalActivate.attach(&playHandler); 
    850907        //playButton.signalMouseButtonPress.attach(&playHandler); 
    851         add(playButton); 
     908        myWindow4.add(playButton); 
    852909         
    853910        exportButton = new Button("Export"); 
     
    856913        exportButton.colour( 0.5f, 0.3f, 0.3f, 0.7f ); 
    857914        exportButton.signalActivate.attach(&exportButtonHandler); 
    858         add(exportButton); 
    859          
     915        myWindow4.add(exportButton); 
     916         
     917        seekToStartButton = new Button("To Start"); 
     918        seekToStartButton.signalActivate.attach(&videoViewer.seekToStart); 
     919        myWindow4.add(seekToStartButton); 
     920         
     921        seekToEndButton = new Button("To End"); 
     922        seekToEndButton.signalActivate.attach(&videoViewer.seekToEnd); 
     923        myWindow4.add(seekToEndButton); 
     924         
     925        seekFrameBackwardButton = new Button("-Frame"); 
     926        seekFrameBackwardButton.signalActivate.attach(&videoViewer.seekFrameBackward); 
     927        myWindow4.add(seekFrameBackwardButton); 
     928         
     929        seekFrameForwardButton = new Button("+Frame"); 
     930        seekFrameForwardButton.signalActivate.attach(&videoViewer.seekFrameForward); 
     931        myWindow4.add(seekFrameForwardButton); 
    860932         
    861933    } 
     
    11071179            //playButton.colour( 1.0f, 1.0f, 1.0f, 1.0f ); 
    11081180            //clickcol = false; 
     1181            playButton.ungrabInput(); 
    11091182        } 
    11101183        else 
     
    11121185            //playButton.colour( 0.2f, 0.4f, 0.2f, 1.0f ); 
    11131186            //clickcol = true; 
     1187            playButton.grabInput(); 
    11141188        } 
    11151189         
     
    11361210    Button exportButton; 
    11371211    Button playButton; 
     1212    Button seekToStartButton; 
     1213    Button seekToEndButton; 
     1214    Button seekFrameForwardButton; 
     1215    Button seekFrameBackwardButton; 
    11381216    SubWindow myWindow3; 
    11391217    SubWindow myWindow4; 
     
    11711249        } 
    11721250    } 
    1173      
     1251    /* 
    11741252    void render() 
    11751253    { 
     
    11841262         
    11851263    } 
     1264    */ 
    11861265     
    11871266     
  • trunk/pihlaja/src/shiraz/av/AudioFileQT.d

    r33 r39  
    8484        } 
    8585        m_ok = true; 
     86         
     87        left_buffer = l_buffer.ptr; 
     88        right_buffer = r_buffer.ptr; 
     89         
     90        //buf_pointer = [ left_buffer, right_buffer ]; 
     91        buf_pointer[0] = left_buffer; 
     92        buf_pointer[1] = right_buffer; 
    8693    } 
    8794 
     
    97104    int64_t length() { return m_length; } 
    98105     
    99     void seek( int64_t position ) 
     106    synchronized void seek( int64_t position ) 
    100107    { 
    101108        //Trace.formatln("position:")(position); 
     
    105112    } 
    106113     
    107     void sampleseek( int, int64_t position ) 
     114    synchronized void sampleseek( int, int64_t position ) 
    108115    { 
    109116        seek( position ); 
    110117    } 
    111118     
    112     int fillBuffer( float* output, uint frames ) 
     119    synchronized int fillBuffer( float* output, uint frames ) 
    113120        // sizof(output) == frames * 2 
    114121        // File Format: 48000 stereo interleaved 
    115122    { 
    116         //Trace.formatln("AudioFileQT.fillBuffer() START."); 
    117         //scope(exit) Trace.formatln("AudioFileQT.fillBuffer() END."); 
     123        debug(audio) Trace.formatln("AudioFileQT.fillBuffer() START."); 
     124        debug(audio) scope(exit) Trace.formatln("AudioFileQT.fillBuffer() END."); 
    118125     
    119126        // l_buffer and r_buffer are defined in the class definition 
    120         float[] templeft; 
    121         float[] tempright; 
     127        //float[] templeft; 
     128        //float[] tempright; 
    122129         
    123         float* left_buffer = l_buffer.ptr; 
    124         float* right_buffer = r_buffer.ptr; 
     130        //float[4096] l_buffer; 
     131        //float[4096] r_buffer; 
     132         
     133        //float* left_buffer = l_buffer.ptr; 
     134        //float* right_buffer = r_buffer.ptr; 
    125135        int64_t diff = lqt_last_audio_position( m_qt, 0 ); 
    126         if ( frames > 4096) 
     136        /*if ( frames > 4096) 
    127137        { 
     138            Trace.formatln("Audio buffer is bigger than 4096. Not supported yet."); 
     139            throw new Exception("Audio buffer is bigger than 4096. Not supported yet."); 
    128140            templeft = new float[frames]; 
    129141            tempright = new float[frames]; 
    130142            left_buffer = templeft.ptr; 
    131143            right_buffer = tempright.ptr; 
    132         } 
    133         float*[2] buf_pointer = [ left_buffer, right_buffer ]; 
     144        }*/ 
     145         
     146        //float*[2] buf_pointer = [ left_buffer, right_buffer ]; 
     147         
    134148        //lqt_decode_audio_track( m_qt, null, cast(float**)buf_pointer.ptr, frames, 0 ); 
    135149        lqt_decode_audio_track( m_qt, null, buf_pointer.ptr, frames, 0 ); 
     150         
    136151        diff = lqt_last_audio_position( m_qt, 0 ) - diff; 
     152         
    137153        if ( m_oneShot ) 
    138154        { 
     
    145161            output[i * 2 + 1] = right_buffer[i]; 
    146162        } 
    147         if ( frames > 4096) 
     163        /*if ( frames > 4096) 
    148164        { 
    149165            delete left_buffer; 
    150166            delete right_buffer; 
    151         } 
     167        }*/ 
    152168        return diff; 
    153169    } 
     
    166182    float[4096] l_buffer; 
    167183    float[4096] r_buffer; 
     184     
     185    float* left_buffer;// = l_buffer.ptr; 
     186    float* right_buffer;// = r_buffer.ptr; 
     187     
     188    float*[2] buf_pointer;// = [ left_buffer, right_buffer ]; 
    168189} 
    169190 
  • trunk/pihlaja/src/shiraz/av/PortAudioPlaybackCore.d

    r33 r39  
    9393//End TEMP sine stuff. 
    9494 
     95static bool thread_attach_once = true; 
     96 
    9597extern (C) 
    9698//static int portaudio_callback( void *input, void *output, unsigned long frames, PaTimestamp time, void* data ) 
     
    105107    //scope(exit) Trace.formatln("portaudio_callback() END."); 
    106108 
    107     static bool once = true; 
    108      
    109     if( once == true ) 
     109    //A temporary test to end the crashing madness. 
     110    //We'll try disabling the GC while in the portaudio_callback... 
     111    GC.disable(); 
     112    scope(exit) GC.enable();; 
     113     
     114    if( thread_attach_once == true ) 
    110115    { 
    111116        Trace.formatln("portaudio_callback() attaching thread."); 
    112117        thread_attachThis(); 
    113         once = false; 
     118        thread_attach_once = false; 
    114119    } 
    115120 
     
    178183static PaStream* g_stream; 
    179184 
     185//synchronized  
    180186static bool portaudio_start( int rate, int frames, void* set_data ) 
    181187{ 
     
    226232    return false; 
    227233} 
     234//synchronized  
    228235static bool portaudio_stop() 
    229236{ 
     
    297304    } 
    298305     
     306    //synchronized  
    299307    void play() 
    300308    { 
     
    313321        } 
    314322         
     323        thread_attach_once = true; 
    315324     
    316325        //C: m_currentFrame = g_timeline.m_seekPosition; 
     
    343352    void pause() { ; } 
    344353 
     354    //synchronized  
    345355    void stop() 
    346356    { 
     
    369379    } 
    370380     
    371     //synchronized  
    372     int readAudio( float* outputBuffer, uint framesPerBuffer ) 
     381    synchronized int readAudio( float* outputBuffer, uint framesPerBuffer ) 
    373382    { 
    374383        //Trace.formatln("PortAudioPlaybackCore.readAudio() START."); 
     
    436445    } 
    437446 
    438     //synchronized  
    439     bool flipFrame() 
     447    synchronized bool flipFrame() 
    440448    { 
    441449        //Trace.formatln("flipFrame"); 
  • trunk/pihlaja/src/shiraz/canvas/Bezier.d

    r37 r39  
    7676    public Point next() 
    7777    { 
    78         //if( nextTimeSetIsLoop == true ) 
    79         //    isLoop = true; 
     78        if( nextTimeSetIsLoop == true ) 
     79          isLoop = true; 
    8080     
    8181        Point ret = p( anim_i, anim_step/cast(float)STEPS ); 
     
    9494            //now we set isLoop to true to show others 
    9595            //that we're looping. Any better ideas for this API? 
    96             //nextTimeSetIsLoop = true; 
    97             isLoop = true; 
     96            nextTimeSetIsLoop = true; 
     97            //isLoop = true; 
    9898            anim_i = 0; 
    9999            anim_step = 0; 
  • trunk/pihlaja/src/shiraz/canvas/Draw.d

    r38 r39  
    5050} 
    5151 
     52const real PI2 = PI * 2.0f; 
     53 
     54void circle(float x, float y, float w, float h) 
     55{ 
     56    //glColor4f(1.0f, 1.0f, 1.0f, 1.0f); 
     57 
     58    w = w * 0.5f; 
     59    h = h * 0.5f; 
     60 
     61    glBegin(GL_TRIANGLE_FAN); 
     62    //glBegin(GL_POINTS); 
     63     
     64        glVertex3f( x, y, 0.0f ); 
     65         
     66        float step = PI2 / 24.0f; 
     67         
     68        for( float a = 0.0f; a <= PI2 + step; a += step ) 
     69        { 
     70            glVertex3f( x + cos(a) * w, y + sin(a) * h, 0.0f ); 
     71        } 
     72     
     73    glEnd(); 
     74} 
     75 
     76void drawCircle( GLubyte[] image, uint wid, uint hei, uint chan, float[4] set_colour ) 
     77{ 
     78    cairo_format_t form = cairo_format_t.ARGB32; 
     79      
     80    if( chan == 4 ) 
     81        form = cairo_format_t.ARGB32; 
     82    else if( chan == 3 ) 
     83        form = cairo_format_t.RGB24; 
     84    //TODO other cairo_format_t. 
     85 
     86    Surface imageSurface = ImageSurface.createForData(image.ptr, form, wid, hei, wid * chan); 
     87    //ImageSurface.createForData(ubyte* data, cairo_format_t format, int width, int height, int stride); 
     88    scope(exit) delete imageSurface;//doesn't call destroy...BUG in gtkD. 
     89 
     90    auto cr = Context.create(imageSurface); 
     91    scope(exit) delete cr; 
     92 
     93    cr.save(); 
     94        //cr.rotate(PI*0.1); 
     95        //cr.scale(1.0, -1.0); 
     96        //cr.translate(0, -2); 
     97        cr.translate(wid/2, hei/2); 
     98         
     99        /* 
     100        //A temporary rectangle 
     101            cr.rectangle( 0.0, 0.0, wid, hei ); 
     102            cr.setSourceRgba(1.0, 0.1, 0.3, 0.8); 
     103            cr.fill(); 
     104        // 
     105        */ 
     106         
     107         
     108        //cr.translate(0, 14); 
     109        cr.setLineWidth(1.0); 
     110        //cr.moveTo(0.0, 0.0); 
     111            //cr.selectFontFace("Bitstream Vera Sans", cairo_font_slant_t.NORMAL, 
     112                        //cairo_font_weight_t.NORMAL); 
     113                         
     114        cr.setSourceRgba(set_colour[0], set_colour[1], set_colour[2], set_colour[3]); 
     115         
     116        cr.arc(0, 0, 6.0, 0, 2 * PI); 
     117        cr.fill(); 
     118    cr.restore(); 
     119     
     120    /* 
     121    cr.save(); 
     122        cr.rectangle( 0.0, 0.0, 20.0, 20.0 ); 
     123            cr.setSourceRgba(0.3, 0.6, 0.3, 0.8); 
     124            cr.fill(); 
     125    cr.restore(); 
     126    */ 
     127     
     128    cr.destroy(); 
     129    imageSurface.destroy(); 
     130     
     131} 
     132 
    52133void showText( char[] set_text, GLubyte[] image, uint wid, uint hei, uint chan, float[4] set_colour ) 
    53134{ 
  • trunk/pihlaja/src/shiraz/canvas/Image.d

    r29 r39  
    114114    protected uint minFilter(){ return m_minFilter; } 
    115115     
     116    //TODO maybe we put these to be in the 
     117    //Rectangle???? 
     118    public uint blendSource = GL_SRC_ALPHA; 
     119    public uint blendDestination = GL_ONE_MINUS_SRC_ALPHA; 
     120    //public uint blendDestination = GL_ONE;//transparent blacks. 
     121     
    116122    void pushTexture() 
    117123    { 
     
    120126        glEnable( glTextureType ); 
    121127        glBindTexture( glTextureType, m_id ); 
     128         
     129        glBlendFunc( blendSource, blendDestination ); 
    122130    } 
    123131     
     
    384392    } 
    385393     
     394    static Image createCircle( float[4] set_colour ) 
     395    { 
     396        Image img = new Image(); 
     397        img.drawCircle(set_colour); 
     398        return img; 
     399    } 
     400     
     401    void drawCircle( float[4] set_colour ) 
     402    { 
     403        uint m_width = 24; 
     404        uint m_height = 24; 
     405        uint m_channels = 4; 
     406        scope GLubyte[] image = new GLubyte[(m_width*m_height)*m_channels]; 
     407        Draw.drawCircle( image, m_width, m_height, m_channels, set_colour ); 
     408        createTextureFromData( image, m_width, m_height, m_channels ); 
     409    } 
     410    /* 
     411    static Image createTopHeader() 
     412    { 
     413        Image img = new Image(); 
     414             
     415        uint m_width = ; 
     416        uint m_height = 24; 
     417        uint m_channels = 4; 
     418        scope GLubyte[] image = new GLubyte[(m_width*m_height)*m_channels]; 
     419        Draw.drawTopHeader( image, m_width, m_height, m_channels ); 
     420        img.createTextureFromData( image, m_width, m_height, m_channels ); 
     421         
     422        return img; 
     423    } 
     424    */ 
     425     
    386426    uint findSmallestNumber(GLubyte[] image) 
    387427    { 
  • trunk/pihlaja/src/shiraz/canvas/PlainRectangle.d