diff options
author | wm4 <wm4@nowhere> | 2016-08-19 22:27:15 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2016-08-19 22:27:15 +0200 |
commit | 23993e91f37f2b15eb1a1103b2444a38b6bd66d3 (patch) | |
tree | a78edb25160d97b5571e3a1ea7298d0215c4daf5 /audio/filter | |
parent | 68dc869d6aa8eb7004e2f86e9e4dcbf203ae6a8c (diff) | |
download | mpv-23993e91f37f2b15eb1a1103b2444a38b6bd66d3.tar.bz2 mpv-23993e91f37f2b15eb1a1103b2444a38b6bd66d3.tar.xz |
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.
Diffstat (limited to 'audio/filter')
-rw-r--r-- | audio/filter/af_lavrresample.c | 9 |
1 files changed, 5 insertions, 4 deletions
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) |