[vlc-commits] auhal: ignore invalid default audio device changes (fixes #9374)
David Fuhrmann
git at videolan.org
Thu Sep 12 21:50:03 CEST 2013
vlc | branch: master | David Fuhrmann <david.fuhrmann at googlemail.com> | Thu Sep 12 21:48:04 2013 +0200| [688f5db3c8764faed15a735f987b4fe85413a833] | committer: David Fuhrmann
auhal: ignore invalid default audio device changes (fixes #9374)
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=688f5db3c8764faed15a735f987b4fe85413a833
---
modules/audio_output/auhal.c | 27 +++++++++++++++++++++++++--
1 file changed, 25 insertions(+), 2 deletions(-)
diff --git a/modules/audio_output/auhal.c b/modules/audio_output/auhal.c
index 073adc9..3dab151 100644
--- a/modules/audio_output/auhal.c
+++ b/modules/audio_output/auhal.c
@@ -1565,9 +1565,32 @@ static OSStatus DefaultDeviceChangedListener(AudioObjectID inObjectID, UInt32 i
return -1;
if (!p_aout->sys->b_selected_dev_is_default)
- return 0;
+ return noErr;
+
+ AudioObjectID defaultDeviceID = 0;
+ UInt32 propertySize = sizeof(AudioObjectID);
+ AudioObjectPropertyAddress defaultDeviceAddress = { kAudioHardwarePropertyDefaultOutputDevice, kAudioDevicePropertyScopeOutput, kAudioObjectPropertyElementMaster };
+ propertySize = sizeof(AudioObjectID);
+ OSStatus err = AudioObjectGetPropertyData(kAudioObjectSystemObject, &defaultDeviceAddress, 0, NULL, &propertySize, &defaultDeviceID);
+ if (err != noErr) {
+ msg_Err(p_aout, "could not get default audio device [%4.4s]", (char *)&err);
+ return -1;
+ }
+
+ msg_Dbg(p_aout, "default device changed to %i", defaultDeviceID);
+
+ /*
+ * The default device id changes to 0 when switching to SPDIF for whatever reason.
+ * We need to ignore that.
+ */
+ if(defaultDeviceID == 0)
+ return noErr;
+
+ /* Also ignore events which announce the same device id */
+ if(defaultDeviceID == p_aout->sys->i_selected_dev)
+ return noErr;
- msg_Dbg(p_aout, "default device changed, resetting aout");
+ msg_Dbg(p_aout, "default device actually changed, resetting aout");
aout_RestartRequest(p_aout, AOUT_RESTART_OUTPUT);
return noErr;
More information about the vlc-commits
mailing list