]> Repos - portaudio/commitdiff
pa_mac_core: use MAX(inputFrames,outputFrames)
authorPhil Burk <philburk@mobileer.com>
Thu, 22 Sep 2016 16:05:38 +0000 (09:05 -0700)
committerPhil Burk <philburk@mobileer.com>
Thu, 22 Sep 2016 16:05:38 +0000 (09:05 -0700)
Double-check whether the stream does ouput before draining the buffer.

src/hostapi/coreaudio/pa_mac_core.c

index beb6bae0a48daf15b279f234525bc13247c219ea..3fba82a3d7a5958c79a8c546b3d0b28ab0a5c9e2 100644 (file)
@@ -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 );
 }