mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-10-31 22:25:33 -04:00
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:
parent
ed6f30c79a
commit
9d6eb21c7e
3 changed files with 12 additions and 1 deletions
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -92,6 +92,7 @@ pa_device_port *pa_device_port_new(pa_core *c, const char *name, const char *des
|
|||
p->name = pa_xstrdup(name);
|
||||
p->description = pa_xstrdup(description);
|
||||
p->core = c;
|
||||
p->card = NULL;
|
||||
p->priority = 0;
|
||||
p->available = PA_PORT_AVAILABLE_UNKNOWN;
|
||||
p->profiles = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
|
||||
|
|
|
|||
|
|
@ -36,10 +36,12 @@ typedef struct pa_device_port pa_device_port;
|
|||
#include <pulsecore/object.h>
|
||||
#include <pulsecore/hashmap.h>
|
||||
#include <pulsecore/core.h>
|
||||
#include <pulsecore/card.h>
|
||||
|
||||
struct pa_device_port {
|
||||
pa_object parent; /* Needed for reference counting */
|
||||
pa_core *core;
|
||||
pa_card *card;
|
||||
|
||||
char *name;
|
||||
char *description;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue