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

@ -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;

View file

@ -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