summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaroslav Kysela <perex@perex.cz>2020-04-14 20:04:00 +0200
committerTanu Kaskinen <tanuk@iki.fi>2020-06-17 06:06:12 +0000
commitfeee531c2bcc3618b62a7fbb140b80043c680dc4 (patch)
tree4051f989b519d2473f99e64acfe14b079a9b51c9
parent861836c5f72de32ec0debcf8fc3a76c4e2c014e6 (diff)
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>
-rw-r--r--src/modules/bluetooth/module-bluez5-device.c16
-rw-r--r--src/modules/module-tunnel.c4
-rw-r--r--src/modules/raop/raop-sink.c1
-rw-r--r--src/pulse/def.h27
-rw-r--r--src/pulse/introspect.c13
-rw-r--r--src/pulse/introspect.h3
-rw-r--r--src/pulsecore/device-port.c8
-rw-r--r--src/pulsecore/device-port.h3
-rw-r--r--src/pulsecore/protocol-native.c12
9 files changed, 77 insertions, 10 deletions
diff --git a/src/modules/bluetooth/module-bluez5-device.c b/src/modules/bluetooth/module-bluez5-device.c
index 9da5d1ac..402053a5 100644
--- a/src/modules/bluetooth/module-bluez5-device.c
+++ b/src/modules/bluetooth/module-bluez5-device.c
@@ -1762,6 +1762,7 @@ static pa_available_t transport_state_to_availability(pa_bluetooth_transport_sta
static void create_card_ports(struct userdata *u, pa_hashmap *ports) {
pa_device_port *port;
pa_device_port_new_data port_data;
+ pa_device_port_type_t input_type, output_type;
const char *name_prefix, *input_description, *output_description;
pa_assert(u);
@@ -1771,60 +1772,67 @@ static void create_card_ports(struct userdata *u, pa_hashmap *ports) {
name_prefix = "unknown";
input_description = _("Bluetooth Input");
output_description = _("Bluetooth Output");
+ input_type = output_type = PA_DEVICE_PORT_TYPE_BLUETOOTH;
switch (form_factor_from_class(u->device->class_of_device)) {
case PA_BLUETOOTH_FORM_FACTOR_HEADSET:
name_prefix = "headset";
input_description = output_description = _("Headset");
+ input_type = output_type = PA_DEVICE_PORT_TYPE_HEADSET;
break;
case PA_BLUETOOTH_FORM_FACTOR_HANDSFREE:
name_prefix = "handsfree";
input_description = output_description = _("Handsfree");
+ input_type = output_type = PA_DEVICE_PORT_TYPE_HANDSFREE;
break;
case PA_BLUETOOTH_FORM_FACTOR_MICROPHONE:
name_prefix = "microphone";
input_description = _("Microphone");
output_description = _("Bluetooth Output");
+ input_type = PA_DEVICE_PORT_TYPE_MIC;
break;
case PA_BLUETOOTH_FORM_FACTOR_SPEAKER:
name_prefix = "speaker";
input_description = _("Bluetooth Input");
output_description = _("Speaker");
+ output_type = PA_DEVICE_PORT_TYPE_SPEAKER;
break;
case PA_BLUETOOTH_FORM_FACTOR_HEADPHONE:
name_prefix = "headphone";
input_description = _("Bluetooth Input");
output_description = _("Headphone");
+ output_type = PA_DEVICE_PORT_TYPE_HEADPHONES;
break;
case PA_BLUETOOTH_FORM_FACTOR_PORTABLE:
name_prefix = "portable";
input_description = output_description = _("Portable");
+ input_type = output_type = PA_DEVICE_PORT_TYPE_PORTABLE;
break;
case PA_BLUETOOTH_FORM_FACTOR_CAR:
name_prefix = "car";
input_description = output_description = _("Car");
+ input_type = output_type = PA_DEVICE_PORT_TYPE_CAR;
break;
case PA_BLUETOOTH_FORM_FACTOR_HIFI:
name_prefix = "hifi";
input_description = output_description = _("HiFi");
+ input_type = output_type = PA_DEVICE_PORT_TYPE_HIFI;
break;
case PA_BLUETOOTH_FORM_FACTOR_PHONE:
name_prefix = "phone";
input_description = output_description = _("Phone");
+ input_type = output_type = PA_DEVICE_PORT_TYPE_PHONE;
break;
case PA_BLUETOOTH_FORM_FACTOR_UNKNOWN:
- name_prefix = "unknown";
- input_description = _("Bluetooth Input");
- output_description = _("Bluetooth Output");
break;
}
@@ -1833,6 +1841,7 @@ static void create_card_ports(struct userdata *u, pa_hashmap *ports) {
pa_device_port_new_data_set_name(&port_data, u->output_port_name);
pa_device_port_new_data_set_description(&port_data, output_description);
pa_device_port_new_data_set_direction(&port_data, PA_DIRECTION_OUTPUT);
+ pa_device_port_new_data_set_type(&port_data, output_type);
pa_device_port_new_data_set_available(&port_data, get_port_availability(u, PA_DIRECTION_OUTPUT));
pa_assert_se(port = pa_device_port_new(u->core, &port_data, 0));
pa_assert_se(pa_hashmap_put(ports, port->name, port) >= 0);
@@ -1843,6 +1852,7 @@ static void create_card_ports(struct userdata *u, pa_hashmap *ports) {
pa_device_port_new_data_set_name(&port_data, u->input_port_name);
pa_device_port_new_data_set_description(&port_data, input_description);
pa_device_port_new_data_set_direction(&port_data, PA_DIRECTION_INPUT);
+ pa_device_port_new_data_set_type(&port_data, input_type);
pa_device_port_new_data_set_available(&port_data, get_port_availability(u, PA_DIRECTION_INPUT));
pa_assert_se(port = pa_device_port_new(u->core, &port_data, 0));
pa_assert_se(pa_hashmap_put(ports, port->name, port) >= 0);
diff --git a/src/modules/module-tunnel.c b/src/modules/module-tunnel.c
index caac2e48..bb4ae489 100644
--- a/src/modules/module-tunnel.c
+++ b/src/modules/module-tunnel.c
@@ -1039,7 +1039,9 @@ static int read_ports(struct userdata *u, pa_tagstruct *t) {
pa_log("Parse failure");
return -PA_ERR_PROTOCOL;
}
- if (u->version >= 34 && pa_tagstruct_gets(t, &s) < 0) { /* available_group */
+ if (u->version >= 34 &&
+ (pa_tagstruct_gets(t, &s) < 0 || /* available_group */
+ pa_tagstruct_getu32(t, &priority) < 0)) { /* device port type */
pa_log("Parse failure");
return -PA_ERR_PROTOCOL;
}
diff --git a/src/modules/raop/raop-sink.c b/src/modules/raop/raop-sink.c
index 373f2ec4..114f6d1e 100644
--- a/src/modules/raop/raop-sink.c
+++ b/src/modules/raop/raop-sink.c
@@ -635,6 +635,7 @@ static pa_device_port *raop_create_port(struct userdata *u, const char *server)
pa_device_port_new_data_set_name(&data, "network-output");
pa_device_port_new_data_set_description(&data, server);
pa_device_port_new_data_set_direction(&data, PA_DIRECTION_OUTPUT);
+ pa_device_port_new_data_set_type(&data, PA_DEVICE_PORT_TYPE_NETWORK);
port = pa_device_port_new(u->core, &data, 0);
diff --git a/src/pulse/def.h b/src/pulse/def.h
index 100df5b5..2e5a5ec3 100644
--- a/src/pulse/def.h
+++ b/src/pulse/def.h
@@ -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
diff --git a/src/pulse/introspect.c b/src/pulse/introspect.c
index 771d680c..b19c3fd2 100644
--- a/src/pulse/introspect.c
+++ b/src/pulse/introspect.c
@@ -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;
diff --git a/src/pulse/introspect.h b/src/pulse/introspect.h
index 2a6e6b43..89685b50 100644
--- a/src/pulse/introspect.h
+++ b/src/pulse/introspect.h
@@ -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
diff --git a/src/pulsecore/device-port.c b/src/pulsecore/device-port.c
index 9d120076..d5677b16 100644
--- a/src/pulsecore/device-port.c
+++ b/src/pulsecore/device-port.c
@@ -29,6 +29,7 @@ pa_device_port_new_data *pa_device_port_new_data_init(pa_device_port_new_data *d
pa_assert(data);
pa_zero(*data);
+ data->type = PA_DEVICE_PORT_TYPE_UNKNOWN;
data->available = PA_AVAILABLE_UNKNOWN;
return data;
}
@@ -66,6 +67,12 @@ void pa_device_port_new_data_set_direction(pa_device_port_new_data *data, pa_dir
data->direction = direction;
}
+void pa_device_port_new_data_set_type(pa_device_port_new_data *data, pa_device_port_type_t type) {
+ pa_assert(data);
+
+ data->type = type;
+}
+
void pa_device_port_new_data_done(pa_device_port_new_data *data) {
pa_assert(data);
@@ -182,6 +189,7 @@ pa_device_port *pa_device_port_new(pa_core *c, pa_device_port_new_data *data, si
data->available_group = NULL;
p->profiles = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
p->direction = data->direction;
+ p->type = data->type;
p->latency_offset = 0;
p->proplist = pa_proplist_new();
diff --git a/src/pulsecore/device-port.h b/src/pulsecore/device-port.h
index ffaa266d..d75eb3c3 100644
--- a/src/pulsecore/device-port.h
+++ b/src/pulsecore/device-port.h
@@ -43,6 +43,7 @@ struct pa_device_port {
char *name;
char *description;
char *preferred_profile;
+ pa_device_port_type_t type;
unsigned priority;
pa_available_t available; /* PA_AVAILABLE_UNKNOWN, PA_AVAILABLE_NO or PA_AVAILABLE_YES */
@@ -70,6 +71,7 @@ typedef struct pa_device_port_new_data {
pa_available_t available;
char *available_group;
pa_direction_t direction;
+ pa_device_port_type_t type;
} pa_device_port_new_data;
pa_device_port_new_data *pa_device_port_new_data_init(pa_device_port_new_data *data);
@@ -78,6 +80,7 @@ void pa_device_port_new_data_set_description(pa_device_port_new_data *data, cons
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_set_type(pa_device_port_new_data *data, pa_device_port_type_t type);
void pa_device_port_new_data_done(pa_device_port_new_data *data);
pa_device_port *pa_device_port_new(pa_core *c, pa_device_port_new_data *data, size_t extra);
diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c
index dddf169d..25bd5ddf 100644
--- a/src/pulsecore/protocol-native.c
+++ b/src/pulsecore/protocol-native.c
@@ -3207,8 +3207,10 @@ static void sink_fill_tagstruct(pa_native_connection *c, pa_tagstruct *t, pa_sin
pa_tagstruct_putu32(t, p->priority);
if (c->version >= 24) {
pa_tagstruct_putu32(t, p->available);
- if (c->version >= 34)
+ if (c->version >= 34) {
pa_tagstruct_puts(t, p->available_group);
+ pa_tagstruct_putu32(t, p->type);
+ }
}
}
@@ -3280,8 +3282,10 @@ static void source_fill_tagstruct(pa_native_connection *c, pa_tagstruct *t, pa_s
pa_tagstruct_putu32(t, p->priority);
if (c->version >= 24) {
pa_tagstruct_putu32(t, p->available);
- if (c->version >= 34)
+ if (c->version >= 34) {
pa_tagstruct_puts(t, p->available_group);
+ pa_tagstruct_putu32(t, p->type);
+ }
}
}
@@ -3366,8 +3370,10 @@ static void card_fill_tagstruct(pa_native_connection *c, pa_tagstruct *t, pa_car
if (c->version >= 27) {
pa_tagstruct_puts64(t, port->latency_offset);
- if (c->version >= 34)
+ if (c->version >= 34) {
pa_tagstruct_puts(t, port->available_group);
+ pa_tagstruct_putu32(t, port->type);
+ }
}
}
}