paqa_latency: tweak parameter printing

This commit is contained in:
rossb 2011-07-28 05:45:57 +00:00
commit 3ed32c7a04
2 changed files with 38 additions and 33 deletions

View file

@ -116,7 +116,12 @@ PaError paqaCheckLatency( PaStreamParameters *outputParamsPtr,
dataPtr->minFramesPerBuffer = 9999999; dataPtr->minFramesPerBuffer = 9999999;
dataPtr->maxFramesPerBuffer = 0; dataPtr->maxFramesPerBuffer = 0;
printf("-------------------------------------\n"); 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( err = Pa_OpenStream(
&stream, &stream,
NULL, /* no input */ NULL, /* no input */
@ -128,19 +133,19 @@ PaError paqaCheckLatency( PaStreamParameters *outputParamsPtr,
dataPtr ); dataPtr );
if( err != paNoError ) goto error1; 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 ); err = Pa_StartStream( stream );
if( err != paNoError ) goto error2; if( err != paNoError ) goto error2;
printf("Play for %d seconds.\n", NUM_SECONDS ); printf("Play for %d seconds.\n", NUM_SECONDS );
Pa_Sleep( NUM_SECONDS * 1000 ); 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(" minFramesPerBuffer = %4d\n", dataPtr->minFramesPerBuffer );
printf(" maxFramesPerBuffer = %4d\n", dataPtr->maxFramesPerBuffer ); printf(" maxFramesPerBuffer = %4d\n", dataPtr->maxFramesPerBuffer );
err = Pa_StopStream( stream ); err = Pa_StopStream( stream );
if( err != paNoError ) goto error2; if( err != paNoError ) goto error2;

View file

@ -1453,13 +1453,13 @@ static void ReselectBufferCount( unsigned long bufferSize,
*/ */
static PaError CalculateBufferSettings( static PaError CalculateBufferSettings(
unsigned long *framesPerHostInputBuffer, unsigned long *hostInputBufferCount, unsigned long *hostFramesPerInputBuffer, unsigned long *hostInputBufferCount,
unsigned long *framesPerHostOutputBuffer, unsigned long *hostOutputBufferCount, unsigned long *hostFramesPerOutputBuffer, unsigned long *hostOutputBufferCount,
int inputChannelCount, PaSampleFormat hostInputSampleFormat, int inputChannelCount, PaSampleFormat hostInputSampleFormat,
PaTime suggestedInputLatency, PaWinMmeStreamInfo *inputStreamInfo, PaTime suggestedInputLatency, PaWinMmeStreamInfo *inputStreamInfo,
int outputChannelCount, PaSampleFormat hostOutputSampleFormat, int outputChannelCount, PaSampleFormat hostOutputSampleFormat,
PaTime suggestedOutputLatency, PaWinMmeStreamInfo *outputStreamInfo, PaTime suggestedOutputLatency, PaWinMmeStreamInfo *outputStreamInfo,
double sampleRate, unsigned long framesPerBuffer ) double sampleRate, unsigned long userFramesPerBuffer )
{ {
PaError result = paNoError; PaError result = paNoError;
int effectiveInputChannelCount, effectiveOutputChannelCount; int effectiveInputChannelCount, effectiveOutputChannelCount;
@ -1471,7 +1471,7 @@ static PaError CalculateBufferSettings(
int hostInputSampleSize = Pa_GetSampleSize( hostInputSampleFormat ); int hostInputSampleSize = Pa_GetSampleSize( hostInputSampleFormat );
if( hostInputSampleSize < 0 ) if( hostInputSampleSize < 0 )
{ {
result = hostInputSampleSize; result = hostInputSampleSize; /* this is an error code */
goto error; goto error;
} }
@ -1505,7 +1505,7 @@ static PaError CalculateBufferSettings(
goto error; goto error;
} }
*framesPerHostInputBuffer = inputStreamInfo->framesPerBuffer; *hostFramesPerInputBuffer = inputStreamInfo->framesPerBuffer;
*hostInputBufferCount = inputStreamInfo->bufferCount; *hostInputBufferCount = inputStreamInfo->bufferCount;
} }
else else
@ -1522,21 +1522,21 @@ static PaError CalculateBufferSettings(
/* compute the following in bytes, then convert back to frames */ /* compute the following in bytes, then convert back to frames */
SelectBufferSizeAndCount( SelectBufferSizeAndCount(
((framesPerBuffer == paFramesPerBufferUnspecified) ((userFramesPerBuffer == paFramesPerBufferUnspecified)
? PA_MME_MIN_HOST_BUFFER_FRAMES_WHEN_UNSPECIFIED_ ? PA_MME_MIN_HOST_BUFFER_FRAMES_WHEN_UNSPECIFIED_
: framesPerBuffer ) * hostInputFrameSize, /* baseBufferSize */ : userFramesPerBuffer ) * hostInputFrameSize, /* baseBufferSize */
((unsigned long)(suggestedInputLatency * sampleRate)) * hostInputFrameSize, /* suggestedLatency */ ((unsigned long)(suggestedInputLatency * sampleRate)) * hostInputFrameSize, /* suggestedLatency */
4, /* baseBufferCount */ 4, /* baseBufferCount */
minimumBufferCount, maximumBufferSize, minimumBufferCount, maximumBufferSize,
&hostBufferSizeBytes, &hostBufferCount ); &hostBufferSizeBytes, &hostBufferCount );
*framesPerHostInputBuffer = hostBufferSizeBytes / hostInputFrameSize; *hostFramesPerInputBuffer = hostBufferSizeBytes / hostInputFrameSize;
*hostInputBufferCount = hostBufferCount; *hostInputBufferCount = hostBufferCount;
} }
} }
else else
{ {
*framesPerHostInputBuffer = 0; *hostFramesPerInputBuffer = 0;
*hostInputBufferCount = 0; *hostInputBufferCount = 0;
} }
@ -1552,13 +1552,13 @@ static PaError CalculateBufferSettings(
goto error; goto error;
} }
*framesPerHostOutputBuffer = outputStreamInfo->framesPerBuffer; *hostFramesPerOutputBuffer = outputStreamInfo->framesPerBuffer;
*hostOutputBufferCount = outputStreamInfo->bufferCount; *hostOutputBufferCount = outputStreamInfo->bufferCount;
if( inputChannelCount > 0 ) /* full duplex */ if( inputChannelCount > 0 ) /* full duplex */
{ {
if( *framesPerHostInputBuffer != *framesPerHostOutputBuffer ) if( *hostFramesPerInputBuffer != *hostFramesPerOutputBuffer )
{ {
if( inputStreamInfo if( inputStreamInfo
&& ( inputStreamInfo->flags & paWinMmeUseLowLevelLatencyParameters ) ) && ( inputStreamInfo->flags & paWinMmeUseLowLevelLatencyParameters ) )
@ -1567,9 +1567,9 @@ static PaError CalculateBufferSettings(
and output buffer sizes, the larger buffer size and output buffer sizes, the larger buffer size
must be a multiple of the smaller 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; result = paIncompatibleHostApiSpecificStreamInfo;
goto error; goto error;
@ -1577,8 +1577,8 @@ static PaError CalculateBufferSettings(
} }
else else
{ {
assert( *framesPerHostInputBuffer > *framesPerHostOutputBuffer ); assert( *hostFramesPerInputBuffer > *hostFramesPerOutputBuffer );
if( *framesPerHostInputBuffer % *framesPerHostOutputBuffer != 0 ) if( *hostFramesPerInputBuffer % *hostFramesPerOutputBuffer != 0 )
{ {
result = paIncompatibleHostApiSpecificStreamInfo; result = paIncompatibleHostApiSpecificStreamInfo;
goto error; goto error;
@ -1590,8 +1590,8 @@ static PaError CalculateBufferSettings(
/* a custom StreamInfo was not used for specifying the input buffer size, /* a custom StreamInfo was not used for specifying the input buffer size,
so use the output buffer size, and approximately the same latency. */ so use the output buffer size, and approximately the same latency. */
*framesPerHostInputBuffer = *framesPerHostOutputBuffer; *hostFramesPerInputBuffer = *hostFramesPerOutputBuffer;
*hostInputBufferCount = (((unsigned long)(suggestedInputLatency * sampleRate)) / *framesPerHostInputBuffer) + 1; *hostInputBufferCount = (((unsigned long)(suggestedInputLatency * sampleRate)) / *hostFramesPerInputBuffer) + 1;
if( *hostInputBufferCount < PA_MME_MIN_HOST_INPUT_BUFFER_COUNT_FULL_DUPLEX_ ) if( *hostInputBufferCount < PA_MME_MIN_HOST_INPUT_BUFFER_COUNT_FULL_DUPLEX_ )
*hostInputBufferCount = PA_MME_MIN_HOST_INPUT_BUFFER_COUNT_FULL_DUPLEX_; *hostInputBufferCount = PA_MME_MIN_HOST_INPUT_BUFFER_COUNT_FULL_DUPLEX_;
@ -1642,16 +1642,16 @@ static PaError CalculateBufferSettings(
/* compute the following in bytes, then convert back to frames */ /* compute the following in bytes, then convert back to frames */
SelectBufferSizeAndCount( SelectBufferSizeAndCount(
((framesPerBuffer == paFramesPerBufferUnspecified) ((userFramesPerBuffer == paFramesPerBufferUnspecified)
? PA_MME_MIN_HOST_BUFFER_FRAMES_WHEN_UNSPECIFIED_ ? PA_MME_MIN_HOST_BUFFER_FRAMES_WHEN_UNSPECIFIED_
: framesPerBuffer ) * hostOutputFrameSize, /* baseBufferSize */ : userFramesPerBuffer ) * hostOutputFrameSize, /* baseBufferSize */
((unsigned long)(suggestedOutputLatency * sampleRate)) * hostOutputFrameSize, /* suggestedLatency */ ((unsigned long)(suggestedOutputLatency * sampleRate)) * hostOutputFrameSize, /* suggestedLatency */
4, /* baseBufferCount */ 4, /* baseBufferCount */
minimumBufferCount, minimumBufferCount,
maximumBufferSize, maximumBufferSize,
&hostBufferSizeBytes, &hostBufferCount ); &hostBufferSizeBytes, &hostBufferCount );
*framesPerHostOutputBuffer = hostBufferSizeBytes / hostOutputFrameSize; *hostFramesPerOutputBuffer = hostBufferSizeBytes / hostOutputFrameSize;
*hostOutputBufferCount = hostBufferCount; *hostOutputBufferCount = hostBufferCount;
@ -1662,11 +1662,11 @@ static PaError CalculateBufferSettings(
and use that for input and output 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_; minimumBufferCount = PA_MME_MIN_HOST_OUTPUT_BUFFER_COUNT_;
ReselectBufferCount( ReselectBufferCount(
@ -1676,12 +1676,12 @@ static PaError CalculateBufferSettings(
minimumBufferCount, minimumBufferCount,
&hostBufferCount ); &hostBufferCount );
*framesPerHostOutputBuffer = framesPerHostBuffer; *hostFramesPerOutputBuffer = framesPerHostBuffer;
*hostOutputBufferCount = hostBufferCount; *hostOutputBufferCount = hostBufferCount;
} }
else else
{ {
unsigned long framesPerHostBuffer = *framesPerHostOutputBuffer; unsigned long framesPerHostBuffer = *hostFramesPerOutputBuffer;
minimumBufferCount = PA_MME_MIN_HOST_INPUT_BUFFER_COUNT_FULL_DUPLEX_; minimumBufferCount = PA_MME_MIN_HOST_INPUT_BUFFER_COUNT_FULL_DUPLEX_;
ReselectBufferCount( ReselectBufferCount(
@ -1691,7 +1691,7 @@ static PaError CalculateBufferSettings(
minimumBufferCount, minimumBufferCount,
&hostBufferCount ); &hostBufferCount );
*framesPerHostInputBuffer = framesPerHostBuffer; *hostFramesPerInputBuffer = framesPerHostBuffer;
*hostInputBufferCount = hostBufferCount; *hostInputBufferCount = hostBufferCount;
} }
} }
@ -1700,7 +1700,7 @@ static PaError CalculateBufferSettings(
} }
else else
{ {
*framesPerHostOutputBuffer = 0; *hostFramesPerOutputBuffer = 0;
*hostOutputBufferCount = 0; *hostOutputBufferCount = 0;
} }