path: root/audio
diff options
authorwm4 <wm4@nowhere>2013-11-10 21:40:51 +0100
committerwm4 <wm4@nowhere>2013-11-10 22:49:39 +0100
commit6ec1f317654ae1e1424ec7c519cf307aae7c3efe (patch)
tree414385c5a2c8f434e7839ecd729720ed027c940b /audio
parent775e08ba656baab77b245536f4d3aaebde503279 (diff)
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!)
Diffstat (limited to 'audio')
2 files changed, 5 insertions, 3 deletions
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);
- 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;