mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2026-04-06 07:15:41 -04:00
Merge branch 'multi-profile_mic' into 'master'
alsa-ucm: allow binding same mic to multiple profiles See merge request pulseaudio/pulseaudio!271
This commit is contained in:
commit
0517c8ea41
1 changed files with 86 additions and 23 deletions
|
|
@ -90,6 +90,8 @@ static pa_alsa_ucm_device *verb_find_device(pa_alsa_ucm_verb *verb, const char *
|
|||
|
||||
static void ucm_port_data_init(pa_alsa_ucm_port_data *port, pa_alsa_ucm_config *ucm, pa_device_port *core_port,
|
||||
pa_alsa_ucm_device **devices, unsigned n_devices);
|
||||
static void ucm_port_add_devices(pa_device_port *port, pa_alsa_ucm_device **pdevices, int num);
|
||||
static void device_add_ucm_port(pa_alsa_ucm_device *device, pa_alsa_ucm_port_data *port);
|
||||
static void ucm_port_data_free(pa_device_port *port);
|
||||
static void ucm_port_update_available(pa_alsa_ucm_port_data *port);
|
||||
|
||||
|
|
@ -982,6 +984,61 @@ fail:
|
|||
}
|
||||
}
|
||||
|
||||
static int devs_have_same_property(pa_alsa_ucm_device *dev1,
|
||||
pa_alsa_ucm_device *dev2,
|
||||
const char *prop)
|
||||
{
|
||||
const char *val1, *val2;
|
||||
|
||||
/* check whether the 2 devices have the exactly same property */
|
||||
val1 = pa_proplist_gets(dev1->proplist, prop);
|
||||
val2 = pa_proplist_gets(dev2->proplist, prop);
|
||||
if (val1 && val2)
|
||||
return pa_streq(val1, val2);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void ucm_port_add_devices(pa_device_port *port,
|
||||
pa_alsa_ucm_device **pdevices,
|
||||
int num)
|
||||
{
|
||||
pa_alsa_ucm_device *device;
|
||||
pa_alsa_ucm_port_data *portdata;
|
||||
unsigned idx;
|
||||
int found, i;
|
||||
|
||||
pa_assert(port);
|
||||
|
||||
portdata = PA_DEVICE_PORT_DATA(port);
|
||||
for (i = 0; i < num; i++) {
|
||||
found = 0;
|
||||
PA_DYNARRAY_FOREACH(device, portdata->devices, idx) {
|
||||
if (pdevices[i] == device) {
|
||||
found = 1;
|
||||
break;
|
||||
} else {
|
||||
if (!devs_have_same_property(pdevices[i], device, PA_ALSA_PROP_UCM_PLAYBACK_CHANNELS))
|
||||
pa_log_warn("port %s has different playback channel devices\n", port->name);
|
||||
if (!devs_have_same_property(pdevices[i], device, PA_ALSA_PROP_UCM_PLAYBACK_RATE))
|
||||
pa_log_warn("port %s has different playback rate devices\n", port->name);
|
||||
if (!devs_have_same_property(pdevices[i], device, PA_ALSA_PROP_UCM_PLAYBACK_PRIORITY))
|
||||
pa_log_warn("port %s has different playback priority devices\n", port->name);
|
||||
if (!devs_have_same_property(pdevices[i], device, PA_ALSA_PROP_UCM_CAPTURE_CHANNELS))
|
||||
pa_log_warn("port %s has different capture channel devices\n", port->name);
|
||||
if (!devs_have_same_property(pdevices[i], device, PA_ALSA_PROP_UCM_CAPTURE_RATE))
|
||||
pa_log_warn("port %s has different capture rate devices\n", port->name);
|
||||
if (!devs_have_same_property(pdevices[i], device, PA_ALSA_PROP_UCM_CAPTURE_PRIORITY))
|
||||
pa_log_warn("port %s has different capture priority devices\n", port->name);
|
||||
}
|
||||
}
|
||||
if (found == 0) {
|
||||
pa_dynarray_append(portdata->devices, pdevices[i]);
|
||||
device_add_ucm_port(pdevices[i], portdata);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void ucm_add_port_combination(
|
||||
pa_hashmap *hash,
|
||||
pa_alsa_ucm_mapping_context *context,
|
||||
|
|
@ -1088,10 +1145,17 @@ static void ucm_add_port_combination(
|
|||
|
||||
pa_hashmap_put(ports, port->name, port);
|
||||
pa_log_debug("Add port %s: %s", port->name, port->description);
|
||||
}
|
||||
|
||||
if (num == 1) {
|
||||
/* To keep things simple and not worry about stacking controls, we only support hardware volumes on non-combination
|
||||
* ports. */
|
||||
/* If the pdevices are not added to the portdata, let's add them */
|
||||
ucm_port_add_devices(port, pdevices, num);
|
||||
|
||||
/* It needs to setup the paths when setup the profiles */
|
||||
if (num == 1 && cp) {
|
||||
/*
|
||||
* To keep things simple and not worry about stacking controls,
|
||||
* we only support hardware volumes on non-combination ports.
|
||||
*/
|
||||
data = PA_DEVICE_PORT_DATA(port);
|
||||
|
||||
PA_HASHMAP_FOREACH_KV(profile, vol, is_sink ? dev->playback_volumes : dev->capture_volumes, state) {
|
||||
|
|
@ -1118,7 +1182,6 @@ static void ucm_add_port_combination(
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
port->priority = priority;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue