]> Repos - portaudio/commitdiff
added test case to patest_stop_playout.c which catches issues with host buffers loopi...
authorrossb <rossb@0f58301d-fd10-0410-b4af-bbb618454e57>
Sun, 24 Jan 2010 11:48:06 +0000 (11:48 +0000)
committerrossb <rossb@0f58301d-fd10-0410-b4af-bbb618454e57>
Sun, 24 Jan 2010 11:48:06 +0000 (11:48 +0000)
test/patest_stop_playout.c

index 6372f569f1a1324fb7437086dbc63289de090657..94acb4768c50eb96c96b0ce80235043c10119f49 100644 (file)
@@ -307,7 +307,7 @@ int main(void)
     err = Pa_Initialize();
     if( err != paNoError ) goto error;
 
-    outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output device */
+    outputParameters.device = 7; //Pa_GetDefaultOutputDevice(); /* default output device */
     outputParameters.channelCount = 2;       /* stereo output */
     outputParameters.sampleFormat = paFloat32; /* 32 bit floating point output */
     outputParameters.suggestedLatency = Pa_GetDeviceInfo( outputParameters.device )->defaultHighOutputLatency;
@@ -331,16 +331,52 @@ int main(void)
     err = Pa_StartStream( stream );
     if( err != paNoError ) goto error;
 
-
     printf("\nPlaying 'tone-blip' %d times using callback, stops by returning paComplete from callback.\n", NUM_REPEATS );
     printf("If final blip is not intact, callback+paComplete implementation may be faulty.\n\n" );
 
+    while( (err = Pa_IsStreamActive( stream )) == 1 )
+        Pa_Sleep( 2 );
+
+    if( err != 0 ) goto error;
+
+    err = Pa_StopStream( stream );
+    if( err != paNoError ) goto error;
+
+    err = Pa_CloseStream( stream );
+    if( err != paNoError ) goto error;
+
+    Pa_Sleep( 500 );
+
+
+/* test paComplete ---------------------------------------------------------- */
+
+    ResetTestSignalGenerator( &data );
+
+    err = Pa_OpenStream(
+              &stream,
+              NULL, /* no input */
+              &outputParameters,
+              SAMPLE_RATE,
+              FRAMES_PER_BUFFER,
+              paClipOff,      /* we won't output out of range samples so don't bother clipping them */
+              TestCallback1,
+              &data );
+    if( err != paNoError ) goto error;
+
+    err = Pa_StartStream( stream );
+    if( err != paNoError ) goto error;
+
+    printf("\nPlaying 'tone-blip' %d times using callback, stops by returning paComplete from callback.\n", NUM_REPEATS );
+    printf("If final blip is not intact or is followed by garbage, callback+paComplete implementation may be faulty.\n\n" );
+
     while( (err = Pa_IsStreamActive( stream )) == 1 )
         Pa_Sleep( 5 );
 
+    printf("Waiting 5 seconds after paComplete before stopping the stream. Tests that buffers are flushed correctly.\n");
+    Pa_Sleep( 5000 );
+
     if( err != 0 ) goto error;
 
-    
     err = Pa_StopStream( stream );
     if( err != paNoError ) goto error;
 
@@ -349,6 +385,7 @@ int main(void)
 
     Pa_Sleep( 500 );
 
+
 /* test Pa_StopStream() with callback --------------------------------------- */
 
     ResetTestSignalGenerator( &data );
@@ -378,6 +415,8 @@ int main(void)
     while( !testCallback2Finished )
         Pa_Sleep( 2 );
 
+    Pa_Sleep( 500 );
+
     err = Pa_StopStream( stream );
     if( err != paNoError ) goto error;