device-port: Add a card pointer to the ports.

This way we can directly access the card that owns the port instead of
iterating over all cards.
This commit is contained in:
poljar (Damir Jelić) 2013-01-17 20:55:14 +01:00 committed by Tanu Kaskinen
parent ed6f30c79a
commit 9d6eb21c7e
3 changed files with 12 additions and 1 deletions

View file

@ -102,8 +102,10 @@ void pa_card_add_ports(pa_card *c, pa_hashmap *ports) {
pa_assert(ports);
/* take ownership of the ports */
PA_HASHMAP_FOREACH(p, ports, state)
PA_HASHMAP_FOREACH(p, ports, state) {
p->card = c;
pa_assert_se(pa_hashmap_put(c->ports, p->name, p) >= 0);
}
pa_subscription_post(c->core, PA_SUBSCRIPTION_EVENT_CARD|PA_SUBSCRIPTION_EVENT_CHANGE, c->index);
@ -145,6 +147,7 @@ pa_card *pa_card_new(pa_core *core, pa_card_new_data *data) {
const char *name;
void *state;
pa_card_profile *profile;
pa_device_port *port;
pa_core_assert_ref(core);
pa_assert(data);
@ -188,6 +191,11 @@ pa_card *pa_card_new(pa_core *core, pa_card_new_data *data) {
profile->card = c;
}
if (c->ports) {
PA_HASHMAP_FOREACH(port, c->ports, state)
port->card = c;
}
c->active_profile = NULL;
c->save_profile = FALSE;