Skip to content

Commit

Permalink
Remove paUtilVariableHostBufferSizePartialUsageAllowed
Browse files Browse the repository at this point in the history
DirectSound was the only host API using this mode, and its usage was
removed in the previous commit, making this mode dead code. As discussed
in that commit the value proposition of this mode is unclear, and it
does not behave correctly around stream start (priming) as shown in
PortAudio#770.
  • Loading branch information
dechamps committed May 25, 2024
1 parent ac3bb20 commit d7bc9c9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 37 deletions.
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

0 comments on commit d7bc9c9

Please sign in to comment.