mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-04 13:29:59 -05:00
device-port: Introduce pa_device_port_new_data
Port creation is now slightly different. It is now similar to how other objects are created (e.g. sinks/sources/cards). This should become more useful in the future when we move more stuff to the ports. Functionally nothing has changed.
This commit is contained in:
parent
23f88ecb84
commit
80b0e285a5
5 changed files with 99 additions and 16 deletions
|
|
@ -4496,11 +4496,15 @@ static pa_device_port* device_port_alsa_init(pa_hashmap *ports, /* card ports */
|
|||
|
||||
if (!p) {
|
||||
pa_alsa_port_data *data;
|
||||
pa_direction_t direction;
|
||||
pa_device_port_new_data port_data;
|
||||
|
||||
direction = path->direction == PA_ALSA_DIRECTION_OUTPUT ? PA_DIRECTION_OUTPUT : PA_DIRECTION_INPUT;
|
||||
pa_device_port_new_data_init(&port_data);
|
||||
pa_device_port_new_data_set_name(&port_data, name);
|
||||
pa_device_port_new_data_set_description(&port_data, description);
|
||||
pa_device_port_new_data_set_direction(&port_data, path->direction == PA_ALSA_DIRECTION_OUTPUT ? PA_DIRECTION_OUTPUT : PA_DIRECTION_INPUT);
|
||||
|
||||
p = pa_device_port_new(core, name, description, direction, sizeof(pa_alsa_port_data));
|
||||
p = pa_device_port_new(core, &port_data, sizeof(pa_alsa_port_data));
|
||||
pa_device_port_new_data_done(&port_data);
|
||||
pa_assert(p);
|
||||
pa_hashmap_put(ports, p->name, p);
|
||||
pa_proplist_update(p->proplist, PA_UPDATE_REPLACE, path->proplist);
|
||||
|
|
|
|||
|
|
@ -688,7 +688,15 @@ static void ucm_add_port_combination(
|
|||
|
||||
port = pa_hashmap_get(ports, name);
|
||||
if (!port) {
|
||||
port = pa_device_port_new(core, pa_strna(name), desc, is_sink ? PA_DIRECTION_OUTPUT : PA_DIRECTION_INPUT, 0);
|
||||
pa_device_port_new_data port_data;
|
||||
|
||||
pa_device_port_new_data_init(&port_data);
|
||||
pa_device_port_new_data_set_name(&port_data, pa_strna(name));
|
||||
pa_device_port_new_data_set_description(&port_data, desc);
|
||||
pa_device_port_new_data_set_direction(&port_data, is_sink ? PA_DIRECTION_OUTPUT : PA_DIRECTION_INPUT);
|
||||
|
||||
port = pa_device_port_new(core, &port_data, 0);
|
||||
pa_device_port_new_data_done(&port_data);
|
||||
pa_assert(port);
|
||||
|
||||
pa_hashmap_put(ports, port->name, port);
|
||||
|
|
|
|||
|
|
@ -2070,6 +2070,8 @@ off:
|
|||
/* Run from main thread */
|
||||
static void create_card_ports(struct userdata *u, pa_hashmap *ports) {
|
||||
pa_device_port *port;
|
||||
pa_device_port_new_data port_data;
|
||||
|
||||
const char *name_prefix = NULL;
|
||||
const char *input_description = NULL;
|
||||
const char *output_description = NULL;
|
||||
|
|
@ -2140,13 +2142,23 @@ static void create_card_ports(struct userdata *u, pa_hashmap *ports) {
|
|||
u->output_port_name = pa_sprintf_malloc("%s-output", name_prefix);
|
||||
u->input_port_name = pa_sprintf_malloc("%s-input", name_prefix);
|
||||
|
||||
pa_assert_se(port = pa_device_port_new(u->core, u->output_port_name, output_description, PA_DIRECTION_OUTPUT, 0));
|
||||
pa_device_port_new_data_init(&port_data);
|
||||
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_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);
|
||||
port->available = get_port_availability(u, PA_DIRECTION_OUTPUT);
|
||||
pa_device_port_new_data_done(&port_data);
|
||||
|
||||
pa_assert_se(port = pa_device_port_new(u->core, u->input_port_name, input_description, PA_DIRECTION_OUTPUT, 0));
|
||||
pa_device_port_new_data_init(&port_data);
|
||||
pa_device_port_new_data_set_name(&port_data, u->input_port_name);
|
||||
pa_device_port_new_data_set_description(&port_data, output_description);
|
||||
pa_device_port_new_data_set_direction(&port_data, PA_DIRECTION_INPUT);
|
||||
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);
|
||||
port->available = get_port_availability(u, PA_DIRECTION_INPUT);
|
||||
pa_device_port_new_data_done(&port_data);
|
||||
}
|
||||
|
||||
/* Run from main thread */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue