mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-12-29 11:08:35 -05: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
bee86af3cc
commit
ce304d6208
12 changed files with 38 additions and 24 deletions
|
|
@ -195,7 +195,7 @@ static pa_hook_result_t profile_available_hook_callback(pa_core *c, pa_card_prof
|
|||
|
||||
pa_log_debug("Setting card '%s' to profile '%s'", card->name, selected_profile->name);
|
||||
|
||||
if (pa_card_set_profile(card, selected_profile->name, false) != 0)
|
||||
if (pa_card_set_profile(card, selected_profile, false) != 0)
|
||||
pa_log_warn("Could not set profile '%s'", selected_profile->name);
|
||||
|
||||
return PA_HOOK_OK;
|
||||
|
|
|
|||
|
|
@ -543,7 +543,7 @@ static int device_process_msg(pa_msgobject *obj, int code, void *data, int64_t o
|
|||
|
||||
pa_log_debug("Switching the profile to off due to IO thread failure.");
|
||||
|
||||
pa_assert_se(pa_card_set_profile(u->card, "off", false) >= 0);
|
||||
pa_assert_se(pa_card_set_profile(u->card, pa_hashmap_get(u->card->profiles, "off"), false) >= 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -1815,7 +1815,7 @@ static pa_hook_result_t transport_state_changed_cb(pa_bluez4_discovery *y, pa_bl
|
|||
pa_assert(u);
|
||||
|
||||
if (t == u->transport && t->state == PA_BLUEZ4_TRANSPORT_STATE_DISCONNECTED)
|
||||
pa_assert_se(pa_card_set_profile(u->card, "off", false) >= 0);
|
||||
pa_assert_se(pa_card_set_profile(u->card, pa_hashmap_get(u->card->profiles, "off"), false) >= 0);
|
||||
|
||||
if (t->device == u->device)
|
||||
handle_transport_state_change(u, t);
|
||||
|
|
@ -2060,7 +2060,7 @@ static int card_set_profile(pa_card *c, pa_card_profile *new_profile) {
|
|||
off:
|
||||
stop_thread(u);
|
||||
|
||||
pa_assert_se(pa_card_set_profile(u->card, "off", false) >= 0);
|
||||
pa_assert_se(pa_card_set_profile(u->card, pa_hashmap_get(u->card->profiles, "off"), false) >= 0);
|
||||
|
||||
return -PA_ERR_IO;
|
||||
}
|
||||
|
|
@ -2537,7 +2537,7 @@ int pa__init(pa_module *m) {
|
|||
off:
|
||||
stop_thread(u);
|
||||
|
||||
pa_assert_se(pa_card_set_profile(u->card, "off", false) >= 0);
|
||||
pa_assert_se(pa_card_set_profile(u->card, pa_hashmap_get(u->card->profiles, "off"), false) >= 0);
|
||||
|
||||
return 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -1588,7 +1588,7 @@ static int set_profile_cb(pa_card *c, pa_card_profile *new_profile) {
|
|||
off:
|
||||
stop_thread(u);
|
||||
|
||||
pa_assert_se(pa_card_set_profile(u->card, "off", false) >= 0);
|
||||
pa_assert_se(pa_card_set_profile(u->card, pa_hashmap_get(u->card->profiles, "off"), false) >= 0);
|
||||
|
||||
return -PA_ERR_IO;
|
||||
}
|
||||
|
|
@ -1757,7 +1757,7 @@ static pa_hook_result_t transport_state_changed_cb(pa_bluetooth_discovery *y, pa
|
|||
pa_assert(u);
|
||||
|
||||
if (t == u->transport && t->state <= PA_BLUETOOTH_TRANSPORT_STATE_DISCONNECTED)
|
||||
pa_assert_se(pa_card_set_profile(u->card, "off", false) >= 0);
|
||||
pa_assert_se(pa_card_set_profile(u->card, pa_hashmap_get(u->card->profiles, "off"), false) >= 0);
|
||||
|
||||
if (t->device == u->device)
|
||||
handle_transport_state_change(u, t);
|
||||
|
|
@ -1775,7 +1775,7 @@ static int device_process_msg(pa_msgobject *obj, int code, void *data, int64_t o
|
|||
break;
|
||||
|
||||
pa_log_debug("Switching the profile to off due to IO thread failure.");
|
||||
pa_assert_se(pa_card_set_profile(u->card, "off", false) >= 0);
|
||||
pa_assert_se(pa_card_set_profile(u->card, pa_hashmap_get(u->card->profiles, "off"), false) >= 0);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -1847,7 +1847,7 @@ int pa__init(pa_module* m) {
|
|||
off:
|
||||
stop_thread(u);
|
||||
|
||||
pa_assert_se(pa_card_set_profile(u->card, "off", false) >= 0);
|
||||
pa_assert_se(pa_card_set_profile(u->card, pa_hashmap_get(u->card->profiles, "off"), false) >= 0);
|
||||
|
||||
return 0;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue