dataPtr->minFramesPerBuffer = 9999999;
dataPtr->maxFramesPerBuffer = 0;
printf("-------------------------------------\n");
- printf("Stream suggestedOutputLatency = %g\n", outputParamsPtr->suggestedLatency );
+ printf("Stream parameter: suggestedOutputLatency = %g\n", outputParamsPtr->suggestedLatency );
+ if( framesPerBuffer == paFramesPerBufferUnspecified ){
+ printf("Stream parameter: user framesPerBuffer = paFramesPerBufferUnspecified\n" );
+ }else{
+ printf("Stream parameter: user framesPerBuffer = %d\n", framesPerBuffer );
+ }
err = Pa_OpenStream(
&stream,
NULL, /* no input */
dataPtr );
if( err != paNoError ) goto error1;
+ streamInfo = Pa_GetStreamInfo( stream );
+ printf("Stream info: inputLatency = %g\n", streamInfo->inputLatency );
+ printf("Stream info: outputLatency = %g\n", streamInfo->outputLatency );
+
err = Pa_StartStream( stream );
if( err != paNoError ) goto error2;
printf("Play for %d seconds.\n", NUM_SECONDS );
Pa_Sleep( NUM_SECONDS * 1000 );
-
- streamInfo = Pa_GetStreamInfo( stream );
- printf("Stream inputLatency = %g\n", streamInfo->inputLatency );
- printf("Stream outputLatency = %g\n", streamInfo->outputLatency );
+
printf(" minFramesPerBuffer = %4d\n", dataPtr->minFramesPerBuffer );
printf(" maxFramesPerBuffer = %4d\n", dataPtr->maxFramesPerBuffer );
-
err = Pa_StopStream( stream );
if( err != paNoError ) goto error2;
*/
static PaError CalculateBufferSettings(
- unsigned long *framesPerHostInputBuffer, unsigned long *hostInputBufferCount,
- unsigned long *framesPerHostOutputBuffer, unsigned long *hostOutputBufferCount,
+ unsigned long *hostFramesPerInputBuffer, unsigned long *hostInputBufferCount,
+ unsigned long *hostFramesPerOutputBuffer, unsigned long *hostOutputBufferCount,
int inputChannelCount, PaSampleFormat hostInputSampleFormat,
PaTime suggestedInputLatency, PaWinMmeStreamInfo *inputStreamInfo,
int outputChannelCount, PaSampleFormat hostOutputSampleFormat,
PaTime suggestedOutputLatency, PaWinMmeStreamInfo *outputStreamInfo,
- double sampleRate, unsigned long framesPerBuffer )
+ double sampleRate, unsigned long userFramesPerBuffer )
{
PaError result = paNoError;
int effectiveInputChannelCount, effectiveOutputChannelCount;
int hostInputSampleSize = Pa_GetSampleSize( hostInputSampleFormat );
if( hostInputSampleSize < 0 )
{
- result = hostInputSampleSize;
+ result = hostInputSampleSize; /* this is an error code */
goto error;
}
goto error;
}
- *framesPerHostInputBuffer = inputStreamInfo->framesPerBuffer;
+ *hostFramesPerInputBuffer = inputStreamInfo->framesPerBuffer;
*hostInputBufferCount = inputStreamInfo->bufferCount;
}
else
/* compute the following in bytes, then convert back to frames */
SelectBufferSizeAndCount(
- ((framesPerBuffer == paFramesPerBufferUnspecified)
+ ((userFramesPerBuffer == paFramesPerBufferUnspecified)
? PA_MME_MIN_HOST_BUFFER_FRAMES_WHEN_UNSPECIFIED_
- : framesPerBuffer ) * hostInputFrameSize, /* baseBufferSize */
+ : userFramesPerBuffer ) * hostInputFrameSize, /* baseBufferSize */
((unsigned long)(suggestedInputLatency * sampleRate)) * hostInputFrameSize, /* suggestedLatency */
4, /* baseBufferCount */
minimumBufferCount, maximumBufferSize,
&hostBufferSizeBytes, &hostBufferCount );
- *framesPerHostInputBuffer = hostBufferSizeBytes / hostInputFrameSize;
+ *hostFramesPerInputBuffer = hostBufferSizeBytes / hostInputFrameSize;
*hostInputBufferCount = hostBufferCount;
}
}
else
{
- *framesPerHostInputBuffer = 0;
+ *hostFramesPerInputBuffer = 0;
*hostInputBufferCount = 0;
}
goto error;
}
- *framesPerHostOutputBuffer = outputStreamInfo->framesPerBuffer;
+ *hostFramesPerOutputBuffer = outputStreamInfo->framesPerBuffer;
*hostOutputBufferCount = outputStreamInfo->bufferCount;
if( inputChannelCount > 0 ) /* full duplex */
{
- if( *framesPerHostInputBuffer != *framesPerHostOutputBuffer )
+ if( *hostFramesPerInputBuffer != *hostFramesPerOutputBuffer )
{
if( inputStreamInfo
&& ( inputStreamInfo->flags & paWinMmeUseLowLevelLatencyParameters ) )
and output buffer sizes, the larger buffer size
must be a multiple of the smaller buffer size */
- if( *framesPerHostInputBuffer < *framesPerHostOutputBuffer )
+ if( *hostFramesPerInputBuffer < *hostFramesPerOutputBuffer )
{
- if( *framesPerHostOutputBuffer % *framesPerHostInputBuffer != 0 )
+ if( *hostFramesPerOutputBuffer % *hostFramesPerInputBuffer != 0 )
{
result = paIncompatibleHostApiSpecificStreamInfo;
goto error;
}
else
{
- assert( *framesPerHostInputBuffer > *framesPerHostOutputBuffer );
- if( *framesPerHostInputBuffer % *framesPerHostOutputBuffer != 0 )
+ assert( *hostFramesPerInputBuffer > *hostFramesPerOutputBuffer );
+ if( *hostFramesPerInputBuffer % *hostFramesPerOutputBuffer != 0 )
{
result = paIncompatibleHostApiSpecificStreamInfo;
goto error;
/* a custom StreamInfo was not used for specifying the input buffer size,
so use the output buffer size, and approximately the same latency. */
- *framesPerHostInputBuffer = *framesPerHostOutputBuffer;
- *hostInputBufferCount = (((unsigned long)(suggestedInputLatency * sampleRate)) / *framesPerHostInputBuffer) + 1;
+ *hostFramesPerInputBuffer = *hostFramesPerOutputBuffer;
+ *hostInputBufferCount = (((unsigned long)(suggestedInputLatency * sampleRate)) / *hostFramesPerInputBuffer) + 1;
if( *hostInputBufferCount < PA_MME_MIN_HOST_INPUT_BUFFER_COUNT_FULL_DUPLEX_ )
*hostInputBufferCount = PA_MME_MIN_HOST_INPUT_BUFFER_COUNT_FULL_DUPLEX_;
/* compute the following in bytes, then convert back to frames */
SelectBufferSizeAndCount(
- ((framesPerBuffer == paFramesPerBufferUnspecified)
+ ((userFramesPerBuffer == paFramesPerBufferUnspecified)
? PA_MME_MIN_HOST_BUFFER_FRAMES_WHEN_UNSPECIFIED_
- : framesPerBuffer ) * hostOutputFrameSize, /* baseBufferSize */
+ : userFramesPerBuffer ) * hostOutputFrameSize, /* baseBufferSize */
((unsigned long)(suggestedOutputLatency * sampleRate)) * hostOutputFrameSize, /* suggestedLatency */
4, /* baseBufferCount */
minimumBufferCount,
maximumBufferSize,
&hostBufferSizeBytes, &hostBufferCount );
- *framesPerHostOutputBuffer = hostBufferSizeBytes / hostOutputFrameSize;
+ *hostFramesPerOutputBuffer = hostBufferSizeBytes / hostOutputFrameSize;
*hostOutputBufferCount = hostBufferCount;
and use that for input and output
*/
- if( *framesPerHostOutputBuffer != *framesPerHostInputBuffer )
+ if( *hostFramesPerOutputBuffer != *hostFramesPerInputBuffer )
{
- if( framesPerHostInputBuffer < framesPerHostOutputBuffer )
+ if( hostFramesPerInputBuffer < hostFramesPerOutputBuffer )
{
- unsigned long framesPerHostBuffer = *framesPerHostInputBuffer;
+ unsigned long framesPerHostBuffer = *hostFramesPerInputBuffer;
minimumBufferCount = PA_MME_MIN_HOST_OUTPUT_BUFFER_COUNT_;
ReselectBufferCount(
minimumBufferCount,
&hostBufferCount );
- *framesPerHostOutputBuffer = framesPerHostBuffer;
+ *hostFramesPerOutputBuffer = framesPerHostBuffer;
*hostOutputBufferCount = hostBufferCount;
}
else
{
- unsigned long framesPerHostBuffer = *framesPerHostOutputBuffer;
+ unsigned long framesPerHostBuffer = *hostFramesPerOutputBuffer;
minimumBufferCount = PA_MME_MIN_HOST_INPUT_BUFFER_COUNT_FULL_DUPLEX_;
ReselectBufferCount(
minimumBufferCount,
&hostBufferCount );
- *framesPerHostInputBuffer = framesPerHostBuffer;
+ *hostFramesPerInputBuffer = framesPerHostBuffer;
*hostInputBufferCount = hostBufferCount;
}
}
}
else
{
- *framesPerHostOutputBuffer = 0;
+ *hostFramesPerOutputBuffer = 0;
*hostOutputBufferCount = 0;
}