From f29bf9cb4046dcbdbbfc080667820ae2fe7fae25 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 15 Sep 2020 13:12:58 +0200 Subject: [PATCH] resample: reset resample state when starting Update the initial delay and size in the rate_match io area when starting. --- spa/plugins/audioconvert/resample.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/spa/plugins/audioconvert/resample.c b/spa/plugins/audioconvert/resample.c index 913674b11..0d2b45ca2 100644 --- a/spa/plugins/audioconvert/resample.c +++ b/spa/plugins/audioconvert/resample.c @@ -238,6 +238,16 @@ static int impl_node_set_io(void *object, uint32_t id, void *data, size_t size) return 0; } +static void update_rate_match(struct impl *this) +{ + if (this->io_rate_match) { + this->io_rate_match->delay = resample_delay(&this->resample); + if (SPA_LIKELY(this->io_position)) + this->io_rate_match->size = resample_in_len(&this->resample, + this->io_position->clock.duration); + } +} + static int impl_node_send_command(void *object, const struct spa_command *command) { struct impl *this = object; @@ -248,6 +258,8 @@ static int impl_node_send_command(void *object, const struct spa_command *comman switch (SPA_NODE_COMMAND_ID(command)) { case SPA_NODE_COMMAND_Start: this->started = true; + resample_update_rate(&this->resample, 1.0); + update_rate_match(this); break; case SPA_NODE_COMMAND_Suspend: /* fallthrough */