Commit aa73cad3 authored by Felix Paul Kühne's avatar Felix Paul Kühne

auhal: clean-up HardwareListener callback

parent 58a31eb2
...@@ -823,13 +823,13 @@ static void Stop(audio_output_t *p_aout) ...@@ -823,13 +823,13 @@ static void Stop(audio_output_t *p_aout)
UInt32 i_param_size = 0; UInt32 i_param_size = 0;
AudioObjectPropertyAddress deviceAliveAddress = { kAudioDevicePropertyDeviceIsAlive, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster }; AudioObjectPropertyAddress deviceAliveAddress = { kAudioDevicePropertyDeviceIsAlive, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
err = AudioObjectRemovePropertyListener(p_sys->i_selected_dev, &deviceAliveAddress, HardwareListener, NULL); err = AudioObjectRemovePropertyListener(p_sys->i_selected_dev, &deviceAliveAddress, HardwareListener, (void *)p_aout);
if (err != noErr) if (err != noErr)
msg_Err(p_aout, "failed to remove audio device life checker: [%4.4s]", (char *)&err); msg_Err(p_aout, "failed to remove audio device life checker: [%4.4s]", (char *)&err);
if (p_sys->b_digital) { if (p_sys->b_digital) {
AudioObjectPropertyAddress physicalFormatsAddress = { kAudioStreamPropertyAvailablePhysicalFormats, kAudioObjectPropertyScopeGlobal, 0 }; AudioObjectPropertyAddress physicalFormatsAddress = { kAudioStreamPropertyAvailablePhysicalFormats, kAudioObjectPropertyScopeGlobal, 0 };
err = AudioObjectRemovePropertyListener(p_sys->i_stream_id, &physicalFormatsAddress, HardwareListener, NULL); err = AudioObjectRemovePropertyListener(p_sys->i_stream_id, &physicalFormatsAddress, HardwareListener, (void *)p_aout);
if (err != noErr) if (err != noErr)
msg_Err(p_aout, "failed to remove audio device property streams callback: [%4.4s]", (char *)&err); msg_Err(p_aout, "failed to remove audio device property streams callback: [%4.4s]", (char *)&err);
} }
...@@ -876,7 +876,7 @@ static void Stop(audio_output_t *p_aout) ...@@ -876,7 +876,7 @@ static void Stop(audio_output_t *p_aout)
} }
AudioObjectPropertyAddress audioDevicesAddress = { kAudioHardwarePropertyDevices, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster }; AudioObjectPropertyAddress audioDevicesAddress = { kAudioHardwarePropertyDevices, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
err = AudioObjectRemovePropertyListener(kAudioObjectSystemObject, &audioDevicesAddress, HardwareListener, NULL); err = AudioObjectRemovePropertyListener(kAudioObjectSystemObject, &audioDevicesAddress, HardwareListener, (void *)p_aout);
if (err != noErr) if (err != noErr)
msg_Err(p_aout, "AudioHardwareRemovePropertyListener failed: [%4.4s]", (char *)&err); msg_Err(p_aout, "AudioHardwareRemovePropertyListener failed: [%4.4s]", (char *)&err);
...@@ -1359,23 +1359,33 @@ static OSStatus HardwareListener(AudioObjectID inObjectID, UInt32 inNumberAddre ...@@ -1359,23 +1359,33 @@ static OSStatus HardwareListener(AudioObjectID inObjectID, UInt32 inNumberAddre
audio_output_t *p_aout = (audio_output_t *)inClientData; audio_output_t *p_aout = (audio_output_t *)inClientData;
VLC_UNUSED(inObjectID); VLC_UNUSED(inObjectID);
if (!p_aout)
return -1;
#ifndef NDEBUG
for (unsigned int i = 0; i < inNumberAddresses; i++) { for (unsigned int i = 0; i < inNumberAddresses; i++) {
if (inAddresses[i].mSelector == kAudioHardwarePropertyDevices) { switch (inAddresses[i].mSelector) {
/* something changed in the list of devices */ case kAudioHardwarePropertyDevices:
/* We trigger the audio-device's aout_ChannelsRestart callback */ msg_Warn(p_aout, "audio device configuration changed, resetting cache");
msg_Warn(p_aout, "audio device configuration changed, resetting cache"); break;
var_TriggerCallback(p_aout, "audio-device");
var_Destroy(p_aout, "audio-device"); case kAudioDevicePropertyDeviceIsAlive:
} else if (inAddresses[i].mSelector == kAudioDevicePropertyDeviceIsAlive) { msg_Warn(p_aout, "audio device died, resetting aout");
msg_Warn(p_aout, "audio device died, resetting aout"); break;
var_TriggerCallback(p_aout, "audio-device");
var_Destroy(p_aout, "audio-device"); case kAudioStreamPropertyAvailablePhysicalFormats:
} else if (inAddresses[i].mSelector == kAudioStreamPropertyAvailablePhysicalFormats) { msg_Warn(p_aout, "available physical formats for audio device changed, resetting aout");
msg_Warn(p_aout, "available physical formats for audio device changed, resetting aout"); break;
var_TriggerCallback(p_aout, "audio-device");
var_Destroy(p_aout, "audio-device"); default:
msg_Warn(p_aout, "device reset for unknown reason (%i)", inAddresses[i].mSelector);
break;
} }
} }
#endif
var_TriggerCallback(p_aout, "audio-device");
var_Destroy(p_aout, "audio-device");
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment