Bugzilla – Attachment 969 Details for
Bug 7450
Default audio devices not respected on macOS
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
patch to sync default devices
defdev.patch (text/plain), 4.67 KB, created by
Pierre Ossman
on 2020-11-17 14:55:46 CET
(
hide
)
Description:
patch to sync default devices
Filename:
MIME Type:
Creator:
Pierre Ossman
Created:
2020-11-17 14:55:46 CET
Size:
4.67 KB
patch
obsolete
>diff --git a/client/pulseaudio/src/modules/macosx/module-coreaudio-detect.c b/client/pulseaudio/src/modules/macosx/module-coreaudio-detect.c >index d9c09da5e..fea95f688 100644 >--- a/client/pulseaudio/src/modules/macosx/module-coreaudio-detect.c >+++ b/client/pulseaudio/src/modules/macosx/module-coreaudio-detect.c >@@ -26,6 +26,7 @@ > #include <pulsecore/module.h> > #include <pulsecore/core-util.h> > #include <pulsecore/modargs.h> >+#include <pulsecore/namereg.h> > #include <pulsecore/log.h> > #include <pulsecore/llist.h> > >@@ -115,6 +116,7 @@ static int ca_update_device_list(struct pa_module *m) { > OSStatus err; > UInt32 i, size, num_devices; > AudioDeviceID *device_id; >+ AudioDeviceID default_id; > struct ca_device *dev; > struct userdata *u; > >@@ -178,6 +180,68 @@ scan_removed: > } > } > >+ /* configure the default source */ >+ >+ property_address.mSelector = kAudioHardwarePropertyDefaultInputDevice; >+ property_address.mScope = kAudioObjectPropertyScopeGlobal; >+ property_address.mElement = kAudioObjectPropertyElementMaster; >+ >+ size = sizeof(AudioDeviceID); >+ err = AudioObjectGetPropertyData(kAudioObjectSystemObject, &property_address, 0, NULL, &size, &default_id); >+ if (err) { >+ pa_log("Unable to get kAudioHardwarePropertyDefaultInputDevice."); >+ } else { >+ PA_LLIST_FOREACH(dev, u->devices) { >+ pa_source *source; >+ uint32_t idx; >+ >+ if (dev->id != default_id) >+ continue; >+ >+ PA_IDXSET_FOREACH(source, m->core->sources, idx) { >+ if (source->monitor_of) >+ continue; >+ if (!source->module || source->module->index != dev->module_index) >+ continue; >+ >+ pa_namereg_set_default_source(m->core, source); >+ break; >+ } >+ >+ break; >+ } >+ } >+ >+ /* configure the default source */ >+ >+ property_address.mSelector = kAudioHardwarePropertyDefaultOutputDevice; >+ property_address.mScope = kAudioObjectPropertyScopeGlobal; >+ property_address.mElement = kAudioObjectPropertyElementMaster; >+ >+ size = sizeof(AudioDeviceID); >+ err = AudioObjectGetPropertyData(kAudioObjectSystemObject, &property_address, 0, NULL, &size, &default_id); >+ if (err) { >+ pa_log("Unable to get kAudioHardwarePropertyDefaultOutputDevice."); >+ } else { >+ PA_LLIST_FOREACH(dev, u->devices) { >+ pa_sink *sink; >+ uint32_t idx; >+ >+ if (dev->id != default_id) >+ continue; >+ >+ PA_IDXSET_FOREACH(sink, m->core->sinks, idx) { >+ if (!sink->module || sink->module->index != dev->module_index) >+ continue; >+ >+ pa_namereg_set_default_sink(m->core, sink); >+ break; >+ } >+ >+ break; >+ } >+ } >+ > pa_xfree(device_id); > return 0; > } >@@ -231,6 +295,24 @@ int pa__init(pa_module *m) { > goto fail; > } > >+ property_address.mSelector = kAudioHardwarePropertyDefaultInputDevice; >+ property_address.mScope = kAudioObjectPropertyScopeGlobal; >+ property_address.mElement = kAudioObjectPropertyElementMaster; >+ >+ if (AudioObjectAddPropertyListener(kAudioObjectSystemObject, &property_address, property_listener_proc, u)) { >+ pa_log("AudioObjectAddPropertyListener() failed."); >+ goto fail; >+ } >+ >+ property_address.mSelector = kAudioHardwarePropertyDefaultOutputDevice; >+ property_address.mScope = kAudioObjectPropertyScopeGlobal; >+ property_address.mElement = kAudioObjectPropertyElementMaster; >+ >+ if (AudioObjectAddPropertyListener(kAudioObjectSystemObject, &property_address, property_listener_proc, u)) { >+ pa_log("AudioObjectAddPropertyListener() failed."); >+ goto fail; >+ } >+ > if (ca_update_device_list(m)) > goto fail; > >@@ -260,6 +342,18 @@ void pa__done(pa_module *m) { > > AudioObjectRemovePropertyListener(kAudioObjectSystemObject, &property_address, property_listener_proc, u); > >+ property_address.mSelector = kAudioHardwarePropertyDefaultInputDevice; >+ property_address.mScope = kAudioObjectPropertyScopeGlobal; >+ property_address.mElement = kAudioObjectPropertyElementMaster; >+ >+ AudioObjectRemovePropertyListener(kAudioObjectSystemObject, &property_address, property_listener_proc, u); >+ >+ property_address.mSelector = kAudioHardwarePropertyDefaultOutputDevice; >+ property_address.mScope = kAudioObjectPropertyScopeGlobal; >+ property_address.mElement = kAudioObjectPropertyElementMaster; >+ >+ AudioObjectRemovePropertyListener(kAudioObjectSystemObject, &property_address, property_listener_proc, u); >+ > while (dev) { > struct ca_device *next = dev->next; >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 7450
: 969