pulseaudio/0019-alsa-ucm-parse-correctly-the-device-values.patch

126 lines
5.3 KiB
Diff
Raw Normal View History

Accepting request 774841 from home:tiwai:branches:multimedia:libs - Backport upstream fixes / enhancements about alsa modules: mainly for UCM support (boo#1160914): 0001-alsa-mixer-path-test-Hide-unused-functions-when-buil.patch 0002-alsa-mixer-recognize-the-Speaker-Jack-control.patch 0003-alsa-mixer-add-support-for-SteelSeries-Arctis-Pro-20.patch 0004-alsa-mixer-Add-support-for-SteelSeries-Arctis-5-2019.patch 0005-alsa-mixer-add-support-for-LucidSound-LS31-and-creat.patch 0006-alsa-ucm-use-ucm2-name-for-the-direct-card-index-ope.patch 0007-alsa-ucm-add-mixer-IDs-to-ucm_items.patch 0008-alsa-mixer-handle-the-index-for-ALSA-mixer-element-i.patch 0009-alsa-mixer-improve-alsa_id_decode-function.patch 0010-alsa-ucm-Support-Playback-CaptureVolume.patch 0011-alsa-ucm-Fix-volume-control-based-on-review.patch 0012-alsa-ucm-use-the-correct-mixer-identifiers-as-first.patch 0013-alsa-ucm-add-support-for-master-volume.patch 0014-alsa-ucm-split-correctly-JackHWMute-device-names.patch 0015-alsa-ucm-fix-parsing-for-JackControl.patch 0016-alsa-ucm-add-comments-to-ucm_get_mixer_id.patch 0017-alsa-ucm-validate-access-to-PA_DEVICE_PORT_DATA.patch 0018-alsa-Skip-resume-PCM-if-hardware-doesn-t-support-it.patch 0019-alsa-ucm-parse-correctly-the-device-values.patch 0020-alsa-ucm-do-not-try-to-use-UCM-device-name-as-jack-n.patch 0021-alsa-util-do-not-try-to-guess-the-mixer-name-from-th.patch 0022-alsa-ucm-add-control-and-mixer-device-items.patch 0023-alsa-ucm-get-the-mixer-names-from-ucm-don-t-guess.patch 0024-alsa-ucm-use-the-proper-mixer-name-for-ucm-pcm-sink-.patch 0025-alsa-mixer-handle-interface-type-CARD-PCM-for-mixer-.patch 0026-alsa-mixer-Add-the-ability-to-pass-the-intended-role.patch 0027-alsa-mixer-Set-the-intended-role-of-Steelseries-Arct.patch 0028-alsa-rewrite-mixer-open-close-cache-mixer-accesses-i.patch OBS-URL: https://build.opensuse.org/request/show/774841 OBS-URL: https://build.opensuse.org/package/show/multimedia:libs/pulseaudio?expand=0&rev=217
2020-02-17 11:47:50 +00:00
From 4c64f73c97c7f77426ee838f47fc7bad6a4563b6 Mon Sep 17 00:00:00 2001
From: Jaroslav Kysela <perex@perex.cz>
Date: Fri, 6 Dec 2019 21:51:47 +0100
Subject: [PATCH] alsa-ucm: parse correctly the device values
The UCM library is used to get the fallback values from the verbs
and the defaults section. There is no reason to duplicate this code
inside application.
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
---
src/modules/alsa/alsa-ucm.c | 55 ++++++---------------------------------------
1 file changed, 7 insertions(+), 48 deletions(-)
diff --git a/src/modules/alsa/alsa-ucm.c b/src/modules/alsa/alsa-ucm.c
index 3ee271845c19..ac1b71e94022 100644
--- a/src/modules/alsa/alsa-ucm.c
+++ b/src/modules/alsa/alsa-ucm.c
@@ -141,30 +141,6 @@ static struct ucm_info dev_info[] = {
{NULL, 0}
};
-/* UCM profile properties - The verb data is store so it can be used to fill
- * the new profiles properties */
-static int ucm_get_property(pa_alsa_ucm_verb *verb, snd_use_case_mgr_t *uc_mgr, const char *verb_name) {
- const char *value;
- char *id;
- int i;
-
- for (i = 0; item[i].id; i++) {
- int err;
-
- id = pa_sprintf_malloc("=%s//%s", item[i].id, verb_name);
- err = snd_use_case_get(uc_mgr, id, &value);
- pa_xfree(id);
- if (err < 0)
- continue;
-
- pa_log_debug("Got %s for verb %s: %s", item[i].id, verb_name, value);
- pa_proplist_sets(verb->proplist, item[i].property, value);
- free((void*)value);
- }
-
- return 0;
-};
-
static int ucm_device_exists(pa_idxset *idxset, pa_alsa_ucm_device *dev) {
pa_alsa_ucm_device *d;
uint32_t idx;
@@ -325,7 +301,7 @@ static int ucm_get_device_property(
pa_alsa_ucm_volume *vol;
for (i = 0; item[i].id; i++) {
- id = pa_sprintf_malloc("=%s/%s", item[i].id, device_name);
+ id = pa_sprintf_malloc("%s/%s", item[i].id, device_name);
err = snd_use_case_get(uc_mgr, id, &value);
pa_xfree(id);
if (err < 0)
@@ -347,14 +323,8 @@ static int ucm_get_device_property(
/* get pcm */
value = pa_proplist_gets(device->proplist, PA_ALSA_PROP_UCM_SINK);
- if (!value) { /* take pcm from verb playback default */
- value = pa_proplist_gets(verb->proplist, PA_ALSA_PROP_UCM_SINK);
- if (value) {
- pa_log_debug("UCM playback device %s fetch pcm from verb default %s", device_name, value);
- pa_proplist_sets(device->proplist, PA_ALSA_PROP_UCM_SINK, value);
- } else
- pa_log("UCM playback device %s fetch pcm failed", device_name);
- }
+ if (!value) /* take pcm from verb playback default */
+ pa_log("UCM playback device %s fetch pcm failed", device_name);
}
value = pa_proplist_gets(device->proplist, PA_ALSA_PROP_UCM_CAPTURE_CHANNELS);
@@ -367,14 +337,8 @@ static int ucm_get_device_property(
/* get pcm */
value = pa_proplist_gets(device->proplist, PA_ALSA_PROP_UCM_SOURCE);
- if (!value) { /* take pcm from verb capture default */
- value = pa_proplist_gets(verb->proplist, PA_ALSA_PROP_UCM_SOURCE);
- if (value) {
- pa_log_debug("UCM capture device %s fetch pcm from verb default %s", device_name, value);
- pa_proplist_sets(device->proplist, PA_ALSA_PROP_UCM_SOURCE, value);
- } else
- pa_log("UCM capture device %s fetch pcm failed", device_name);
- }
+ if (!value) /* take pcm from verb capture default */
+ pa_log("UCM capture device %s fetch pcm failed", device_name);
}
if (device->playback_channels == 0 && device->capture_channels == 0) {
@@ -387,8 +351,7 @@ static int ucm_get_device_property(
/* get rate and priority of device */
if (device->playback_channels) { /* sink device */
/* get rate */
- if ((value = pa_proplist_gets(device->proplist, PA_ALSA_PROP_UCM_PLAYBACK_RATE)) ||
- (value = pa_proplist_gets(verb->proplist, PA_ALSA_PROP_UCM_PLAYBACK_RATE))) {
+ if ((value = pa_proplist_gets(device->proplist, PA_ALSA_PROP_UCM_PLAYBACK_RATE))) {
if (pa_atou(value, &ui) == 0 && pa_sample_rate_valid(ui)) {
pa_log_debug("UCM playback device %s rate %d", device_name, ui);
device->playback_rate = ui;
@@ -417,8 +380,7 @@ static int ucm_get_device_property(
if (device->capture_channels) { /* source device */
/* get rate */
- if ((value = pa_proplist_gets(device->proplist, PA_ALSA_PROP_UCM_CAPTURE_RATE)) ||
- (value = pa_proplist_gets(verb->proplist, PA_ALSA_PROP_UCM_CAPTURE_RATE))) {
+ if ((value = pa_proplist_gets(device->proplist, PA_ALSA_PROP_UCM_CAPTURE_RATE))) {
if (pa_atou(value, &ui) == 0 && pa_sample_rate_valid(ui)) {
pa_log_debug("UCM capture device %s rate %d", device_name, ui);
device->capture_rate = ui;
@@ -796,9 +758,6 @@ int pa_alsa_ucm_get_verb(snd_use_case_mgr_t *uc_mgr, const char *verb_name, cons
if (err < 0)
pa_log("No UCM modifiers for verb %s", verb_name);
- /* Verb properties */
- ucm_get_property(verb, uc_mgr, verb_name);
-
PA_LLIST_FOREACH(d, verb->devices) {
const char *dev_name = pa_proplist_gets(d->proplist, PA_ALSA_PROP_UCM_NAME);
--
2.16.4