From 0eb9c6351d0f7e51b625547af94b9c01828b2963 Mon Sep 17 00:00:00 2001 From: Gary Scavone Date: Sun, 7 Apr 2019 15:02:40 -0400 Subject: [PATCH] Bug fix for double stream time ticking in OS-X if duplex stream with two different devices. --- RtAudio.cpp | 1 - tests/duplex.cpp | 10 +++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/RtAudio.cpp b/RtAudio.cpp index fd8380b..2edc14a 100644 --- a/RtAudio.cpp +++ b/RtAudio.cpp @@ -1947,7 +1947,6 @@ bool RtApiCore :: callbackEvent( AudioDeviceID deviceId, } unlock: - //MUTEX_UNLOCK( &stream_.mutex ); // Make sure to only tick duplex stream time once if using two devices if ( stream_.mode != DUPLEX || (stream_.mode == DUPLEX && handle->id[0] != handle->id[1] && deviceId == handle->id[0] ) ) diff --git a/tests/duplex.cpp b/tests/duplex.cpp index 494e5ad..c5abc3b 100644 --- a/tests/duplex.cpp +++ b/tests/duplex.cpp @@ -48,13 +48,21 @@ void usage( void ) { exit( 0 ); } +double streamTimePrintIncrement = 1.0; // seconds +double streamTimePrintTime = 1.0; // seconds + int inout( void *outputBuffer, void *inputBuffer, unsigned int /*nBufferFrames*/, - double /*streamTime*/, RtAudioStreamStatus status, void *data ) + double streamTime, RtAudioStreamStatus status, void *data ) { // Since the number of input and output channels is equal, we can do // a simple buffer copy operation here. if ( status ) std::cout << "Stream over/underflow detected." << std::endl; + if ( streamTime >= streamTimePrintTime ) { + std::cout << "streamTime = " << streamTime << std::endl; + streamTimePrintTime += streamTimePrintIncrement; + } + unsigned int *bytes = (unsigned int *) data; memcpy( outputBuffer, inputBuffer, *bytes ); return 0; -- 2.30.2