alsa: Add a proplist to mappings

The proplist isn't used by the conventional alsa-mixer code path, but
can be used by UCM to transfer properties from UCM data to the
sinks/sources corresponding to a mapping. These properties could be used
later in policy, etc.

The specific use for which I'm writing this now is for UCM modifiers
that have their own PlaybackPCM/CapturePCM field. These will be
translated to a separate sink/source corresponding to the modifier by
adding an additional mapping per sink/source. These mappings' proplist
will be populated with the name of the modifier and corresponding
"device.intended_role" property. The latter will be used in the usual
routing-by-role way, and the former will be used during sink/source
activation and deactivation to know what UCM modifier is to be enabled
or disabled.
This commit is contained in:
Arun Raghavan 2012-07-03 11:50:29 +05:30
parent 89024f6f12
commit a08c85d299
4 changed files with 15 additions and 2 deletions

View file

@ -3258,6 +3258,8 @@ static void mapping_free(pa_alsa_mapping *m) {
pa_xfree(m->name);
pa_xfree(m->description);
pa_proplist_free(m->proplist);
pa_xstrfreev(m->device_strings);
pa_xstrfreev(m->input_path_names);
pa_xstrfreev(m->output_path_names);
@ -3360,6 +3362,7 @@ pa_alsa_mapping *pa_alsa_mapping_get(pa_alsa_profile_set *ps, const char *name)
m->profile_set = ps;
m->name = pa_xstrdup(name);
pa_channel_map_init(&m->channel_map);
m->proplist = pa_proplist_new();
pa_hashmap_put(ps->mappings, m->name, m);

View file

@ -246,6 +246,8 @@ struct pa_alsa_mapping {
char *description;
unsigned priority;
pa_alsa_direction_t direction;
/* These are copied over to the resultant sink/source */
pa_proplist *proplist;
pa_channel_map channel_map;

View file

@ -1977,7 +1977,7 @@ static int setup_mixer(struct userdata *u, pa_bool_t ignore_dB) {
pa_sink *pa_alsa_sink_new(pa_module *m, pa_modargs *ma, const char*driver, pa_card *card, pa_alsa_mapping *mapping) {
struct userdata *u = NULL;
const char *dev_id = NULL;
const char *dev_id = NULL, *key;
pa_sample_spec ss;
uint32_t alternate_sample_rate;
pa_channel_map map;
@ -1987,6 +1987,7 @@ pa_sink *pa_alsa_sink_new(pa_module *m, pa_modargs *ma, const char*driver, pa_ca
pa_bool_t use_mmap = TRUE, b, use_tsched = TRUE, d, ignore_dB = FALSE, namereg_fail = FALSE, deferred_volume = FALSE, set_formats = FALSE, fixed_latency_range = FALSE;
pa_sink_new_data data;
pa_alsa_profile_set *profile_set = NULL;
void *state = NULL;
pa_assert(m);
pa_assert(ma);
@ -2221,6 +2222,9 @@ pa_sink *pa_alsa_sink_new(pa_module *m, pa_modargs *ma, const char*driver, pa_ca
if (mapping) {
pa_proplist_sets(data.proplist, PA_PROP_DEVICE_PROFILE_NAME, mapping->name);
pa_proplist_sets(data.proplist, PA_PROP_DEVICE_PROFILE_DESCRIPTION, mapping->description);
while ((key = pa_proplist_iterate(mapping->proplist, &state)))
pa_proplist_sets(data.proplist, key, pa_proplist_gets(mapping->proplist, key));
}
pa_alsa_init_description(data.proplist);

View file

@ -1714,7 +1714,7 @@ static int setup_mixer(struct userdata *u, pa_bool_t ignore_dB) {
pa_source *pa_alsa_source_new(pa_module *m, pa_modargs *ma, const char*driver, pa_card *card, pa_alsa_mapping *mapping) {
struct userdata *u = NULL;
const char *dev_id = NULL;
const char *dev_id = NULL, *key;
pa_sample_spec ss;
uint32_t alternate_sample_rate;
pa_channel_map map;
@ -1724,6 +1724,7 @@ pa_source *pa_alsa_source_new(pa_module *m, pa_modargs *ma, const char*driver, p
pa_bool_t use_mmap = TRUE, b, use_tsched = TRUE, d, ignore_dB = FALSE, namereg_fail = FALSE, deferred_volume = FALSE, fixed_latency_range = FALSE;
pa_source_new_data data;
pa_alsa_profile_set *profile_set = NULL;
void *state = NULL;
pa_assert(m);
pa_assert(ma);
@ -1947,6 +1948,9 @@ pa_source *pa_alsa_source_new(pa_module *m, pa_modargs *ma, const char*driver, p
if (mapping) {
pa_proplist_sets(data.proplist, PA_PROP_DEVICE_PROFILE_NAME, mapping->name);
pa_proplist_sets(data.proplist, PA_PROP_DEVICE_PROFILE_DESCRIPTION, mapping->description);
while ((key = pa_proplist_iterate(mapping->proplist, &state)))
pa_proplist_sets(data.proplist, key, pa_proplist_gets(mapping->proplist, key));
}
pa_alsa_init_description(data.proplist);