Changeset 39
- Timestamp:
- 04/02/08 06:44:59 (8 months ago)
- Files:
-
- trunk/pihlaja/src/dsss.conf (modified) (2 diffs)
- trunk/pihlaja/src/pihlaja/PihlajaMain.d (modified) (26 diffs)
- trunk/pihlaja/src/shiraz/av/AudioFileQT.d (modified) (5 diffs)
- trunk/pihlaja/src/shiraz/av/PortAudioPlaybackCore.d (modified) (9 diffs)
- trunk/pihlaja/src/shiraz/canvas/Bezier.d (modified) (2 diffs)
- trunk/pihlaja/src/shiraz/canvas/Draw.d (modified) (1 diff)
- trunk/pihlaja/src/shiraz/canvas/Image.d (modified) (3 diffs)
- trunk/pihlaja/src/shiraz/canvas/PlainRectangle.d (modified) (12 diffs)
- trunk/pihlaja/src/shiraz/canvas/Rectangle.d (modified) (11 diffs)
- trunk/pihlaja/src/shiraz/ui/Button.d (modified) (1 diff)
- trunk/pihlaja/src/shiraz/ui/SubWindow.d (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/pihlaja/src/dsss.conf
r37 r39 31 31 #Another but: but it will crash without it too. 32 32 #We need to not do anything else while playing? 33 buildflags += -version=noGCOnPlay33 #buildflags += -version=noGCOnPlay 34 34 35 35 ##debugs: … … 37 37 buildflags += -debug=logging 38 38 39 #buildflags += -debug=GC 39 #buildflags += -debug=audio 40 #buildflags += -debug=arrange 41 buildflags += -debug=GC 40 42 #buildflags += -debug=Shiraz 41 43 #buildflags += -debug=ProjectWindow trunk/pihlaja/src/pihlaja/PihlajaMain.d
r38 r39 64 64 65 65 66 class VideoViewer : public IVideoWriter66 class VideoViewer : public Widget, public IVideoWriter 67 67 { 68 68 69 69 IPlaybackCore playbackCore = null; 70 70 71 /* 71 72 //Move to SubWindow or similar: 72 73 float width = 1.0f;//512;//1024/2 … … 80 81 //resize(); 81 82 } 82 83 */ 83 84 84 85 //My stuff: … … 99 100 } 100 101 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 101 130 void play() 102 131 { … … 113 142 uint currentVideo = 0; 114 143 int64_t m_seekPosition = 0; 144 115 145 float x_aspect = 1.78f; 116 146 float y_aspect = 1.0f; 117 147 148 /* 118 149 //To be removed or changed stuff: 119 150 GLfloat xpos = 0.0f; 120 151 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 */ 127 158 128 159 … … 135 166 scope(exit) Trace.formatln("VideoViewer.this() END."); 136 167 168 super(); 169 137 170 initVideo(); 138 171 initAudio(); 172 173 initVideoGL(); 174 175 //colour(1.0f, 0.3f, 0.1f, 1.0f); 139 176 } 140 177 … … 179 216 const TEXTURE_HEIGHT = 1024.0; 180 217 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. 181 221 /* 182 222 const T_W_F = 512.0; … … 306 346 307 347 348 /* 308 349 void resize() 309 { /*350 { 310 351 if( height == 0.0f ) 311 352 height = 1.0f; … … 326 367 //gluPerspective( 45.0f, 1.0f, 0.1f, 100.0f ); 327 368 glMatrixMode( GL_MODELVIEW ); 328 glLoadIdentity();*/ 329 } 369 glLoadIdentity(); 370 } 371 */ 330 372 331 373 //rename to render() draw() or similar. 332 bool drawGL()374 void render() 333 375 { 334 376 glPushMatrix(); 377 378 applyPosition(); 379 applyRotation(); 380 applyScale(); 381 applyColour(); 382 applyClipping(); 335 383 336 384 /*GLdouble eqn[4] = [0.0, 1.0, 0.0, 0.0]; // y < 0 … … 356 404 357 405 /* Translate Into/Out Of The Screen By z */ 406 407 /* 408 358 409 glTranslatef( 0.0f, 0.0f, z ); 359 410 360 411 glTranslatef( xpos, ypos, 0.0f ); 361 412 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 */ 364 417 365 418 drawVideo(); 366 419 420 /* 367 421 //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 370 424 371 425 if( xspeed > 0.1f ) … … 379 433 yspeed += 0.1f; 380 434 else yspeed = 0.0f; 435 */ 436 381 437 382 438 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 }477 439 } 478 440 … … 548 510 */ 549 511 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; 552 516 gl_x = -gl_w * 0.5f;//-2.0f; 553 517 gl_y = -gl_h * 0.5f;//-1.5f; … … 573 537 } 574 538 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 575 633 576 634 … … 599 657 case GDK_Up: 600 658 //case GDK_r: 601 m_seekPosition = 0; 602 fs = qtvideo[2].getFrame( m_seekPosition ); 659 seekToStart(); 603 660 break; 604 661 case GDK_Left: 605 m_seekPosition -= qtvideo[2].ticksPerFrame(); 606 fs = qtvideo[2].getFrame( m_seekPosition ); 662 seekFrameBackward(); 607 663 //currentVideo--; 608 664 break; 609 665 case GDK_Right: 610 m_seekPosition += qtvideo[2].ticksPerFrame(); 611 fs = qtvideo[2].getFrame( m_seekPosition ); 666 seekFrameForward(); 612 667 //currentVideo++; 613 668 break; … … 628 683 break; 629 684 case GDK_z: 630 x rot = 0.0f;631 y rot = 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; 634 689 break; 635 690 case GDK_u: 636 z -= 0.01f;691 //z -= 0.01f; 637 692 break; 638 693 case GDK_o: 639 z += 0.01f;694 //z += 0.01f; 640 695 break; 641 696 642 697 case GDK_w: 643 ypos -= 0.005f;698 //ypos -= 0.005f; 644 699 break; 645 700 case GDK_s: 646 ypos += 0.005f;701 //ypos += 0.005f; 647 702 break; 648 703 case GDK_a: 649 xpos -= 0.005f;704 //xpos -= 0.005f; 650 705 break; 651 706 case GDK_d: 652 xpos += 0.005f;707 //xpos += 0.005f; 653 708 break; 654 709 … … 665 720 666 721 case GDK_i: 667 xspeed += 0.5f;722 //xspeed += 0.5f; 668 723 //Trace.formatln("i pressed.")("xspeed: ")(xspeed); 669 724 break; 670 725 case GDK_k: 671 xspeed -= 0.5f;726 //xspeed -= 0.5f; 672 727 //Trace.formatln("k pressed.")("xspeed: ")(xspeed); 673 728 break; 674 729 case GDK_l: 675 yspeed += 0.5f;730 //yspeed += 0.5f; 676 731 //Trace.formatln("l pressed.")("yspeed: ")(yspeed); 677 732 break; 678 733 case GDK_j: 679 yspeed -= 0.5f;734 //yspeed -= 0.5f; 680 735 //Trace.formatln("j pressed.")("yspeed: ")(yspeed); 681 736 break; … … 734 789 */ 735 790 videoViewer = new VideoViewer(); 736 videoViewer.defaultSize( 0.5f, 0.5f );737 videoViewer.initVideoGL();791 //videoViewer.defaultSize( 0.5f, 0.5f ); 792 //videoViewer.initVideoGL(); 738 793 //add( videoViewer ); 739 794 … … 741 796 742 797 743 myWindow2 = new SubWindow(" 0.5windowrect");798 myWindow2 = new SubWindow("Viewer"); 744 799 //myWindow2.isRotate = true; 745 800 Trace.formatln("{}", myWindow2 ); 746 myWindow2.defaultSize( 0. 5, 0.5);801 myWindow2.defaultSize( 0.8, 0.4 ); 747 802 Trace.formatln("{}", myWindow2 ); 748 803 //myWindow2.colour( 0.2, 0.5, 0.3, 0.5 ); 749 804 myWindow2.signalMouseButtonPress.attach(&clickHandler); 750 805 806 myWindow2.add(videoViewer); 807 751 808 add(myWindow2); 752 809 … … 754 811 755 812 756 myWindow3 = new SubWindow(" upleftwindow");813 myWindow3 = new SubWindow("Pihlaja"); 757 814 //myWindow2.isRotate = true; 758 815 Trace.formatln("{}", myWindow3 ); … … 818 875 myWindow3.add(insideButton);*/ 819 876 820 myWindow4 = new SubWindow(" rightsmallwindow");877 myWindow4 = new SubWindow("Timeline"); 821 878 myWindow4.moveTo( 0.3f, 0.0f ); 822 879 myWindow4.defaultSize( 0.2f, 0.1f ); … … 844 901 845 902 playButton = new Button("Play"); 846 playButton.moveTo(-0.5f, 0.0f );903 //playButton.moveTo(-0.5f, 0.0f ); 847 904 playButton.defaultSize( 0.1f, 0.05f ); 848 905 //playButton.colour( 0.3f, 0.3f, 0.3f, 0.7f ); 849 906 playButton.signalActivate.attach(&playHandler); 850 907 //playButton.signalMouseButtonPress.attach(&playHandler); 851 add(playButton);908 myWindow4.add(playButton); 852 909 853 910 exportButton = new Button("Export"); … … 856 913 exportButton.colour( 0.5f, 0.3f, 0.3f, 0.7f ); 857 914 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); 860 932 861 933 } … … 1107 1179 //playButton.colour( 1.0f, 1.0f, 1.0f, 1.0f ); 1108 1180 //clickcol = false; 1181 playButton.ungrabInput(); 1109 1182 } 1110 1183 else … … 1112 1185 //playButton.colour( 0.2f, 0.4f, 0.2f, 1.0f ); 1113 1186 //clickcol = true; 1187 playButton.grabInput(); 1114 1188 } 1115 1189 … … 1136 1210 Button exportButton; 1137 1211 Button playButton; 1212 Button seekToStartButton; 1213 Button seekToEndButton; 1214 Button seekFrameForwardButton; 1215 Button seekFrameBackwardButton; 1138 1216 SubWindow myWindow3; 1139 1217 SubWindow myWindow4; … … 1171 1249 } 1172 1250 } 1173 1251 /* 1174 1252 void render() 1175 1253 { … … 1184 1262 1185 1263 } 1264 */ 1186 1265 1187 1266 trunk/pihlaja/src/shiraz/av/AudioFileQT.d
r33 r39 84 84 } 85 85 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; 86 93 } 87 94 … … 97 104 int64_t length() { return m_length; } 98 105 99 void seek( int64_t position )106 synchronized void seek( int64_t position ) 100 107 { 101 108 //Trace.formatln("position:")(position); … … 105 112 } 106 113 107 void sampleseek( int, int64_t position )114 synchronized void sampleseek( int, int64_t position ) 108 115 { 109 116 seek( position ); 110 117 } 111 118 112 int fillBuffer( float* output, uint frames )119 synchronized int fillBuffer( float* output, uint frames ) 113 120 // sizof(output) == frames * 2 114 121 // File Format: 48000 stereo interleaved 115 122 { 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."); 118 125 119 126 // l_buffer and r_buffer are defined in the class definition 120 float[] templeft;121 float[] tempright;127 //float[] templeft; 128 //float[] tempright; 122 129 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; 125 135 int64_t diff = lqt_last_audio_position( m_qt, 0 ); 126 if ( frames > 4096)136 /*if ( frames > 4096) 127 137 { 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."); 128 140 templeft = new float[frames]; 129 141 tempright = new float[frames]; 130 142 left_buffer = templeft.ptr; 131 143 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 134 148 //lqt_decode_audio_track( m_qt, null, cast(float**)buf_pointer.ptr, frames, 0 ); 135 149 lqt_decode_audio_track( m_qt, null, buf_pointer.ptr, frames, 0 ); 150 136 151 diff = lqt_last_audio_position( m_qt, 0 ) - diff; 152 137 153 if ( m_oneShot ) 138 154 { … … 145 161 output[i * 2 + 1] = right_buffer[i]; 146 162 } 147 if ( frames > 4096)163 /*if ( frames > 4096) 148 164 { 149 165 delete left_buffer; 150 166 delete right_buffer; 151 } 167 }*/ 152 168 return diff; 153 169 } … … 166 182 float[4096] l_buffer; 167 183 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 ]; 168 189 } 169 190 trunk/pihlaja/src/shiraz/av/PortAudioPlaybackCore.d
r33 r39 93 93 //End TEMP sine stuff. 94 94 95 static bool thread_attach_once = true; 96 95 97 extern (C) 96 98 //static int portaudio_callback( void *input, void *output, unsigned long frames, PaTimestamp time, void* data ) … … 105 107 //scope(exit) Trace.formatln("portaudio_callback() END."); 106 108 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 ) 110 115 { 111 116 Trace.formatln("portaudio_callback() attaching thread."); 112 117 thread_attachThis(); 113 once = false;118 thread_attach_once = false; 114 119 } 115 120 … … 178 183 static PaStream* g_stream; 179 184 185 //synchronized 180 186 static bool portaudio_start( int rate, int frames, void* set_data ) 181 187 { … … 226 232 return false; 227 233 } 234 //synchronized 228 235 static bool portaudio_stop() 229 236 { … … 297 304 } 298 305 306 //synchronized 299 307 void play() 300 308 { … … 313 321 } 314 322 323 thread_attach_once = true; 315 324 316 325 //C: m_currentFrame = g_timeline.m_seekPosition; … … 343 352 void pause() { ; } 344 353 354 //synchronized 345 355 void stop() 346 356 { … … 369 379 } 370 380 371 //synchronized 372 int readAudio( float* outputBuffer, uint framesPerBuffer ) 381 synchronized int readAudio( float* outputBuffer, uint framesPerBuffer ) 373 382 { 374 383 //Trace.formatln("PortAudioPlaybackCore.readAudio() START."); … … 436 445 } 437 446 438 //synchronized 439 bool flipFrame() 447 synchronized bool flipFrame() 440 448 { 441 449 //Trace.formatln("flipFrame"); trunk/pihlaja/src/shiraz/canvas/Bezier.d
r37 r39 76 76 public Point next() 77 77 { 78 //if( nextTimeSetIsLoop == true )79 //isLoop = true;78 if( nextTimeSetIsLoop == true ) 79 isLoop = true; 80 80 81 81 Point ret = p( anim_i, anim_step/cast(float)STEPS ); … … 94 94 //now we set isLoop to true to show others 95 95 //that we're looping. Any better ideas for this API? 96 //nextTimeSetIsLoop = true;97 isLoop = true;96 nextTimeSetIsLoop = true; 97 //isLoop = true; 98 98 anim_i = 0; 99 99 anim_step = 0; trunk/pihlaja/src/shiraz/canvas/Draw.d
r38 r39 50 50 } 51 51 52 const real PI2 = PI * 2.0f; 53 54 void 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 76 void 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 52 133 void showText( char[] set_text, GLubyte[] image, uint wid, uint hei, uint chan, float[4] set_colour ) 53 134 { trunk/pihlaja/src/shiraz/canvas/Image.d
r29 r39 114 114 protected uint minFilter(){ return m_minFilter; } 115 115 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 116 122 void pushTexture() 117 123 { … … 120 126 glEnable( glTextureType ); 121 127 glBindTexture( glTextureType, m_id ); 128 129 glBlendFunc( blendSource, blendDestination ); 122 130 } 123 131 … … 384 392 } 385 393 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 386 426 uint findSmallestNumber(GLubyte[] image) 387 427 { trunk/pihlaja/src/shiraz/canvas/PlainRectangle.d
