From 08154554b0cdce6d16816536211718bf14ff33ff Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 23 Mar 2009 19:31:36 +0100 Subject: only store card profile if flagged for that --- src/modules/module-card-restore.c | 3 +++ src/pulsecore/card.c | 10 +++++++--- src/pulsecore/card.h | 6 +++++- src/pulsecore/cli-command.c | 2 +- src/pulsecore/protocol-native.c | 2 +- 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/modules/module-card-restore.c b/src/modules/module-card-restore.c index 0afb9353..17f1f8c3 100644 --- a/src/modules/module-card-restore.c +++ b/src/modules/module-card-restore.c @@ -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))) { diff --git a/src/pulsecore/card.c b/src/pulsecore/card.c index 6419c234..f268f7c9 100644 --- a/src/pulsecore/card.c +++ b/src/pulsecore/card.c @@ -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; } diff --git a/src/pulsecore/card.h b/src/pulsecore/card.h index c80d4e2e..3b7608f6 100644 --- a/src/pulsecore/card.h +++ b/src/pulsecore/card.h @@ -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); diff --git a/src/pulsecore/cli-command.c b/src/pulsecore/cli-command.c index b5f7e7f5..d4d407c6 100644 --- a/src/pulsecore/cli-command.c +++ b/src/pulsecore/cli-command.c @@ -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; } diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c index 4860860b..ff49e696 100644 --- a/src/pulsecore/protocol-native.c +++ b/src/pulsecore/protocol-native.c @@ -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; } -- cgit