From dfadcff5c912beee1d1b76d50d47adcea2e400e4 Mon Sep 17 00:00:00 2001 From: Gary Scavone Date: Sun, 7 Apr 2019 15:38:58 -0400 Subject: [PATCH] Added clearing of input user buffer in stopStream for OS-X, in case stream is restarted. --- RtAudio.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/RtAudio.cpp b/RtAudio.cpp index 912704e..0dff2d3 100644 --- a/RtAudio.cpp +++ b/RtAudio.cpp @@ -1656,7 +1656,12 @@ void RtApiCore :: stopStream( void ) stream_.state = STREAM_STOPPED; // set stream time to zero? - // and perhaps clear input user or device buffers? + // Clear user input buffer in case the stream is restarted + if ( stream_.mode == INPUT || stream_.mode == DUPLEX ) { + unsigned long bufferBytes; + bufferBytes = stream_.nUserChannels[1] * stream_.bufferSize * formatBytes( stream_.userFormat ); + memset( stream_.userBuffer[1], 0, bufferBytes * sizeof(char) ); + } unlock: if ( result == noErr ) return;