diff options
author | Tanu Kaskinen <tanu.kaskinen@linux.intel.com> | 2013-11-20 15:42:26 +0200 |
---|---|---|
committer | Tanu Kaskinen <tanu.kaskinen@linux.intel.com> | 2013-11-29 07:25:13 +0200 |
commit | ce304d62087b51ce592e9489381ba49750392f60 (patch) | |
tree | d063463f7c111dfc285ed3235810b2c81bd100c1 /src/pulsecore/cli-command.c | |
parent | bee86af3ccc247834bf38a57296958f9cd35ffc4 (diff) | |
download | pulseaudio-ce304d62087b51ce592e9489381ba49750392f60.tar.gz |
Pass the profile object instead of the profile name to pa_card_set_profile()
When setting attribute foo, or in this case the card profile, in my
opinion the thing passed to the set_foo() function should be of the
type of foo, not a string identifier that can be used to search for
the actual foo in set_foo().
This is mostly a question of taste, but there's at least some small
benefit from passing the actual object: often the profile object is
already available when calling pa_card_set_profile(), so passing the
card name would cause unnecessary searching when pa_card_set_profile()
needs to look up the profile from the hashmap.
Diffstat (limited to 'src/pulsecore/cli-command.c')
-rw-r--r-- | src/pulsecore/cli-command.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/pulsecore/cli-command.c b/src/pulsecore/cli-command.c index d2cc38af2..8c956ac29 100644 --- a/src/pulsecore/cli-command.c +++ b/src/pulsecore/cli-command.c @@ -1634,6 +1634,7 @@ static int pa_cli_command_log_backtrace(pa_core *c, pa_tokenizer *t, pa_strbuf * static int pa_cli_command_card_profile(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) { const char *n, *p; pa_card *card; + pa_card_profile *profile; pa_core_assert_ref(c); pa_assert(t); @@ -1655,7 +1656,12 @@ 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, true) < 0) { + if (!(profile = pa_hashmap_get(card->profiles, p))) { + pa_strbuf_printf(buf, "No such profile: %s\n", p); + return -1; + } + + if (pa_card_set_profile(card, profile, true) < 0) { pa_strbuf_printf(buf, "Failed to set card profile to '%s'.\n", p); return -1; } |