mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-11 13:30:07 -05:00
core: fix pw_core_find_format() for active ports
pw_core_find_format() is currently broken when one of the ports is already active: The format of the active port is used and the other port is completely ignored. As a result, the autolink module may try to link a new port to the first already active port even if the formats do not match. To fix this, use the format of the active port as a filter and enumerate the formats of the other port.
This commit is contained in:
parent
777b97b7d8
commit
1c8daa4a50
1 changed files with 32 additions and 8 deletions
|
|
@ -773,27 +773,51 @@ int pw_core_find_format(struct pw_core *core,
|
||||||
in_state = PW_PORT_STATE_CONFIGURE;
|
in_state = PW_PORT_STATE_CONFIGURE;
|
||||||
|
|
||||||
if (in_state == PW_PORT_STATE_CONFIGURE && out_state > PW_PORT_STATE_CONFIGURE) {
|
if (in_state == PW_PORT_STATE_CONFIGURE && out_state > PW_PORT_STATE_CONFIGURE) {
|
||||||
/* only input needs format */
|
struct spa_pod_builder fb = { 0 };
|
||||||
|
uint8_t fbuf[4096];
|
||||||
|
struct spa_pod *dummy;
|
||||||
|
spa_pod_builder_init(&fb, fbuf, sizeof(fbuf));
|
||||||
if ((res = spa_node_port_enum_params(output->node->node,
|
if ((res = spa_node_port_enum_params(output->node->node,
|
||||||
output->spa_direction, output->port_id,
|
output->spa_direction, output->port_id,
|
||||||
t->param.idFormat, &oidx,
|
t->param.idFormat, &oidx,
|
||||||
NULL, format, builder)) <= 0) {
|
NULL, format, &fb)) <= 0) {
|
||||||
if (res == 0)
|
|
||||||
res = -EBADF;
|
|
||||||
asprintf(error, "error get output format: %s", spa_strerror(res));
|
asprintf(error, "error get output format: %s", spa_strerror(res));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
pw_log_debug("Got output %d format:", oidx);
|
||||||
|
if (pw_log_level_enabled(SPA_LOG_LEVEL_DEBUG))
|
||||||
|
spa_debug_format(2, core->type.map, *format);
|
||||||
|
|
||||||
|
if ((res = spa_node_port_enum_params(input->node->node,
|
||||||
|
input->spa_direction, input->port_id,
|
||||||
|
t->param.idEnumFormat, &iidx,
|
||||||
|
*format, &dummy, builder)) <= 0) {
|
||||||
|
asprintf(error, "error input enum formats: %d", res);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
} else if (out_state == PW_PORT_STATE_CONFIGURE && in_state > PW_PORT_STATE_CONFIGURE) {
|
} else if (out_state == PW_PORT_STATE_CONFIGURE && in_state > PW_PORT_STATE_CONFIGURE) {
|
||||||
/* only output needs format */
|
struct spa_pod_builder fb = { 0 };
|
||||||
|
uint8_t fbuf[4096];
|
||||||
|
struct spa_pod *dummy;
|
||||||
|
spa_pod_builder_init(&fb, fbuf, sizeof(fbuf));
|
||||||
if ((res = spa_node_port_enum_params(input->node->node,
|
if ((res = spa_node_port_enum_params(input->node->node,
|
||||||
input->spa_direction, input->port_id,
|
input->spa_direction, input->port_id,
|
||||||
t->param.idFormat, &iidx,
|
t->param.idFormat, &iidx,
|
||||||
NULL, format, builder)) <= 0) {
|
NULL, format, &fb)) <= 0) {
|
||||||
if (res == 0)
|
|
||||||
res = -EBADF;
|
|
||||||
asprintf(error, "error get input format: %s", spa_strerror(res));
|
asprintf(error, "error get input format: %s", spa_strerror(res));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
pw_log_debug("Got input %d format:", oidx);
|
||||||
|
if (pw_log_level_enabled(SPA_LOG_LEVEL_DEBUG))
|
||||||
|
spa_debug_format(2, core->type.map, *format);
|
||||||
|
|
||||||
|
if ((res = spa_node_port_enum_params(output->node->node,
|
||||||
|
output->spa_direction, output->port_id,
|
||||||
|
t->param.idEnumFormat, &oidx,
|
||||||
|
*format, &dummy, builder)) <= 0) {
|
||||||
|
asprintf(error, "error output enum formats: %d", res);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
} else if (in_state == PW_PORT_STATE_CONFIGURE && out_state == PW_PORT_STATE_CONFIGURE) {
|
} else if (in_state == PW_PORT_STATE_CONFIGURE && out_state == PW_PORT_STATE_CONFIGURE) {
|
||||||
struct spa_pod_builder fb = { 0 };
|
struct spa_pod_builder fb = { 0 };
|
||||||
uint8_t fbuf[4096];
|
uint8_t fbuf[4096];
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue