From 0d4628a7fd2bb2c0e7b6284d9dd643abb216c16e Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Sat, 16 Nov 2013 14:10:00 +0100 Subject: ao_lavc: fix crash with interleaved audio outputs. --- audio/out/ao_lavc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'audio') diff --git a/audio/out/ao_lavc.c b/audio/out/ao_lavc.c index 117b6c6832..cb8e24d4aa 100644 --- a/audio/out/ao_lavc.c +++ b/audio/out/ao_lavc.c @@ -310,6 +310,8 @@ static int play(struct ao *ao, void **data, int samples, int flags) return 0; } + size_t num_planes = af_fmt_is_planar(ao->format) ? ao->channels.num : 1; + if (flags & AOPLAY_FINAL_CHUNK) { int written = 0; if (samples > 0) { @@ -317,7 +319,7 @@ static int play(struct ao *ao, void **data, int samples, int flags) size_t bytelen = samples * ao->sstride; size_t extralen = (ac->aframesize - 1) * ao->sstride; void *padded[MP_NUM_CHANNELS]; - for (int n = 0; n < ao->channels.num; n++) { + for (int n = 0; n < num_planes; n++) { padded[n] = talloc_size(tmp, bytelen + extralen); memcpy(padded[n], data[n], bytelen); af_fill_silence((char *)padded[n] + bytelen, extralen, ao->format); @@ -411,7 +413,7 @@ static int play(struct ao *ao, void **data, int samples, int flags) while (samples - bufpos >= ac->aframesize) { void *start[MP_NUM_CHANNELS]; - for (int n = 0; n < ao->channels.num; n++) + for (int n = 0; n < num_planes; n++) start[n] = (char *)data[n] + bufpos * ao->sstride; encode(ao, outpts + bufpos / (double) ao->samplerate, start); bufpos += ac->aframesize; -- cgit v1.2.3