From e59c4675a75ef357740c5714b2a7649da0ff7646 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 14 Sep 2020 16:39:42 +0200 Subject: [PATCH] audioconvert: send the command to the children Send the command on the converter to all children as well. Reset the resampler when we are paused so that we don't end up with old data. Fixes #288 --- spa/plugins/audioconvert/audioconvert.c | 18 +++++++++++++++--- spa/plugins/audioconvert/channelmix.c | 2 ++ spa/plugins/audioconvert/fmtconvert.c | 2 ++ spa/plugins/audioconvert/merger.c | 2 ++ spa/plugins/audioconvert/resample-native.c | 2 ++ spa/plugins/audioconvert/resample.c | 1 + spa/plugins/audioconvert/splitter.c | 2 ++ 7 files changed, 26 insertions(+), 3 deletions(-) diff --git a/spa/plugins/audioconvert/audioconvert.c b/spa/plugins/audioconvert/audioconvert.c index a0605cd6e..5fcb6b30f 100644 --- a/spa/plugins/audioconvert/audioconvert.c +++ b/spa/plugins/audioconvert/audioconvert.c @@ -791,7 +791,7 @@ static int impl_node_set_param(void *object, uint32_t id, uint32_t flags, static int impl_node_send_command(void *object, const struct spa_command *command) { struct impl *this = object; - int res; + int res, i; spa_return_val_if_fail(this != NULL, -EINVAL); spa_return_val_if_fail(command != NULL, -EINVAL); @@ -802,7 +802,6 @@ static int impl_node_send_command(void *object, const struct spa_command *comman return res; if ((res = setup_buffers(this, SPA_DIRECTION_INPUT)) < 0) return res; - this->started = true; break; case SPA_NODE_COMMAND_Suspend: @@ -811,10 +810,23 @@ static int impl_node_send_command(void *object, const struct spa_command *comman case SPA_NODE_COMMAND_Pause: this->started = false; break; - default: return -ENOTSUP; } + + for (i = 0; i < this->n_nodes; i++) { + if ((res = spa_node_send_command(this->nodes[i], command)) < 0) { + spa_log_error(this->log, NAME " %p: can't send command to node %d: %s", + this, i, spa_strerror(res)); + } + } + + switch (SPA_NODE_COMMAND_ID(command)) { + case SPA_NODE_COMMAND_Start: + this->started = true; + break; + } + return 0; } diff --git a/spa/plugins/audioconvert/channelmix.c b/spa/plugins/audioconvert/channelmix.c index a215c113c..337c03355 100644 --- a/spa/plugins/audioconvert/channelmix.c +++ b/spa/plugins/audioconvert/channelmix.c @@ -442,6 +442,8 @@ static int impl_node_send_command(void *object, const struct spa_command *comman case SPA_NODE_COMMAND_Start: this->started = true; break; + case SPA_NODE_COMMAND_Suspend: + /* fallthrough */ case SPA_NODE_COMMAND_Pause: this->started = false; break; diff --git a/spa/plugins/audioconvert/fmtconvert.c b/spa/plugins/audioconvert/fmtconvert.c index ec5e0d66a..e81c2f653 100644 --- a/spa/plugins/audioconvert/fmtconvert.c +++ b/spa/plugins/audioconvert/fmtconvert.c @@ -244,6 +244,8 @@ static int impl_node_send_command(void *object, const struct spa_command *comman case SPA_NODE_COMMAND_Start: this->started = true; break; + case SPA_NODE_COMMAND_Suspend: + /* fallthrough */ case SPA_NODE_COMMAND_Pause: this->started = false; break; diff --git a/spa/plugins/audioconvert/merger.c b/spa/plugins/audioconvert/merger.c index 38146968e..641d3d5bd 100644 --- a/spa/plugins/audioconvert/merger.c +++ b/spa/plugins/audioconvert/merger.c @@ -347,6 +347,8 @@ static int impl_node_send_command(void *object, const struct spa_command *comman case SPA_NODE_COMMAND_Start: this->started = true; break; + case SPA_NODE_COMMAND_Suspend: + /* fallthrough */ case SPA_NODE_COMMAND_Pause: this->started = false; break; diff --git a/spa/plugins/audioconvert/resample-native.c b/spa/plugins/audioconvert/resample-native.c index ad967d2f7..f9fb10d9c 100644 --- a/spa/plugins/audioconvert/resample-native.c +++ b/spa/plugins/audioconvert/resample-native.c @@ -305,6 +305,8 @@ static void impl_native_process(struct resample *r, static void impl_native_reset (struct resample *r) { struct native_data *d = r->data; + if (d == NULL) + return; memset(d->hist_mem, 0, r->channels * sizeof(float) * d->n_taps * 2); d->hist = (d->n_taps / 2) - 1; d->phase = 0; diff --git a/spa/plugins/audioconvert/resample.c b/spa/plugins/audioconvert/resample.c index 9814e1db5..913674b11 100644 --- a/spa/plugins/audioconvert/resample.c +++ b/spa/plugins/audioconvert/resample.c @@ -252,6 +252,7 @@ static int impl_node_send_command(void *object, const struct spa_command *comman case SPA_NODE_COMMAND_Suspend: /* fallthrough */ case SPA_NODE_COMMAND_Pause: + resample_reset(&this->resample); this->started = false; break; default: diff --git a/spa/plugins/audioconvert/splitter.c b/spa/plugins/audioconvert/splitter.c index 17cee71e3..bc82fac7a 100644 --- a/spa/plugins/audioconvert/splitter.c +++ b/spa/plugins/audioconvert/splitter.c @@ -329,6 +329,8 @@ static int impl_node_send_command(void *object, const struct spa_command *comman case SPA_NODE_COMMAND_Start: this->started = true; break; + case SPA_NODE_COMMAND_Suspend: + /* fallthrough */ case SPA_NODE_COMMAND_Pause: this->started = false; break;