device-port: introduce available_group member

In some cases, the I/O connector functionality can be shared
and we cannot determine the proper purpose automatically.
We just know that something was inserted to the jack.

Introduce a group identifier (a simple string - unique
per group) which helps to determine the proper ports
for the application. The user interface may be used
to set the wanted behaviour.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
Jaroslav Kysela 2020-04-14 17:42:34 +02:00 committed by Tanu Kaskinen
parent 9315bbdfe5
commit 861836c5f7
7 changed files with 54 additions and 8 deletions

View file

@ -53,6 +53,13 @@ void pa_device_port_new_data_set_available(pa_device_port_new_data *data, pa_ava
data->available = available;
}
void pa_device_port_new_data_set_available_group(pa_device_port_new_data *data, const char *group) {
pa_assert(data);
pa_xfree(data->available_group);
data->available_group = pa_xstrdup(group);
}
void pa_device_port_new_data_set_direction(pa_device_port_new_data *data, pa_direction_t direction) {
pa_assert(data);
@ -64,6 +71,7 @@ void pa_device_port_new_data_done(pa_device_port_new_data *data) {
pa_xfree(data->name);
pa_xfree(data->description);
pa_xfree(data->available_group);
}
void pa_device_port_set_preferred_profile(pa_device_port *p, const char *new_pp) {
@ -144,6 +152,7 @@ static void device_port_free(pa_object *o) {
if (p->profiles)
pa_hashmap_free(p->profiles);
pa_xfree(p->available_group);
pa_xfree(p->preferred_profile);
pa_xfree(p->name);
pa_xfree(p->description);
@ -169,6 +178,8 @@ pa_device_port *pa_device_port_new(pa_core *c, pa_device_port_new_data *data, si
p->card = NULL;
p->priority = 0;
p->available = data->available;
p->available_group = data->available_group;
data->available_group = NULL;
p->profiles = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
p->direction = data->direction;