From 98d10bbd1f236c38daabb7ce2df445101fccf089 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 3 Jul 2019 11:01:12 +0200 Subject: [PATCH] adapter: use slave as filter for adapter This makes the converter choose the final param and not the slave, which makes more sense. --- src/modules/module-adapter/adapter.c | 52 ++++++++++++++-------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/src/modules/module-adapter/adapter.c b/src/modules/module-adapter/adapter.c index ceff8a57f..50029e06f 100644 --- a/src/modules/module-adapter/adapter.c +++ b/src/modules/module-adapter/adapter.c @@ -528,19 +528,7 @@ static int negotiate_format(struct impl *impl) spa_log_debug(this->log, NAME "%p: negiotiate", impl); state = 0; - if ((res = spa_node_port_enum_params_sync(impl->adapter_mix, - SPA_DIRECTION_REVERSE(impl->direction), - impl->adapter_mix_port, - SPA_PARAM_EnumFormat, &state, - NULL, &format, &b)) != 1) { - debug_params(impl, impl->adapter_mix, - SPA_DIRECTION_REVERSE(impl->direction), - impl->adapter_mix_port, - SPA_PARAM_EnumFormat, NULL); - return -ENOTSUP; - } - - state = 0; + format = NULL; if ((res = spa_node_port_enum_params_sync(impl->slave_node, impl->direction, 0, SPA_PARAM_EnumFormat, &state, @@ -550,6 +538,19 @@ static int negotiate_format(struct impl *impl) return -ENOTSUP; } + state = 0; + if ((res = spa_node_port_enum_params_sync(impl->adapter_mix, + SPA_DIRECTION_REVERSE(impl->direction), + impl->adapter_mix_port, + SPA_PARAM_EnumFormat, &state, + format, &format, &b)) != 1) { + debug_params(impl, impl->adapter_mix, + SPA_DIRECTION_REVERSE(impl->direction), + impl->adapter_mix_port, + SPA_PARAM_EnumFormat, NULL); + return -ENOTSUP; + } + spa_pod_fixate(format); if (pw_log_level_enabled(SPA_LOG_LEVEL_DEBUG)) spa_debug_format(0, NULL, format); @@ -576,7 +577,7 @@ static int negotiate_buffers(struct impl *impl) uint8_t buffer[4096]; struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buffer, sizeof(buffer)); uint32_t state; - struct spa_pod *param = NULL; + struct spa_pod *param; int res, i; bool in_alloc, out_alloc; int32_t size, buffers, blocks, align, flags; @@ -591,6 +592,17 @@ static int negotiate_buffers(struct impl *impl) if (impl->n_buffers > 0) return 0; + state = 0; + param = NULL; + if ((res = spa_node_port_enum_params_sync(impl->slave_node, + impl->direction, 0, + SPA_PARAM_Buffers, &state, + param, ¶m, &b)) != 1) { + debug_params(impl, impl->slave_node, impl->direction, 0, + SPA_PARAM_Buffers, param); + return -ENOTSUP; + } + state = 0; if ((res = spa_node_port_enum_params_sync(impl->adapter_mix, SPA_DIRECTION_REVERSE(impl->direction), @@ -603,18 +615,6 @@ static int negotiate_buffers(struct impl *impl) SPA_PARAM_Buffers, param); return -ENOTSUP; } - if (res != 1) - param = NULL; - - state = 0; - if ((res = spa_node_port_enum_params_sync(impl->slave_node, - impl->direction, 0, - SPA_PARAM_Buffers, &state, - param, ¶m, &b)) < 0) { - debug_params(impl, impl->slave_node, impl->direction, 0, - SPA_PARAM_Buffers, param); - return res; - } spa_pod_fixate(param);