1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # T2 SDE: package/*/pulseaudio/hotfix-alsa-ucm.patch
3 # Copyright (C) 2024 The T2 SDE Project
5 # This Copyright note is generated by scripts/Create-CopyPatch,
6 # more information can be found in the files COPYING and README.
8 # This patch file is dual-licensed. It is available under the license the
9 # patched project is licensed under, as long as it is an OpenSource license
10 # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
11 # of the GNU General Public License version 2 as used by the T2 SDE.
12 # --- T2-COPYRIGHT-NOTE-END ---
14 --- pulseaudio-17.0/src/modules/alsa/alsa-ucm.c.vanilla
15 +++ pulseaudio-17.0/src/modules/alsa/alsa-ucm.c
20 + if (!ucm->active_verb) {
21 + pa_log_error("Failed to get status for UCM device %s: no UCM verb set", dev_name);
25 devstatus = pa_sprintf_malloc("_devstatus/%s", dev_name);
26 if (snd_use_case_geti(ucm->ucm_mgr, devstatus, &status) < 0) {
27 pa_log_debug("Failed to get status for UCM device %s", dev_name);
29 static int ucm_device_disable(pa_alsa_ucm_config *ucm, pa_alsa_ucm_device *dev) {
30 const char *dev_name = pa_proplist_gets(dev->proplist, PA_ALSA_PROP_UCM_NAME);
32 + if (!ucm->active_verb) {
33 + pa_log_error("Failed to disable UCM device %s: no UCM verb set", dev_name);
37 /* If any of dev's conflicting devices is enabled, trying to disable
38 * dev gives an error despite the fact that it's already disabled.
39 * Check that dev is enabled to avoid this error. */
41 static int ucm_device_enable(pa_alsa_ucm_config *ucm, pa_alsa_ucm_device *dev) {
42 const char *dev_name = pa_proplist_gets(dev->proplist, PA_ALSA_PROP_UCM_NAME);
44 + if (!ucm->active_verb) {
45 + pa_log_error("Failed to enable UCM device %s: no UCM verb set", dev_name);
49 /* We don't need to enable devices that are already enabled */
50 if (ucm_device_status(ucm, dev) > 0) {
51 pa_log_debug("UCM device %s is already enabled", dev_name);
56 + if (!ucm->active_verb) {
57 + pa_log_error("Failed to get status for UCM modifier %s: no UCM verb set", mod_name);
61 modstatus = pa_sprintf_malloc("_modstatus/%s", mod_name);
62 if (snd_use_case_geti(ucm->ucm_mgr, modstatus, &status) < 0) {
63 pa_log_debug("Failed to get status for UCM modifier %s", mod_name);
65 static int ucm_modifier_disable(pa_alsa_ucm_config *ucm, pa_alsa_ucm_modifier *mod) {
66 const char *mod_name = pa_proplist_gets(mod->proplist, PA_ALSA_PROP_UCM_NAME);
68 + if (!ucm->active_verb) {
69 + pa_log_error("Failed to disable UCM modifier %s: no UCM verb set", mod_name);
73 /* We don't need to disable modifiers that are already disabled */
74 if (ucm_modifier_status(ucm, mod) == 0) {
75 pa_log_debug("UCM modifier %s is already disabled", mod_name);
77 static int ucm_modifier_enable(pa_alsa_ucm_config *ucm, pa_alsa_ucm_modifier *mod) {
78 const char *mod_name = pa_proplist_gets(mod->proplist, PA_ALSA_PROP_UCM_NAME);
80 + if (!ucm->active_verb) {
81 + pa_log_error("Failed to disable UCM modifier %s: no UCM verb set", mod_name);
85 /* We don't need to enable modifiers that are already enabled */
86 if (ucm_modifier_status(ucm, mod) > 0) {
87 pa_log_debug("UCM modifier %s is already enabled", mod_name);
89 pa_alsa_ucm_config *ucm;
90 pa_alsa_ucm_device *dev;
91 pa_alsa_ucm_port_data *data;
92 + const char *dev_name, *ucm_dev_name;
94 pa_assert(context && context->ucm);
96 @@ -1558,8 +1589,18 @@
97 pa_assert(ucm->ucm_mgr);
99 data = PA_DEVICE_PORT_DATA(port);
100 - dev = context->ucm_device;
101 - pa_assert(dev == data->device);
102 + dev = data->device;
105 + if (context->ucm_device) {
106 + dev_name = pa_proplist_gets(dev->proplist, PA_ALSA_PROP_UCM_NAME);
107 + ucm_dev_name = pa_proplist_gets(context->ucm_device->proplist, PA_ALSA_PROP_UCM_NAME);
108 + if (!pa_streq(dev_name, ucm_dev_name)) {
109 + pa_log_error("Failed to set port %s with wrong UCM context: %s", dev_name, ucm_dev_name);
115 return ucm_device_enable(ucm, dev);