From 23993e91f37f2b15eb1a1103b2444a38b6bd66d3 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 19 Aug 2016 22:27:15 +0200 Subject: af_lavrresample: fix error if resampler could not be recreated There are situations where the resampler is destroyed and recreated during playback. If recreating the resampler unexpectedly fails, the filter function is supposed to return an error. This wasn't done correctly, because get_out_samples() accessed the resampler before the check. Move the check up to fix this. --- audio/filter/af_lavrresample.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'audio') diff --git a/audio/filter/af_lavrresample.c b/audio/filter/af_lavrresample.c index 99c080478d..7c704c22e8 100644 --- a/audio/filter/af_lavrresample.c +++ b/audio/filter/af_lavrresample.c @@ -479,19 +479,20 @@ static void reorder_planes(struct mp_audio *mpa, int *reorder, static int filter_resample(struct af_instance *af, struct mp_audio *in) { struct af_resample *s = af->priv; + struct mp_audio *out = NULL; + + if (!s->avrctx) + goto error; int samples = get_out_samples(s, in ? in->samples : 0); struct mp_audio out_format = s->pool_fmt; - struct mp_audio *out = mp_audio_pool_get(af->out_pool, &out_format, samples); + out = mp_audio_pool_get(af->out_pool, &out_format, samples); if (!out) goto error; if (in) mp_audio_copy_attributes(out, in); - if (!s->avrctx) - goto error; - if (out->samples) { out->samples = resample_frame(s->avrctx, out, in); if (out->samples < 0) -- cgit v1.2.3