mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-10-29 05:40:23 -04:00
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:
parent
9315bbdfe5
commit
861836c5f7
7 changed files with 54 additions and 8 deletions
|
|
@ -42,7 +42,7 @@ AC_SUBST(PA_MINOR, pa_minor)
|
|||
AC_SUBST(PA_MAJORMINOR, pa_major.pa_minor)
|
||||
|
||||
AC_SUBST(PA_API_VERSION, 12)
|
||||
AC_SUBST(PA_PROTOCOL_VERSION, 33)
|
||||
AC_SUBST(PA_PROTOCOL_VERSION, 34)
|
||||
|
||||
# The stable ABI for client applications, for the version info x:y:z
|
||||
# always will hold x=z
|
||||
|
|
|
|||
|
|
@ -1034,9 +1034,15 @@ static int read_ports(struct userdata *u, pa_tagstruct *t) {
|
|||
pa_log("Parse failure");
|
||||
return -PA_ERR_PROTOCOL;
|
||||
}
|
||||
if (u->version >= 24 && pa_tagstruct_getu32(t, &priority) < 0) { /* available */
|
||||
pa_log("Parse failure");
|
||||
return -PA_ERR_PROTOCOL;
|
||||
if (u->version >= 24) {
|
||||
if (pa_tagstruct_getu32(t, &priority) < 0) { /* available */
|
||||
pa_log("Parse failure");
|
||||
return -PA_ERR_PROTOCOL;
|
||||
}
|
||||
if (u->version >= 34 && pa_tagstruct_gets(t, &s) < 0) { /* available_group */
|
||||
pa_log("Parse failure");
|
||||
return -PA_ERR_PROTOCOL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -219,6 +219,11 @@ static void context_get_sink_info_callback(pa_pdispatch *pd, uint32_t command, u
|
|||
goto fail;
|
||||
i.ports[j]->available = av;
|
||||
}
|
||||
i.ports[j]->available_group = NULL;
|
||||
if (o->context->version >= 34) {
|
||||
if (pa_tagstruct_gets(t, &i.ports[j]->available_group) < 0)
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
i.ports[j] = NULL;
|
||||
|
|
@ -492,11 +497,15 @@ static void context_get_source_info_callback(pa_pdispatch *pd, uint32_t command,
|
|||
goto fail;
|
||||
i.ports[j]->available = av;
|
||||
}
|
||||
i.ports[j]->available_group = NULL;
|
||||
if (o->context->version >= 34) {
|
||||
if (pa_tagstruct_gets(t, &i.ports[j]->available_group) < 0)
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
i.ports[j] = NULL;
|
||||
}
|
||||
|
||||
if (pa_tagstruct_gets(t, &ap) < 0)
|
||||
goto fail;
|
||||
|
||||
|
|
@ -863,6 +872,11 @@ static int fill_card_port_info(pa_context *context, pa_tagstruct* t, pa_card_inf
|
|||
return -PA_ERR_PROTOCOL;
|
||||
} else
|
||||
port->latency_offset = 0;
|
||||
if (context->version >= 34) {
|
||||
if (pa_tagstruct_gets(t, &port->available_group) < 0)
|
||||
return -PA_ERR_PROTOCOL;
|
||||
} else
|
||||
port->available_group = NULL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -229,6 +229,7 @@ typedef struct pa_sink_port_info {
|
|||
const char *description; /**< Description of this port */
|
||||
uint32_t priority; /**< The higher this value is, the more useful this port is as a default. */
|
||||
int available; /**< A flags (see #pa_port_available), indicating availability status of this port. \since 2.0 */
|
||||
const char *available_group; /**< A string indentifier which determine the group of devices handling the available state simultaneously. \since 14.0 */
|
||||
} pa_sink_port_info;
|
||||
|
||||
/** Stores information about sinks. Please note that this structure
|
||||
|
|
@ -309,6 +310,7 @@ typedef struct pa_source_port_info {
|
|||
const char *description; /**< Description of this port */
|
||||
uint32_t priority; /**< The higher this value is, the more useful this port is as a default. */
|
||||
int available; /**< A flags (see #pa_port_available), indicating availability status of this port. \since 2.0 */
|
||||
const char *available_group; /**< A string indentifier which determine the group of devices handling the available state simultaneously. \since 14.0 */
|
||||
} pa_source_port_info;
|
||||
|
||||
/** Stores information about sources. Please note that this structure
|
||||
|
|
@ -509,6 +511,7 @@ typedef struct pa_card_port_info {
|
|||
pa_proplist *proplist; /**< Property list */
|
||||
int64_t latency_offset; /**< Latency offset of the port that gets added to the sink/source latency when the port is active. \since 3.0 */
|
||||
pa_card_profile_info2** profiles2; /**< Array of pointers to available profiles, or NULL. Array is terminated by an entry set to NULL. \since 5.0 */
|
||||
const char *available_group; /**< A string indentifier which determine the group of devices handling the available state simultaneously. \since 14.0 */
|
||||
} pa_card_port_info;
|
||||
|
||||
/** Stores information about cards. Please note that this structure
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ struct pa_device_port {
|
|||
|
||||
unsigned priority;
|
||||
pa_available_t available; /* PA_AVAILABLE_UNKNOWN, PA_AVAILABLE_NO or PA_AVAILABLE_YES */
|
||||
char *available_group; /* a string indentifier which determine the group of devices handling the available state simulteneously */
|
||||
|
||||
pa_proplist *proplist;
|
||||
pa_hashmap *profiles; /* Does not own the profiles */
|
||||
|
|
@ -67,6 +68,7 @@ typedef struct pa_device_port_new_data {
|
|||
char *name;
|
||||
char *description;
|
||||
pa_available_t available;
|
||||
char *available_group;
|
||||
pa_direction_t direction;
|
||||
} pa_device_port_new_data;
|
||||
|
||||
|
|
@ -74,6 +76,7 @@ pa_device_port_new_data *pa_device_port_new_data_init(pa_device_port_new_data *d
|
|||
void pa_device_port_new_data_set_name(pa_device_port_new_data *data, const char *name);
|
||||
void pa_device_port_new_data_set_description(pa_device_port_new_data *data, const char *description);
|
||||
void pa_device_port_new_data_set_available(pa_device_port_new_data *data, pa_available_t available);
|
||||
void pa_device_port_new_data_set_available_group(pa_device_port_new_data *data, const char *group);
|
||||
void pa_device_port_new_data_set_direction(pa_device_port_new_data *data, pa_direction_t direction);
|
||||
void pa_device_port_new_data_done(pa_device_port_new_data *data);
|
||||
|
||||
|
|
|
|||
|
|
@ -3205,8 +3205,11 @@ static void sink_fill_tagstruct(pa_native_connection *c, pa_tagstruct *t, pa_sin
|
|||
pa_tagstruct_puts(t, p->name);
|
||||
pa_tagstruct_puts(t, p->description);
|
||||
pa_tagstruct_putu32(t, p->priority);
|
||||
if (c->version >= 24)
|
||||
if (c->version >= 24) {
|
||||
pa_tagstruct_putu32(t, p->available);
|
||||
if (c->version >= 34)
|
||||
pa_tagstruct_puts(t, p->available_group);
|
||||
}
|
||||
}
|
||||
|
||||
pa_tagstruct_puts(t, sink->active_port ? sink->active_port->name : NULL);
|
||||
|
|
@ -3275,8 +3278,11 @@ static void source_fill_tagstruct(pa_native_connection *c, pa_tagstruct *t, pa_s
|
|||
pa_tagstruct_puts(t, p->name);
|
||||
pa_tagstruct_puts(t, p->description);
|
||||
pa_tagstruct_putu32(t, p->priority);
|
||||
if (c->version >= 24)
|
||||
if (c->version >= 24) {
|
||||
pa_tagstruct_putu32(t, p->available);
|
||||
if (c->version >= 34)
|
||||
pa_tagstruct_puts(t, p->available_group);
|
||||
}
|
||||
}
|
||||
|
||||
pa_tagstruct_puts(t, source->active_port ? source->active_port->name : NULL);
|
||||
|
|
@ -3358,8 +3364,11 @@ static void card_fill_tagstruct(pa_native_connection *c, pa_tagstruct *t, pa_car
|
|||
PA_HASHMAP_FOREACH(p, port->profiles, state2)
|
||||
pa_tagstruct_puts(t, p->name);
|
||||
|
||||
if (c->version >= 27)
|
||||
if (c->version >= 27) {
|
||||
pa_tagstruct_puts64(t, port->latency_offset);
|
||||
if (c->version >= 34)
|
||||
pa_tagstruct_puts(t, port->available_group);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue