Skip to content

Commit

Permalink
WDM-KS: don't request a zero buffer size
Browse files Browse the repository at this point in the history
This fixes an issue where Pa_OpenStream() would fail on WDM-KS WinRT
devices if suggestedLatency is zero.

Fixes PortAudio#761
  • Loading branch information
dechamps committed Feb 2, 2023
1 parent 4bccdfb commit cd89b17
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/hostapi/wdmks/pa_win_wdmks.c
Original file line number Diff line number Diff line change
Expand Up @@ -4734,6 +4734,12 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
{
stream->capture.framesPerBuffer = stream->capture.pPin->frameSize;
}

if(stream->capture.framesPerBuffer == 0) {
/* WinRT devices will reject a zero RequestedBufferSize. See https://github.com/PortAudio/portaudio/issues/761 */
stream->capture.framesPerBuffer = 1;
}

PA_DEBUG(("Input frames chosen:%ld\n",stream->capture.framesPerBuffer));

/* Setup number of packets to use */
Expand Down Expand Up @@ -4763,6 +4769,12 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
{
stream->render.framesPerBuffer = stream->render.pPin->frameSize;
}

if(stream->render.framesPerBuffer == 0) {
/* WinRT devices will reject a zero RequestedBufferSize. See https://github.com/PortAudio/portaudio/issues/761 */
stream->render.framesPerBuffer = 1;
}

PA_DEBUG(("Output frames chosen:%ld\n",stream->render.framesPerBuffer));

/* Setup number of packets to use */
Expand Down

0 comments on commit cd89b17

Please sign in to comment.