device-port: add type member

The clients might wanna to know for which purpose is the port.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
Jaroslav Kysela 2020-04-14 20:04:00 +02:00 committed by Tanu Kaskinen
parent 861836c5f7
commit feee531c2b
9 changed files with 77 additions and 10 deletions

View file

@ -1070,6 +1070,33 @@ typedef enum pa_port_available {
/** \endcond */
#endif
/** Port type. \since 14.0 */
typedef enum pa_device_port_type {
PA_DEVICE_PORT_TYPE_UNKNOWN = 0,
PA_DEVICE_PORT_TYPE_AUX = 1,
PA_DEVICE_PORT_TYPE_SPEAKER = 2,
PA_DEVICE_PORT_TYPE_HEADPHONES = 3,
PA_DEVICE_PORT_TYPE_LINE = 4,
PA_DEVICE_PORT_TYPE_MIC = 5,
PA_DEVICE_PORT_TYPE_HEADSET = 6,
PA_DEVICE_PORT_TYPE_HANDSET = 7,
PA_DEVICE_PORT_TYPE_EARPIECE = 8,
PA_DEVICE_PORT_TYPE_SPDIF = 9,
PA_DEVICE_PORT_TYPE_HDMI = 10,
PA_DEVICE_PORT_TYPE_TV = 11,
PA_DEVICE_PORT_TYPE_RADIO = 12,
PA_DEVICE_PORT_TYPE_VIDEO = 13,
PA_DEVICE_PORT_TYPE_USB = 14,
PA_DEVICE_PORT_TYPE_BLUETOOTH = 15,
PA_DEVICE_PORT_TYPE_PORTABLE = 16,
PA_DEVICE_PORT_TYPE_HANDSFREE = 17,
PA_DEVICE_PORT_TYPE_CAR = 18,
PA_DEVICE_PORT_TYPE_HIFI = 19,
PA_DEVICE_PORT_TYPE_PHONE = 20,
PA_DEVICE_PORT_TYPE_NETWORK = 21,
PA_DEVICE_PORT_TYPE_ANALOG = 22,
} pa_device_port_type_t;
PA_C_DECL_END
#endif

View file

@ -220,8 +220,10 @@ static void context_get_sink_info_callback(pa_pdispatch *pd, uint32_t command, u
i.ports[j]->available = av;
}
i.ports[j]->available_group = NULL;
i.ports[j]->type = PA_DEVICE_PORT_TYPE_UNKNOWN;
if (o->context->version >= 34) {
if (pa_tagstruct_gets(t, &i.ports[j]->available_group) < 0)
if (pa_tagstruct_gets(t, &i.ports[j]->available_group) < 0 ||
pa_tagstruct_getu32(t, &i.ports[j]->type) < 0)
goto fail;
}
}
@ -498,8 +500,10 @@ static void context_get_source_info_callback(pa_pdispatch *pd, uint32_t command,
i.ports[j]->available = av;
}
i.ports[j]->available_group = NULL;
i.ports[j]->type = PA_DEVICE_PORT_TYPE_UNKNOWN;
if (o->context->version >= 34) {
if (pa_tagstruct_gets(t, &i.ports[j]->available_group) < 0)
if (pa_tagstruct_gets(t, &i.ports[j]->available_group) < 0 ||
pa_tagstruct_getu32(t, &i.ports[j]->type))
goto fail;
}
}
@ -872,8 +876,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;
port->type = PA_DEVICE_PORT_TYPE_UNKNOWN;
if (context->version >= 34) {
if (pa_tagstruct_gets(t, &port->available_group) < 0)
if (pa_tagstruct_gets(t, &port->available_group) < 0 ||
pa_tagstruct_getu32(t, &port->type) < 0)
return -PA_ERR_PROTOCOL;
} else
port->available_group = NULL;

View file

@ -230,6 +230,7 @@ typedef struct pa_sink_port_info {
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 */
uint32_t type; /**< Port device type (PA_PORT_DEVICE_TYPE). \since 14.0 */
} pa_sink_port_info;
/** Stores information about sinks. Please note that this structure
@ -311,6 +312,7 @@ typedef struct pa_source_port_info {
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 */
uint32_t type; /**< Port device type (PA_PORT_DEVICE_TYPE). \since 14.0 */
} pa_source_port_info;
/** Stores information about sources. Please note that this structure
@ -512,6 +514,7 @@ typedef struct pa_card_port_info {
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 */
uint32_t type; /**< Port device type (PA_PORT_DEVICE_TYPE). \since 14.0 */
} pa_card_port_info;
/** Stores information about cards. Please note that this structure