af_lavrresample: fix crash with size 0

The filter output size can be 0. Due to how filtering works, this is
nothing unusual, but avresample_convert() will return 0. The same case
is already handling with "normal" resampling (this commit fixes the
reordering code).

Additionally, don't use an assert(). avresample_convert() failing is
unusual, but might also happen due to e.g. internal out of memory
conditions, so we shouldn't just crash on it.

Curiously observed with --ao=oss --audio-channels=5.1 when changing
speed.
This commit is contained in:
wm4 2014-09-15 23:14:19 +02:00
parent 7c2fb859ab
commit b2b1b848da
1 changed files with 3 additions and 2 deletions

View File

@ -338,7 +338,7 @@ static int filter(struct af_instance *af, struct mp_audio *data, int flags)
if (needs_reorder(s->reorder_out, out->nch)) {
if (af_fmt_is_planar(out->format)) {
reorder_planes(data, s->reorder_out);
} else {
} else if (out->samples) {
int out_size = out->samples * out->sstride;
if (talloc_get_size(s->reorder_buffer) < out_size)
s->reorder_buffer = talloc_realloc_size(s, s->reorder_buffer, out_size);
@ -346,7 +346,8 @@ static int filter(struct af_instance *af, struct mp_audio *data, int flags)
int out_samples = avresample_convert(s->avrctx_out,
(uint8_t **) data->planes, out_size, out->samples,
(uint8_t **) out->planes, out_size, out->samples);
assert(out_samples == data->samples);
if (out_samples < 0)
MP_ERR(af, "Reordering failed.\n");
}
}