Commit 1cb158c9 authored by Felix Paul Kühne's avatar Felix Paul Kühne

auhal: fix SPDIF -> default device fallback if SPDIF device is unplugged...

auhal: fix SPDIF -> default device fallback if SPDIF device is unplugged during playback (close #8286)
parent fb772d0f
...@@ -288,10 +288,22 @@ static int Start(audio_output_t *p_aout, audio_sample_format_t *restrict fmt) ...@@ -288,10 +288,22 @@ static int Start(audio_output_t *p_aout, audio_sample_format_t *restrict fmt)
b_alive = false; b_alive = false;
} }
if (!b_alive) { if (!b_alive || p_sys->i_selected_dev == 0) {
msg_Warn(p_aout, "selected audio device is not alive, switching to default device with id %i", p_sys->i_default_dev); msg_Warn(p_aout, "selected audio device is not alive, switching to default device");
p_sys->i_selected_dev = p_sys->i_default_dev;
p_sys->b_selected_dev_is_digital = false; AudioObjectID defaultDeviceID = 0;
UInt32 propertySize = 0;
AudioObjectPropertyAddress defaultDeviceAddress = { kAudioHardwarePropertyDefaultOutputDevice, kAudioDevicePropertyScopeOutput, kAudioObjectPropertyElementMaster };
propertySize = sizeof(AudioObjectID);
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);
goto error;
}
else
msg_Dbg(p_aout, "using default audio device %i", defaultDeviceID);
p_sys->i_selected_dev = defaultDeviceID;
} }
// recheck if device still supports digital // recheck if device still supports digital
...@@ -966,7 +978,7 @@ static void Stop(audio_output_t *p_aout) ...@@ -966,7 +978,7 @@ static void Stop(audio_output_t *p_aout)
static void ReportDevice(audio_output_t *p_aout, UInt32 i_id, char *name) static void ReportDevice(audio_output_t *p_aout, UInt32 i_id, char *name)
{ {
char deviceid[100]; char deviceid[10];
sprintf(deviceid, "%i", i_id); sprintf(deviceid, "%i", i_id);
aout_HotplugReport(p_aout, deviceid, name); aout_HotplugReport(p_aout, deviceid, name);
...@@ -976,7 +988,6 @@ static void RebuildDeviceList(audio_output_t * p_aout) ...@@ -976,7 +988,6 @@ static void RebuildDeviceList(audio_output_t * p_aout)
{ {
OSStatus err = noErr; OSStatus err = noErr;
UInt32 propertySize = 0; UInt32 propertySize = 0;
AudioObjectID defaultDeviceID = 0;
AudioObjectID *deviceIDs; AudioObjectID *deviceIDs;
UInt32 numberOfDevices; UInt32 numberOfDevices;
CFMutableArrayRef currentListOfDevices; CFMutableArrayRef currentListOfDevices;
...@@ -1014,16 +1025,6 @@ static void RebuildDeviceList(audio_output_t * p_aout) ...@@ -1014,16 +1025,6 @@ static void RebuildDeviceList(audio_output_t * p_aout)
return; return;
} }
/* Find the ID of the default Device */
AudioObjectPropertyAddress defaultDeviceAddress = { kAudioHardwarePropertyDefaultOutputDevice, kAudioDevicePropertyScopeOutput, kAudioObjectPropertyElementMaster };
propertySize = sizeof(AudioObjectID);
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;
}
p_sys->i_default_dev = defaultDeviceID;
AudioObjectPropertyAddress deviceNameAddress = { kAudioObjectPropertyName, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster }; AudioObjectPropertyAddress deviceNameAddress = { kAudioObjectPropertyName, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
for (unsigned int i = 0; i < numberOfDevices; i++) { for (unsigned int i = 0; i < numberOfDevices; i++) {
...@@ -1085,8 +1086,6 @@ static void RebuildDeviceList(audio_output_t * p_aout) ...@@ -1085,8 +1086,6 @@ static void RebuildDeviceList(audio_output_t * p_aout)
count = CFArrayGetCount(p_sys->device_list); count = CFArrayGetCount(p_sys->device_list);
if (count > 0) { if (count > 0) {
CFShow(currentListOfDevices);
CFShow(p_sys->device_list);
CFNumberRef cfn_device_id; CFNumberRef cfn_device_id;
int i_device_id = 0; int i_device_id = 0;
for (CFIndex x = 0; x < count; x++) { for (CFIndex x = 0; x < count; x++) {
......
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