[pulseaudio-discuss] [[PATCH v0] 2/5] alsa-card/bluetooth-device: Set the card name while creating ports.
poljar (Damir Jelić)
poljarinho at gmail.com
Wed Apr 17 17:24:05 PDT 2013
While creating ports also set the card name.
---
src/modules/alsa/alsa-mixer.c | 13 ++++++++-----
src/modules/alsa/alsa-mixer.h | 2 +-
src/modules/alsa/alsa-ucm.c | 14 +++++++++-----
src/modules/alsa/alsa-ucm.h | 1 +
src/modules/alsa/module-alsa-card.c | 12 ++++++------
src/modules/bluetooth/module-bluetooth-device.c | 6 ++++--
6 files changed, 29 insertions(+), 19 deletions(-)
diff --git a/src/modules/alsa/alsa-mixer.c b/src/modules/alsa/alsa-mixer.c
index be9ee4e..046ace0 100644
--- a/src/modules/alsa/alsa-mixer.c
+++ b/src/modules/alsa/alsa-mixer.c
@@ -4480,8 +4480,9 @@ void pa_alsa_profile_set_drop_unsupported(pa_alsa_profile_set *ps) {
}
static pa_device_port* device_port_alsa_init(pa_hashmap *ports, /* card ports */
- const char* name,
- const char* description,
+ const char *name,
+ const char *description,
+ const char *card_name,
pa_alsa_path *path,
pa_alsa_setting *setting,
pa_card_profile *cp,
@@ -4500,6 +4501,7 @@ static pa_device_port* device_port_alsa_init(pa_hashmap *ports, /* card ports */
pa_device_port_new_data_init(&port_data);
pa_device_port_new_data_set_name(&port_data, name);
+ pa_device_port_new_data_set_card_name(&port_data, card_name);
pa_device_port_new_data_set_description(&port_data, description);
pa_device_port_new_data_set_direction(&port_data, path->direction == PA_ALSA_DIRECTION_OUTPUT ? PA_DIRECTION_OUTPUT : PA_DIRECTION_INPUT);
@@ -4528,6 +4530,7 @@ static pa_device_port* device_port_alsa_init(pa_hashmap *ports, /* card ports */
void pa_alsa_path_set_add_ports(
pa_alsa_path_set *ps,
+ const char *card_name,
pa_card_profile *cp,
pa_hashmap *ports, /* card ports */
pa_hashmap *extra, /* sink/source ports */
@@ -4546,7 +4549,7 @@ void pa_alsa_path_set_add_ports(
/* If there is no or just one setting we only need a
* single entry */
pa_device_port *port = device_port_alsa_init(ports, path->name,
- path->description, path, path->settings, cp, extra, core);
+ path->description, card_name, path, path->settings, cp, extra, core);
port->priority = path->priority * 100;
} else {
@@ -4562,7 +4565,7 @@ void pa_alsa_path_set_add_ports(
else
d = pa_xstrdup(path->description);
- port = device_port_alsa_init(ports, n, d, path, s, cp, extra, core);
+ port = device_port_alsa_init(ports, n, d, card_name, path, s, cp, extra, core);
port->priority = path->priority * 100 + s->priority;
pa_xfree(n);
@@ -4585,7 +4588,7 @@ void pa_alsa_add_ports(void *sink_or_source_new_data, pa_alsa_path_set *ps, pa_c
if (ps->paths && pa_hashmap_size(ps->paths) > 0) {
pa_assert(card);
- pa_alsa_path_set_add_ports(ps, NULL, card->ports, ports, card->core);
+ pa_alsa_path_set_add_ports(ps, card->name, NULL, card->ports, ports, card->core);
}
pa_log_debug("Added %u ports", pa_hashmap_size(ports));
diff --git a/src/modules/alsa/alsa-mixer.h b/src/modules/alsa/alsa-mixer.h
index 3d50ebb..442ac6b 100644
--- a/src/modules/alsa/alsa-mixer.h
+++ b/src/modules/alsa/alsa-mixer.h
@@ -351,6 +351,6 @@ struct pa_alsa_port_data {
};
void pa_alsa_add_ports(void *sink_or_source_new_data, pa_alsa_path_set *ps, pa_card *card);
-void pa_alsa_path_set_add_ports(pa_alsa_path_set *ps, pa_card_profile *cp, pa_hashmap *ports, pa_hashmap *extra, pa_core *core);
+void pa_alsa_path_set_add_ports(pa_alsa_path_set *ps, const char *card_name, pa_card_profile *cp, pa_hashmap *ports, pa_hashmap *extra, pa_core *core);
#endif
diff --git a/src/modules/alsa/alsa-ucm.c b/src/modules/alsa/alsa-ucm.c
index 3b55e82..6904eb5 100644
--- a/src/modules/alsa/alsa-ucm.c
+++ b/src/modules/alsa/alsa-ucm.c
@@ -648,6 +648,7 @@ static void ucm_add_port_combination(
pa_alsa_ucm_device **pdevices,
int num,
pa_hashmap *ports,
+ const char *card_name,
pa_card_profile *cp,
pa_core *core) {
@@ -693,6 +694,7 @@ static void ucm_add_port_combination(
pa_device_port_new_data_init(&port_data);
pa_device_port_new_data_set_name(&port_data, name);
pa_device_port_new_data_set_description(&port_data, desc);
+ pa_device_port_new_data_set_card_name(&port_data, card_name);
pa_device_port_new_data_set_direction(&port_data, is_sink ? PA_DIRECTION_OUTPUT : PA_DIRECTION_INPUT);
port = pa_device_port_new(core, &port_data, 0);
@@ -807,6 +809,7 @@ static void ucm_add_ports_combination(
int dev_num,
uint32_t map_index,
pa_hashmap *ports,
+ const char *card_name,
pa_card_profile *cp,
pa_core *core) {
@@ -821,13 +824,13 @@ static void ucm_add_ports_combination(
/* add device at map_index to devices combination */
pdevices[dev_num] = dev;
/* add current devices combination as a new port */
- ucm_add_port_combination(hash, context, is_sink, pdevices, dev_num + 1, ports, cp, core);
+ ucm_add_port_combination(hash, context, is_sink, pdevices, dev_num + 1, ports, card_name, cp, core);
/* try more elements combination */
- ucm_add_ports_combination(hash, context, is_sink, pdevices, dev_num + 1, idx, ports, cp, core);
+ ucm_add_ports_combination(hash, context, is_sink, pdevices, dev_num + 1, idx, ports, card_name, cp, core);
}
/* try other device with current elements number */
- ucm_add_ports_combination(hash, context, is_sink, pdevices, dev_num, idx, ports, cp, core);
+ ucm_add_ports_combination(hash, context, is_sink, pdevices, dev_num, idx, ports, card_name, cp, core);
}
static char* merge_roles(const char *cur, const char *add) {
@@ -864,6 +867,7 @@ void pa_alsa_ucm_add_ports_combination(
pa_alsa_ucm_mapping_context *context,
bool is_sink,
pa_hashmap *ports,
+ const char *card_name,
pa_card_profile *cp,
pa_core *core) {
@@ -873,7 +877,7 @@ void pa_alsa_ucm_add_ports_combination(
if (pa_idxset_size(context->ucm_devices) > 0) {
pdevices = pa_xnew(pa_alsa_ucm_device *, pa_idxset_size(context->ucm_devices));
- ucm_add_ports_combination(p, context, is_sink, pdevices, 0, PA_IDXSET_INVALID, ports, cp, core);
+ ucm_add_ports_combination(p, context, is_sink, pdevices, 0, PA_IDXSET_INVALID, ports, card_name, cp, core);
pa_xfree(pdevices);
}
}
@@ -896,7 +900,7 @@ void pa_alsa_ucm_add_ports(
pa_assert(*p);
/* add ports first */
- pa_alsa_ucm_add_ports_combination(*p, context, is_sink, card->ports, NULL, card->core);
+ pa_alsa_ucm_add_ports_combination(*p, context, is_sink, card->ports, card->name, NULL, card->core);
/* then set property PA_PROP_DEVICE_INTENDED_ROLES */
merged_roles = pa_xstrdup(pa_proplist_gets(proplist, PA_PROP_DEVICE_INTENDED_ROLES));
diff --git a/src/modules/alsa/alsa-ucm.h b/src/modules/alsa/alsa-ucm.h
index cdeb469..556130b 100644
--- a/src/modules/alsa/alsa-ucm.h
+++ b/src/modules/alsa/alsa-ucm.h
@@ -99,6 +99,7 @@ void pa_alsa_ucm_add_ports_combination(
pa_alsa_ucm_mapping_context *context,
bool is_sink,
pa_hashmap *ports,
+ const char *card_name,
pa_card_profile *cp,
pa_core *core);
int pa_alsa_ucm_set_port(pa_alsa_ucm_mapping_context *context, pa_device_port *port, bool is_sink);
diff --git a/src/modules/alsa/module-alsa-card.c b/src/modules/alsa/module-alsa-card.c
index 2529c0d..96156e4 100644
--- a/src/modules/alsa/module-alsa-card.c
+++ b/src/modules/alsa/module-alsa-card.c
@@ -137,7 +137,7 @@ struct profile_data {
pa_alsa_profile *profile;
};
-static void add_profiles(struct userdata *u, pa_hashmap *h, pa_hashmap *ports) {
+static void add_profiles(struct userdata *u, const char *card_name, pa_hashmap *h, pa_hashmap *ports) {
pa_alsa_profile *ap;
void *state;
@@ -158,9 +158,9 @@ static void add_profiles(struct userdata *u, pa_hashmap *h, pa_hashmap *ports) {
PA_IDXSET_FOREACH(m, ap->output_mappings, idx) {
if (u->use_ucm)
- pa_alsa_ucm_add_ports_combination(NULL, &m->ucm_context, TRUE, ports, cp, u->core);
+ pa_alsa_ucm_add_ports_combination(NULL, &m->ucm_context, TRUE, ports, card_name, cp, u->core);
else
- pa_alsa_path_set_add_ports(m->output_path_set, cp, ports, NULL, u->core);
+ pa_alsa_path_set_add_ports(m->output_path_set, card_name, cp, ports, NULL, u->core);
if (m->channel_map.channels > cp->max_sink_channels)
cp->max_sink_channels = m->channel_map.channels;
}
@@ -171,9 +171,9 @@ static void add_profiles(struct userdata *u, pa_hashmap *h, pa_hashmap *ports) {
PA_IDXSET_FOREACH(m, ap->input_mappings, idx) {
if (u->use_ucm)
- pa_alsa_ucm_add_ports_combination(NULL, &m->ucm_context, FALSE, ports, cp, u->core);
+ pa_alsa_ucm_add_ports_combination(NULL, &m->ucm_context, FALSE, ports, card_name, cp, u->core);
else
- pa_alsa_path_set_add_ports(m->input_path_set, cp, ports, NULL, u->core);
+ pa_alsa_path_set_add_ports(m->input_path_set, card_name, cp, ports, NULL, u->core);
if (m->channel_map.channels > cp->max_source_channels)
cp->max_source_channels = m->channel_map.channels;
}
@@ -720,7 +720,7 @@ int pa__init(pa_module *m) {
if ((description = pa_proplist_gets(data.proplist, PA_PROP_DEVICE_DESCRIPTION)))
pa_reserve_wrapper_set_application_device_name(reserve, description);
- add_profiles(u, data.profiles, data.ports);
+ add_profiles(u, data.name, data.profiles, data.ports);
if (pa_hashmap_isempty(data.profiles)) {
pa_log("Failed to find a working profile.");
diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c
index cd0a515..78c05ef 100644
--- a/src/modules/bluetooth/module-bluetooth-device.c
+++ b/src/modules/bluetooth/module-bluetooth-device.c
@@ -2068,7 +2068,7 @@ off:
}
/* Run from main thread */
-static void create_card_ports(struct userdata *u, pa_hashmap *ports) {
+static void create_card_ports(struct userdata *u, const char *card_name, pa_hashmap *ports) {
pa_device_port *port;
pa_device_port_new_data port_data;
@@ -2145,6 +2145,7 @@ static void create_card_ports(struct userdata *u, pa_hashmap *ports) {
pa_device_port_new_data_init(&port_data);
pa_device_port_new_data_set_name(&port_data, u->output_port_name);
pa_device_port_new_data_set_description(&port_data, output_description);
+ pa_device_port_new_data_set_card_name(&port_data, card_name);
pa_device_port_new_data_set_direction(&port_data, PA_DIRECTION_OUTPUT);
pa_device_port_new_data_set_available(&port_data, get_port_availability(u, PA_DIRECTION_OUTPUT));
pa_assert_se(port = pa_device_port_new(u->core, &port_data, 0));
@@ -2154,6 +2155,7 @@ static void create_card_ports(struct userdata *u, pa_hashmap *ports) {
pa_device_port_new_data_init(&port_data);
pa_device_port_new_data_set_name(&port_data, u->input_port_name);
pa_device_port_new_data_set_description(&port_data, output_description);
+ pa_device_port_new_data_set_card_name(&port_data, card_name);
pa_device_port_new_data_set_direction(&port_data, PA_DIRECTION_INPUT);
pa_device_port_new_data_set_available(&port_data, get_port_availability(u, PA_DIRECTION_INPUT));
pa_assert_se(port = pa_device_port_new(u->core, &port_data, 0));
@@ -2276,7 +2278,7 @@ static int add_card(struct userdata *u) {
pa_assert(!pa_hashmap_isempty(data.profiles));
- create_card_ports(u, data.ports);
+ create_card_ports(u, data.name, data.ports);
p = pa_card_profile_new("off", _("Off"), sizeof(enum profile));
p->available = PA_AVAILABLE_YES;
--
1.8.2.1
More information about the pulseaudio-discuss
mailing list