A simplified version of Pa_OpenStream() that opens the default input and/or output devices.
Definition at line 1346 of file pa_front.c. References PaStreamParameters::channelCount, PaDeviceInfo::defaultHighInputLatency, PaDeviceInfo::defaultHighOutputLatency, PaStreamParameters::device, PaStreamParameters::hostApiSpecificStreamInfo, Pa_GetDefaultInputDevice(), Pa_GetDefaultOutputDevice(), Pa_OpenStream(), paNoFlag, PaUtil_DebugPrint(), PaStreamParameters::sampleFormat, and PaStreamParameters::suggestedLatency. {
PaError result;
PaStreamParameters hostApiInputParameters, hostApiOutputParameters;
PaStreamParameters *hostApiInputParametersPtr, *hostApiOutputParametersPtr;
#ifdef PA_LOG_API_CALLS
PaUtil_DebugPrint("Pa_OpenDefaultStream called:\n" );
PaUtil_DebugPrint("\tPaStream** stream: 0x%p\n", stream );
PaUtil_DebugPrint("\tint inputChannelCount: %d\n", inputChannelCount );
PaUtil_DebugPrint("\tint outputChannelCount: %d\n", outputChannelCount );
PaUtil_DebugPrint("\tPaSampleFormat sampleFormat: %d\n", sampleFormat );
PaUtil_DebugPrint("\tdouble sampleRate: %g\n", sampleRate );
PaUtil_DebugPrint("\tunsigned long framesPerBuffer: %d\n", framesPerBuffer );
PaUtil_DebugPrint("\tPaStreamCallback *streamCallback: 0x%p\n", streamCallback );
PaUtil_DebugPrint("\tvoid *userData: 0x%p\n", userData );
#endif
if( inputChannelCount > 0 )
{
hostApiInputParameters.device = Pa_GetDefaultInputDevice();
hostApiInputParameters.channelCount = inputChannelCount;
hostApiInputParameters.sampleFormat = sampleFormat;
/* defaultHighInputLatency is used below instead of
defaultLowInputLatency because it is more important for the default
stream to work reliably than it is for it to work with the lowest
latency.
*/
hostApiInputParameters.suggestedLatency =
Pa_GetDeviceInfo( hostApiInputParameters.device )->defaultHighInputLatency;
hostApiInputParameters.hostApiSpecificStreamInfo = NULL;
hostApiInputParametersPtr = &hostApiInputParameters;
}
else
{
hostApiInputParametersPtr = NULL;
}
if( outputChannelCount > 0 )
{
hostApiOutputParameters.device = Pa_GetDefaultOutputDevice();
hostApiOutputParameters.channelCount = outputChannelCount;
hostApiOutputParameters.sampleFormat = sampleFormat;
/* defaultHighOutputLatency is used below instead of
defaultLowOutputLatency because it is more important for the default
stream to work reliably than it is for it to work with the lowest
latency.
*/
hostApiOutputParameters.suggestedLatency =
Pa_GetDeviceInfo( hostApiOutputParameters.device )->defaultHighOutputLatency;
hostApiOutputParameters.hostApiSpecificStreamInfo = NULL;
hostApiOutputParametersPtr = &hostApiOutputParameters;
}
else
{
hostApiOutputParametersPtr = NULL;
}
result = Pa_OpenStream(
stream, hostApiInputParametersPtr, hostApiOutputParametersPtr,
sampleRate, framesPerBuffer, paNoFlag, streamCallback, userData );
#ifdef PA_LOG_API_CALLS
PaUtil_DebugPrint("Pa_OpenDefaultStream returned:\n" );
PaUtil_DebugPrint("\t*(PaStream** stream): 0x%p", *stream );
PaUtil_DebugPrint("\tPaError: %d ( %s )\n\n", result, Pa_GetErrorText( result ) );
#endif
return result;
}
|