card: Ensure that there's always at least one profile.

In practice there is always at least one profile, and I
don't think there will ever be cards without profiles.
Therefore, I added assertions to pa_card_new() stating that
the card new data must always contain at least one profile.
Now a lot of code can be simplified, because it's guaranteed
that the profiles hashmap and the active_profile field are
always non-NULL.
This commit is contained in:
Tanu Kaskinen 2012-06-08 21:49:10 +03:00
parent 1a6da64b16
commit 12af302ac7
9 changed files with 35 additions and 70 deletions

View file

@ -60,10 +60,6 @@ static pa_bool_t try_to_switch_profile(pa_card *card, pa_device_port *port) {
if (best_profile && best_profile->priority >= profile->priority)
continue;
if (!card->active_profile) {
best_profile = profile;
continue;
}
/* We make a best effort to keep other direction unchanged */
if (!port->is_input) {
@ -156,7 +152,7 @@ static pa_hook_result_t port_available_hook_callback(pa_core *c, pa_device_port
find_sink_and_source(card, port, &sink, &source);
is_active_profile = port->profiles && card->active_profile &&
is_active_profile = port->profiles &&
card->active_profile == pa_hashmap_get(port->profiles, card->active_profile->name);
is_active_port = (sink && sink->active_port == port) || (source && source->active_port == port);