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;
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;
Pa_Sleep( 500 );
+
/* test Pa_StopStream() with callback --------------------------------------- */
ResetTestSignalGenerator( &data );
while( !testCallback2Finished )
Pa_Sleep( 2 );
+ Pa_Sleep( 500 );
+
err = Pa_StopStream( stream );
if( err != paNoError ) goto error;