From c1cb395f66ec54a67ce0d85bf2e253e5d385a205 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 19 Jul 2016 18:20:57 +0200 Subject: [PATCH] audioresample: after a reset, recalculate the ouput size After we reset the resampler, there is no history anymore in the resampler and the previously calculated output size is no longer valid. Recalculate the new output size after a reset to make sure we don't try to convert too much. --- gst/audioresample/gstaudioresample.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gst/audioresample/gstaudioresample.c b/gst/audioresample/gstaudioresample.c index a7ba00098a..df6782b6cc 100644 --- a/gst/audioresample/gstaudioresample.c +++ b/gst/audioresample/gstaudioresample.c @@ -846,8 +846,16 @@ gst_audio_resample_transform (GstBaseTransform * base, GstBuffer * inbuf, * flag to resync timestamp and offset counters and send event * downstream */ if (G_UNLIKELY (gst_audio_resample_check_discont (resample, inbuf))) { + gsize size; + gint bpf = GST_AUDIO_INFO_BPF (&resample->in); + gst_audio_resample_reset_state (resample); resample->need_discont = TRUE; + + /* need to recalculate the output size */ + size = gst_buffer_get_size (inbuf) / bpf; + size = gst_audio_converter_get_out_frames (resample->converter, size); + gst_buffer_set_size (outbuf, size * bpf); } /* handle discontinuity */