Fix to CoreAudio update for deprecated behaviour.
authorGary Scavone <gary@music.mcgill.ca>
Wed, 28 Aug 2019 00:31:50 +0000 (20:31 -0400)
committerGary Scavone <gary@music.mcgill.ca>
Wed, 28 Aug 2019 00:31:50 +0000 (20:31 -0400)
RtAudio.cpp

index 9576d1670c1640631416cd66abbaea3c699374ac..1108c7482b945a8bb89cb8c674e1392e3a092d00 100644 (file)
@@ -1478,13 +1478,14 @@ void RtApiCore :: closeStream( void )
         errorText_ = "RtApiCore::closeStream(): error removing property listener!";
         error( RtAudioError::WARNING );
       }
-    }
-    if ( stream_.state == STREAM_RUNNING ) {
+
 #if defined( MAC_OS_X_VERSION_10_5 ) && ( MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 )
-      AudioDeviceStop( handle->id[0], handle->procId[0] );
+      if ( stream_.state == STREAM_RUNNING )
+        AudioDeviceStop( handle->id[0], handle->procId[0] );
       AudioDeviceDestroyIOProcID( handle->id[0], handle->procId[0] );
 #else // deprecated behaviour
-      AudioDeviceStop( handle->id[0], callbackHandler );
+      if ( stream_.state == STREAM_RUNNING )
+        AudioDeviceStop( handle->id[0], callbackHandler );
       AudioDeviceRemoveIOProc( handle->id[0], callbackHandler );
 #endif
     }
@@ -1502,13 +1503,14 @@ void RtApiCore :: closeStream( void )
         errorText_ = "RtApiCore::closeStream(): error removing property listener!";
         error( RtAudioError::WARNING );
       }
-    }
-    if ( stream_.state == STREAM_RUNNING ) {
+
 #if defined( MAC_OS_X_VERSION_10_5 ) && ( MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 )
-      AudioDeviceStop( handle->id[1], handle->procId[1] );
+      if ( stream_.state == STREAM_RUNNING )
+        AudioDeviceStop( handle->id[1], handle->procId[1] );
       AudioDeviceDestroyIOProcID( handle->id[1], handle->procId[1] );
 #else // deprecated behaviour
-      AudioDeviceStop( handle->id[1], callbackHandler );
+      if ( stream_.state == STREAM_RUNNING )
+        AudioDeviceStop( handle->id[1], callbackHandler );
       AudioDeviceRemoveIOProc( handle->id[1], callbackHandler );
 #endif
     }