From 64936ef6ee60cd630d77dd725e85e86df2cb2e61 Mon Sep 17 00:00:00 2001 From: rossb Date: Sun, 24 Jan 2010 11:48:06 +0000 Subject: [PATCH] added test case to patest_stop_playout.c which catches issues with host buffers looping/not being cleared if the callback returns paComplete --- test/patest_stop_playout.c | 45 +++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/test/patest_stop_playout.c b/test/patest_stop_playout.c index 6372f56..94acb47 100644 --- a/test/patest_stop_playout.c +++ b/test/patest_stop_playout.c @@ -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; -- 2.43.0