Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop using paUtilVariableHostBufferSizePartialUsageAllowed in DirectSound #772

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 5 additions & 22 deletions src/common/pa_process.c
Original file line number Diff line number Diff line change
Expand Up @@ -1287,18 +1287,15 @@ static void CopyTempOutputBuffersToHostOutputBuffers( PaUtilBufferProcessor *bp)
data from the temporary output buffer into the host output buffers, then
from the host input buffers into the temporary input buffers. Calling the
streamCallback when necessary.
When processPartialUserBuffers is 0, all available input data will be
consumed and all available output space will be filled. When
processPartialUserBuffers is non-zero, as many full user buffers
as possible will be processed, but partial buffers will not be consumed.
All available input data will be consumed and all available output space
will be filled.
*/
static unsigned long AdaptingProcess( PaUtilBufferProcessor *bp,
int *streamCallbackResult, int processPartialUserBuffers )
int *streamCallbackResult )
{
void *userInput, *userOutput;
unsigned long framesProcessed = 0;
unsigned long framesAvailable;
unsigned long endProcessingMinFrameCount;
unsigned long maxFramesToCopy;
PaUtilChannelDescriptor *hostInputChannels, *hostOutputChannels;
unsigned int frameCount;
Expand All @@ -1310,15 +1307,10 @@ static unsigned long AdaptingProcess( PaUtilBufferProcessor *bp,

framesAvailable = bp->hostInputFrameCount[0] + bp->hostInputFrameCount[1];/* this is assumed to be the same as the output buffer's frame count */

if( processPartialUserBuffers )
endProcessingMinFrameCount = 0;
else
endProcessingMinFrameCount = (bp->framesPerUserBuffer - 1);

/* Fill host output with remaining frames in user output (tempOutputBuffer) */
CopyTempOutputBuffersToHostOutputBuffers( bp );

while( framesAvailable > endProcessingMinFrameCount )
while( framesAvailable >= bp->framesPerUserBuffer )
{

if( bp->framesInTempOutputBuffer == 0 && *streamCallbackResult != paContinue )
Expand Down Expand Up @@ -1612,16 +1604,7 @@ unsigned long PaUtil_EndBufferProcessing( PaUtilBufferProcessor* bp, int *stream
{
/* full duplex */

if( bp->hostBufferSizeMode == paUtilVariableHostBufferSizePartialUsageAllowed )
{
framesProcessed = AdaptingProcess( bp, streamCallbackResult,
0 /* dont process partial user buffers */ );
}
else
{
framesProcessed = AdaptingProcess( bp, streamCallbackResult,
1 /* process partial user buffers */ );
}
framesProcessed = AdaptingProcess( bp, streamCallbackResult );
}
else if( bp->inputChannelCount != 0 )
{
Expand Down
13 changes: 1 addition & 12 deletions src/common/pa_process.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,15 +225,6 @@ typedef enum {

/** Nothing is known about the host buffer size. */
paUtilUnknownHostBufferSize,

/** The host buffer size varies, and the client does not require the buffer
processor to consume all of the input and fill all of the output buffer. This
is useful when the implementation has access to the host API's circular buffer
and only needs to consume/fill some of it, not necessarily all of it, with each
call to the buffer processor. This is the only mode where
PaUtil_EndBufferProcessing() may not consume the whole buffer.
*/
paUtilVariableHostBufferSizePartialUsageAllowed
}PaUtilHostBufferSizeMode;


Expand Down Expand Up @@ -652,9 +643,7 @@ void PaUtil_BeginBufferProcessing( PaUtilBufferProcessor* bufferProcessor,
wasn't generated by the terminating callback.
@return The number of frames processed. This usually corresponds to the
number of frames specified by the PaUtil_Set*FrameCount functions, except in
the paUtilVariableHostBufferSizePartialUsageAllowed buffer size mode when a
smaller value may be returned.
number of frames specified by the PaUtil_Set*FrameCount functions.
*/
unsigned long PaUtil_EndBufferProcessing( PaUtilBufferProcessor* bufferProcessor,
int *callbackResult );
Expand Down
3 changes: 0 additions & 3 deletions src/hostapi/asihpi/pa_linux_asihpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1322,9 +1322,6 @@ static void PaAsiHpi_StreamComponentDump( PaAsiHpiStreamComponent *streamComp,
case paUtilUnknownHostBufferSize:
PA_DEBUG(( "[unknown] " ));
break;
case paUtilVariableHostBufferSizePartialUsageAllowed:
PA_DEBUG(( "[variable] " ));
break;
}
PA_DEBUG(( "(%d max)\n", streamComp->tempBufferSize / streamComp->bytesPerFrame ));
/* HPI hardware settings */
Expand Down
25 changes: 11 additions & 14 deletions src/hostapi/dsound/pa_win_ds.c
Original file line number Diff line number Diff line change
Expand Up @@ -2052,20 +2052,6 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
hostOutputSampleFormat = 0;
}

result = PaUtil_InitializeBufferProcessor( &stream->bufferProcessor,
inputChannelCount, inputSampleFormat, hostInputSampleFormat,
outputChannelCount, outputSampleFormat, hostOutputSampleFormat,
sampleRate, streamFlags, framesPerBuffer,
0, /* ignored in paUtilVariableHostBufferSizePartialUsageAllowed mode. */
/* This next mode is required because DS can split the host buffer when it wraps around. */
paUtilVariableHostBufferSizePartialUsageAllowed,
streamCallback, userData );
if( result != paNoError )
goto error;

bufferProcessorIsInitialized = 1;


/* DirectSound specific initialization */
{
HRESULT hr;
Expand Down Expand Up @@ -2131,6 +2117,17 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
DBUG(("DirectSound host buffer size frames: %d, polling period seconds: %f, @ sr: %f\n",
stream->hostBufferSizeFrames, stream->pollingPeriodSeconds, sampleRate ));

result = PaUtil_InitializeBufferProcessor(&stream->bufferProcessor,
inputChannelCount, inputSampleFormat, hostInputSampleFormat,
outputChannelCount, outputSampleFormat, hostOutputSampleFormat,
sampleRate, streamFlags, framesPerBuffer,
stream->hostBufferSizeFrames, paUtilBoundedHostBufferSize,
streamCallback, userData);
if (result != paNoError)
goto error;

bufferProcessorIsInitialized = 1;


/* ------------------ OUTPUT */
if( outputParameters )
Expand Down
Loading