From: Phil Burk Date: Thu, 22 Sep 2016 16:05:38 +0000 (-0700) Subject: pa_mac_core: use MAX(inputFrames,outputFrames) X-Git-Tag: pa_stable_v190600_20161030~8^2~1 X-Git-Url: https://andrewgundersen.net/repos?a=commitdiff_plain;h=cacc5dc4ba848ce1aabed425ef9f465cd9e0babb;p=portaudio pa_mac_core: use MAX(inputFrames,outputFrames) Double-check whether the stream does ouput before draining the buffer. --- diff --git a/src/hostapi/coreaudio/pa_mac_core.c b/src/hostapi/coreaudio/pa_mac_core.c index beb6bae..3fba82a 100644 --- a/src/hostapi/coreaudio/pa_mac_core.c +++ b/src/hostapi/coreaudio/pa_mac_core.c @@ -2786,13 +2786,17 @@ static PaError StopStream( PaStream *s ) PaMacCoreStream *stream = (PaMacCoreStream*)s; VVDBUG(("StopStream()\n")); - // Tell WriteStream to stop filling the buffer while we are waiting for it to drain. + /* Tell WriteStream to stop filling the buffer. */ stream->state = STOPPING; - VDBUG( ("Waiting for BLIO.\n") ); - paErr = waitUntilBlioWriteBufferIsEmpty( &stream->blio, stream->sampleRate, stream->outputFramesPerBuffer ); - VDBUG( ( "waitUntilBlioWriteBufferIsEmpty returned %d\n", paErr ) ); - + if (stream->userOutChan > 0) /* Does this stream do output? */ + { + size_t maxHostFrames = MAX(stream->inputFramesPerBuffer, stream->outputFramesPerBuffer) + VDBUG( ("Waiting for write buffer to be drained.\n") ); + paErr = waitUntilBlioWriteBufferIsEmpty( &stream->blio, stream->sampleRate, + maxHostFrames); + VDBUG( ( "waitUntilBlioWriteBufferIsEmpty returned %d\n", paErr ) ); + } return FinishStoppingStream( stream ); }