]> code.delx.au - pulseaudio/blobdiff - src/modules/alsa/module-alsa-card.c
alsa: Use card description in default sink/source prefix when available
[pulseaudio] / src / modules / alsa / module-alsa-card.c
index be982ed59b7f5053120f2183884fbcfeb2348a26..63ff6e6d480ad8cc79070e63eddd72af6a797a4d 100644 (file)
@@ -204,6 +204,7 @@ static int card_set_profile(pa_card *c, pa_card_profile *new_profile) {
     uint32_t idx;
     pa_alsa_mapping *am;
     pa_queue *sink_inputs = NULL, *source_outputs = NULL;
+    int ret = 0;
 
     pa_assert(c);
     pa_assert(new_profile);
@@ -245,8 +246,10 @@ static int card_set_profile(pa_card *c, pa_card_profile *new_profile) {
     /* if UCM is available for this card then update the verb */
     if (u->use_ucm) {
         if (pa_alsa_ucm_set_profile(&u->ucm, nd->profile ? nd->profile->name : NULL,
-                    od->profile ? od->profile->name : NULL) < 0)
-            return -1;
+                    od->profile ? od->profile->name : NULL) < 0) {
+            ret = -1;
+            goto finish;
+        }
     }
 
     if (nd->profile && nd->profile->output_mappings)
@@ -273,13 +276,14 @@ static int card_set_profile(pa_card *c, pa_card_profile *new_profile) {
             }
         }
 
+finish:
     if (sink_inputs)
         pa_sink_move_all_fail(sink_inputs);
 
     if (source_outputs)
         pa_source_move_all_fail(source_outputs);
 
-    return 0;
+    return ret;
 }
 
 static void init_profile(struct userdata *u) {
@@ -603,7 +607,6 @@ static pa_hook_result_t source_output_unlink_hook_callback(pa_core *c, pa_source
 
 int pa__init(pa_module *m) {
     pa_card_new_data data;
-    pa_modargs *ma;
     bool ignore_dB = false;
     struct userdata *u;
     pa_reserve_wrapper *reserve = NULL;
@@ -616,30 +619,29 @@ int pa__init(pa_module *m) {
 
     pa_assert(m);
 
-    if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
-        pa_log("Failed to parse module arguments");
-        goto fail;
-    }
-
-    if (pa_modargs_get_value_boolean(ma, "ignore_dB", &ignore_dB) < 0) {
-        pa_log("Failed to parse ignore_dB argument.");
-        goto fail;
-    }
-
     m->userdata = u = pa_xnew0(struct userdata, 1);
     u->core = m->core;
     u->module = m;
-    u->device_id = pa_xstrdup(pa_modargs_get_value(ma, "device_id", DEFAULT_DEVICE_ID));
-    u->modargs = ma;
-
     u->use_ucm = true;
     u->ucm.core = m->core;
 
+    if (!(u->modargs = pa_modargs_new(m->argument, valid_modargs))) {
+        pa_log("Failed to parse module arguments.");
+        goto fail;
+    }
+
+    u->device_id = pa_xstrdup(pa_modargs_get_value(u->modargs, "device_id", DEFAULT_DEVICE_ID));
+
     if ((u->alsa_card_index = snd_card_get_index(u->device_id)) < 0) {
         pa_log("Card '%s' doesn't exist: %s", u->device_id, pa_alsa_strerror(u->alsa_card_index));
         goto fail;
     }
 
+    if (pa_modargs_get_value_boolean(u->modargs, "ignore_dB", &ignore_dB) < 0) {
+        pa_log("Failed to parse ignore_dB argument.");
+        goto fail;
+    }
+
     if (!pa_in_system_mode()) {
         char *rname;
 
@@ -652,7 +654,7 @@ int pa__init(pa_module *m) {
         }
     }
 
-    pa_modargs_get_value_boolean(ma, "use_ucm", &u->use_ucm);
+    pa_modargs_get_value_boolean(u->modargs, "use_ucm", &u->use_ucm);
     if (u->use_ucm && !pa_alsa_ucm_query_profiles(&u->ucm, u->alsa_card_index)) {
         pa_log_info("Found UCM profiles");
 
@@ -678,9 +680,9 @@ int pa__init(pa_module *m) {
         fn = pa_udev_get_property(u->alsa_card_index, "PULSE_PROFILE_SET");
 #endif
 
-        if (pa_modargs_get_value(ma, "profile_set", NULL)) {
+        if (pa_modargs_get_value(u->modargs, "profile_set", NULL)) {
             pa_xfree(fn);
-            fn = pa_xstrdup(pa_modargs_get_value(ma, "profile_set", NULL));
+            fn = pa_xstrdup(pa_modargs_get_value(u->modargs, "profile_set", NULL));
         }
 
         u->profile_set = pa_alsa_profile_set_new(fn, &u->core->default_channel_map);
@@ -702,15 +704,15 @@ int pa__init(pa_module *m) {
     pa_alsa_init_proplist_card(m->core, data.proplist, u->alsa_card_index);
 
     pa_proplist_sets(data.proplist, PA_PROP_DEVICE_STRING, u->device_id);
-    pa_alsa_init_description(data.proplist);
-    set_card_name(&data, ma, u->device_id);
+    pa_alsa_init_description(data.proplist, NULL);
+    set_card_name(&data, u->modargs, u->device_id);
 
     /* We need to give pa_modargs_get_value_boolean() a pointer to a local
      * variable instead of using &data.namereg_fail directly, because
      * data.namereg_fail is a bitfield and taking the address of a bitfield
      * variable is impossible. */
     namereg_fail = data.namereg_fail;
-    if (pa_modargs_get_value_boolean(ma, "namereg_fail", &namereg_fail) < 0) {
+    if (pa_modargs_get_value_boolean(u->modargs, "namereg_fail", &namereg_fail) < 0) {
         pa_log("Failed to parse namereg_fail argument.");
         pa_card_new_data_done(&data);
         goto fail;
@@ -731,13 +733,13 @@ int pa__init(pa_module *m) {
 
     add_disabled_profile(data.profiles);
 
-    if (pa_modargs_get_proplist(ma, "card_properties", data.proplist, PA_UPDATE_REPLACE) < 0) {
+    if (pa_modargs_get_proplist(u->modargs, "card_properties", data.proplist, PA_UPDATE_REPLACE) < 0) {
         pa_log("Invalid properties");
         pa_card_new_data_done(&data);
         goto fail;
     }
 
-    if ((profile = pa_modargs_get_value(ma, "profile", NULL)))
+    if ((profile = pa_modargs_get_value(u->modargs, "profile", NULL)))
         pa_card_new_data_set_profile(&data, profile);
 
     u->card = pa_card_new(m->core, &data);