From cd89b17a926c6c5732db10f317cd9b83c5d0558c Mon Sep 17 00:00:00 2001 From: Etienne Dechamps Date: Sat, 21 Jan 2023 14:56:44 +0000 Subject: [PATCH] WDM-KS: don't request a zero buffer size This fixes an issue where Pa_OpenStream() would fail on WDM-KS WinRT devices if suggestedLatency is zero. Fixes #761 --- src/hostapi/wdmks/pa_win_wdmks.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/hostapi/wdmks/pa_win_wdmks.c b/src/hostapi/wdmks/pa_win_wdmks.c index 0df5ba381..ad703b497 100644 --- a/src/hostapi/wdmks/pa_win_wdmks.c +++ b/src/hostapi/wdmks/pa_win_wdmks.c @@ -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 */ @@ -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 */