Bug fix for double stream time ticking in OS-X if duplex stream with two different...
authorGary Scavone <gary@music.mcgill.ca>
Sun, 7 Apr 2019 19:02:40 +0000 (15:02 -0400)
committerGary Scavone <gary@music.mcgill.ca>
Fri, 19 Apr 2019 19:16:47 +0000 (15:16 -0400)
RtAudio.cpp
tests/duplex.cpp

index fd8380b63d79c303a03fa402e6257e0b84349793..2edc14a1d489912b67550a18c1507060c6a299af 100644 (file)
@@ -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] ) )
index 494e5ad7ab121e6ffa1ac98537d064af20c2c9f2..c5abc3b60a5401e3999fa4cd5901310194899124 100644 (file)
@@ -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;