Skip to content

Commit

Permalink
Remove CoreAudio device disconnect listener when closing input mode s…
Browse files Browse the repository at this point in the history
…treams

The flag handle->disconnectListenerAdded[0] is never set to true for input
mode streams because the probeOpenStream() code uses
handle->disconnectListenerAdded[mode].

This causes RtAudio to never remove device disconnect listeners, which can
cause the listener slots to fill up and an "illegal instruction" error code
to be returned when you try to add a new one.
  • Loading branch information
mikedickey committed Jan 10, 2024
1 parent 36b03e2 commit b0e3374
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion RtAudio.cpp
Expand Up @@ -1981,7 +1981,7 @@ void RtApiCore :: closeStream( void )
}
}

if ( handle->disconnectListenerAdded[0] ) {
if ( handle->disconnectListenerAdded[1] ) {
property.mSelector = kAudioDevicePropertyDeviceIsAlive;
if (AudioObjectRemovePropertyListener( handle->id[1], &property, streamDisconnectListener, (void *) &stream_.callbackInfo ) != noErr) {
errorText_ = "RtApiCore::closeStream(): error removing disconnect property listener!";
Expand Down

0 comments on commit b0e3374

Please sign in to comment.