mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-10-31 22:25:33 -04:00
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.
This commit is contained in:
parent
c2c8475f0d
commit
37429cb07e
11 changed files with 34 additions and 20 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue