summaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
authorRudolf Polzer <divverent@xonotic.org>2013-11-16 14:10:00 +0100
committerRudolf Polzer <divverent@xonotic.org>2013-11-16 14:10:00 +0100
commit0d4628a7fd2bb2c0e7b6284d9dd643abb216c16e (patch)
treebb67f4b90b94a8482ed2124195e58b9dbd5bcb24 /audio
parent514c4547702a01adb6f9e6274c40a77c7c511339 (diff)
downloadmpv-0d4628a7fd2bb2c0e7b6284d9dd643abb216c16e.tar.bz2
mpv-0d4628a7fd2bb2c0e7b6284d9dd643abb216c16e.tar.xz
ao_lavc: fix crash with interleaved audio outputs.
Diffstat (limited to 'audio')
-rw-r--r--audio/out/ao_lavc.c6
1 files changed, 4 insertions, 2 deletions
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;