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!)
This commit is contained in:
wm4 2013-11-10 21:40:51 +01:00
parent 775e08ba65
commit 6ec1f31765
2 changed files with 5 additions and 3 deletions

View File

@ -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);

View File

@ -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
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;