PortAudio Tutorial |
The stream will not start running until you call Pa_StartStream(). Then it will start calling your callback function to perform the audio processing.home | contents | previous | nextAt this point, audio is being generated. You can communicate to your callback routine through the data structure you passed in on the open call, or through global variables, or using other interprocess communication techniques. Please be aware that your callback function may be called at interrupt time when your foreground process is least expecting it. So avoid sharing complex data structures that are easily corrupted like double linked lists.err = Pa_StartStream( stream ); if( err != paNoError ) goto error;In many of the tests we simply sleep for a few seconds so we can hear the sound. This is easy to do with Pa_Sleep() which will sleep for some number of milliseconds. Do not rely on this function for accurate scheduling. it is mostly for writing examples.
When you are through, you can stop the stream from the foreground./* Sleep for several seconds. */ Pa_Sleep(NUM_SECONDS*1000);You can also stop the stream by returning 1 from your custom callback function.err = Pa_StopStream( stream ); if( err != paNoError ) goto error;