From bae0622311780b925f126dc73ddd9a98e8d6c131 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 25 May 2021 17:54:24 +0200 Subject: [PATCH] filter-chain: pass latency param along Intercept the latency param and pass it on the right stream. --- src/modules/module-filter-chain.c | 51 +++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 10 deletions(-) diff --git a/src/modules/module-filter-chain.c b/src/modules/module-filter-chain.c index b409fb76c..174fbc634 100644 --- a/src/modules/module-filter-chain.c +++ b/src/modules/module-filter-chain.c @@ -567,21 +567,13 @@ static void graph_reset(struct graph *graph) } } -static void param_changed(void *data, uint32_t id, const struct spa_pod *param) +static void param_props_changed(struct impl *impl, const struct spa_pod *param) { - struct impl *impl = data; - const struct spa_pod_prop *prop; struct spa_pod_object *obj = (struct spa_pod_object *) param; + const struct spa_pod_prop *prop; struct graph *graph = &impl->graph; int changed = 0; - if (id == SPA_PARAM_Format && param == NULL) { - graph_reset(graph); - return; - } - if (id != SPA_PARAM_Props) - return; - SPA_POD_OBJECT_FOREACH(obj, prop) { uint32_t idx; float value; @@ -620,6 +612,45 @@ static void param_changed(void *data, uint32_t id, const struct spa_pod *param) } } +static void param_latency_changed(struct impl *impl, const struct spa_pod *param) +{ + struct spa_latency_info latency; + uint8_t buffer[1024]; + struct spa_pod_builder b; + const struct spa_pod *params[1]; + + if (spa_latency_parse(param, &latency) < 0) + return; + + spa_pod_builder_init(&b, buffer, sizeof(buffer)); + params[0] = spa_latency_build(&b, SPA_PARAM_Latency, &latency); + + if (latency.direction == SPA_DIRECTION_INPUT) + pw_stream_update_params(impl->capture, params, 1); + else + pw_stream_update_params(impl->playback, params, 1); +} + +static void param_changed(void *data, uint32_t id, const struct spa_pod *param) +{ + struct impl *impl = data; + struct graph *graph = &impl->graph; + + switch (id) { + case SPA_PARAM_Format: + if (param == NULL) + graph_reset(graph); + break; + case SPA_PARAM_Props: + if (param != NULL) + param_props_changed(impl, param); + break; + case SPA_PARAM_Latency: + param_latency_changed(impl, param); + break; + } +} + static const struct pw_stream_events in_stream_events = { PW_VERSION_STREAM_EVENTS, .destroy = capture_destroy,