* updated pyxdg (0.19 -> 0.28)
[t2sde.git] / package / audio / pulseaudio / hotfix-alsa-ucm.patch
blobd9719987d16f1cd689a90d0d5182d82d6178111b
1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # T2 SDE: package/*/pulseaudio/hotfix-alsa-ucm.patch
3 # Copyright (C) 2024 The T2 SDE Project
4 #
5 # This Copyright note is generated by scripts/Create-CopyPatch,
6 # more information can be found in the files COPYING and README.
7 #
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
16 @@ -624,6 +624,11 @@
17 char *devstatus;
18 long status = 0;
20 + if (!ucm->active_verb) {
21 + pa_log_error("Failed to get status for UCM device %s: no UCM verb set", dev_name);
22 + return -1;
23 + }
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);
28 @@ -637,6 +642,11 @@
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);
34 + return -1;
35 + }
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. */
40 @@ -657,6 +667,11 @@
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);
46 + return -1;
47 + }
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);
52 @@ -707,6 +722,11 @@
53 char *modstatus;
54 long status = 0;
56 + if (!ucm->active_verb) {
57 + pa_log_error("Failed to get status for UCM modifier %s: no UCM verb set", mod_name);
58 + return -1;
59 + }
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);
64 @@ -720,6 +740,11 @@
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);
70 + return -1;
71 + }
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);
76 @@ -738,6 +763,11 @@
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);
82 + return -1;
83 + }
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);
88 @@ -1551,6 +1581,7 @@
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;
103 + pa_assert(dev);
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);
110 + return -1;
115 return ucm_device_enable(ucm, dev);