]> code.delx.au - pulseaudio/commitdiff
only store card profile if flagged for that
authorLennart Poettering <lennart@poettering.net>
Mon, 23 Mar 2009 18:31:36 +0000 (19:31 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 23 Mar 2009 18:31:36 +0000 (19:31 +0100)
src/modules/module-card-restore.c
src/pulsecore/card.c
src/pulsecore/card.h
src/pulsecore/cli-command.c
src/pulsecore/protocol-native.c

index 0afb9353ba2b7d2e271ae8f928b13d679340747f..17f1f8c395a06497882d15e0341e887a959acca5 100644 (file)
@@ -161,6 +161,9 @@ static void subscribe_callback(pa_core *c, pa_subscription_event_type_t t, uint3
     if (!(card = pa_idxset_get_by_index(c->cards, idx)))
         return;
 
+    if (!card->save_profile)
+        return;
+
     pa_strlcpy(entry.profile, card->active_profile ? card->active_profile->name : "", sizeof(entry.profile));
 
     if ((old = read_entry(u, card->name))) {
index 6419c2347ef6294608e91a046262b751ccfbfbb6..f268f7c9598e16927ee7327ca62108d347cbbfe9 100644 (file)
@@ -143,7 +143,8 @@ pa_card *pa_card_new(pa_core *core, pa_card_new_data *data) {
     c->active_profile = NULL;
 
     if (data->active_profile && c->profiles)
-        c->active_profile = pa_hashmap_get(c->profiles, data->active_profile);
+        if ((c->active_profile = pa_hashmap_get(c->profiles, data->active_profile)))
+            c->save_profile = data->save_profile;
 
     if (!c->active_profile && c->profiles) {
         void *state = NULL;
@@ -209,7 +210,7 @@ void pa_card_free(pa_card *c) {
     pa_xfree(c);
 }
 
-int pa_card_set_profile(pa_card *c, const char *name) {
+int pa_card_set_profile(pa_card *c, const char *name, pa_bool_t save) {
     pa_card_profile *profile;
     pa_assert(c);
 
@@ -224,8 +225,10 @@ int pa_card_set_profile(pa_card *c, const char *name) {
     if (!(profile = pa_hashmap_get(c->profiles, name)))
         return -1;
 
-    if (c->active_profile == profile)
+    if (c->active_profile == profile) {
+        c->save_profile = c->save_profile || save;
         return 0;
+    }
 
     if (c->set_profile(c, profile) < 0)
         return -1;
@@ -235,6 +238,7 @@ int pa_card_set_profile(pa_card *c, const char *name) {
     pa_log_info("Changed profile of card %u \"%s\" to %s", c->index, c->name, profile->name);
 
     c->active_profile = profile;
+    c->save_profile = save;
 
     return 0;
 }
index c80d4e2ed13abc0a169abf82cd9b0f473495959d..3b7608f61776ee82c8f145d3c1cedf9fe805d112 100644 (file)
@@ -63,6 +63,8 @@ struct pa_card {
     pa_hashmap *profiles;
     pa_card_profile *active_profile;
 
+    pa_bool_t save_profile;
+
     void *userdata;
 
     int (*set_profile)(pa_card *c, pa_card_profile *profile);
@@ -80,6 +82,8 @@ typedef struct pa_card_new_data {
     char *active_profile;
 
     pa_bool_t namereg_fail:1;
+
+    pa_bool_t save_profile:1;
 } pa_card_new_data;
 
 pa_card_profile *pa_card_profile_new(const char *name, const char *description, size_t extra);
@@ -93,7 +97,7 @@ void pa_card_new_data_done(pa_card_new_data *data);
 pa_card *pa_card_new(pa_core *c, pa_card_new_data *data);
 void pa_card_free(pa_card *c);
 
-int pa_card_set_profile(pa_card *c, const char *name);
+int pa_card_set_profile(pa_card *c, const char *name, pa_bool_t save);
 
 int pa_card_suspend(pa_card *c, pa_bool_t suspend);
 
index b5f7e7f51d7e6ba198e8eb5c939ff7223e26a5f9..d4d407c612017f1bd3dc633ae90ed0be7b8d6b1e 100644 (file)
@@ -1454,7 +1454,7 @@ static int pa_cli_command_card_profile(pa_core *c, pa_tokenizer *t, pa_strbuf *b
         return -1;
     }
 
-    if (pa_card_set_profile(card, p) < 0) {
+    if (pa_card_set_profile(card, p, TRUE) < 0) {
         pa_strbuf_printf(buf, "Failed to set card profile to '%s'.\n", p);
         return -1;
     }
index 4860860b3089686cd1e29dd49547656c14790812..ff49e696a9ee5b2430221b38144ef173c19a4857 100644 (file)
@@ -4119,7 +4119,7 @@ static void command_set_card_profile(pa_pdispatch *pd, uint32_t command, uint32_
 
     CHECK_VALIDITY(c->pstream, card, tag, PA_ERR_NOENTITY);
 
-    if (pa_card_set_profile(card, profile) < 0) {
+    if (pa_card_set_profile(card, profile, TRUE) < 0) {
         pa_pstream_send_error(c->pstream, tag, PA_ERR_INVALID);
         return;
     }