From 6ec1f317654ae1e1424ec7c519cf307aae7c3efe Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 10 Nov 2013 21:40:51 +0100 Subject: af: don't skip filtering if there's no more audio My main problem with this is that the output format will be incorrect. (This doesn't matter right, because there are no samples output.) This assumes all audio filters can deal with len==0 passed in for filtering (though I wouldn't see why not). A filter can still signal an error by returning NULL. af_lavrresample has to be fixed, since resampling 0 samples makes libavresample fail and return a negative error code. (Even though it's not documented to return an error code!) --- audio/filter/af.c | 2 -- audio/filter/af_lavrresample.c | 6 +++++- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'audio') diff --git a/audio/filter/af.c b/audio/filter/af.c index cfe4b401df..edee4bef65 100644 --- a/audio/filter/af.c +++ b/audio/filter/af.c @@ -697,8 +697,6 @@ struct mp_audio *af_play(struct af_stream *s, struct mp_audio *data) struct af_instance *af = s->first; // Iterate through all filters do { - if (data->len <= 0) - break; data = af->play(af, data); af = af->next; } while (af && data); diff --git a/audio/filter/af_lavrresample.c b/audio/filter/af_lavrresample.c index 46428e1f76..860e5a52d3 100644 --- a/audio/filter/af_lavrresample.c +++ b/audio/filter/af_lavrresample.c @@ -324,9 +324,13 @@ static struct mp_audio *play(struct af_instance *af, struct mp_audio *data) reorder_channels(data->audio, s->reorder_in, data->bps, data->nch, in_samples); #endif - out_samples = avresample_convert(s->avrctx, + if (out_samples) { + out_samples = avresample_convert(s->avrctx, (uint8_t **) &out->audio, out_size, out_samples, (uint8_t **) &in->audio, in_size, in_samples); + if (out_samples < 0) + return NULL; // error + } *data = *out; -- cgit v1.2.3