From 521632cd9bf4f14a275f6d8b33943de8ba89d70d Mon Sep 17 00:00:00 2001 From: Karl Blomster Date: Fri, 14 Mar 2008 05:14:30 +0000 Subject: [PATCH] changed output buffer size to AVCODEC_MAX_AUDIO_FRAME_SIZE which is what it's actually malloc()'ed as. might actually work now. Originally committed to SVN as r2052. --- aegisub/audio_provider_lavc.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/aegisub/audio_provider_lavc.cpp b/aegisub/audio_provider_lavc.cpp index 0beb69145..4f1feba43 100644 --- a/aegisub/audio_provider_lavc.cpp +++ b/aegisub/audio_provider_lavc.cpp @@ -165,10 +165,12 @@ void LAVCAudioProvider::GetAudio(void *buf, int64_t start, int64_t count) AVPacket packet; while (_count > 0 && av_read_frame(lavcfile->fctx, &packet) >= 0) { while (packet.stream_index == audStream) { - int bytesout = 0, samples; - if (avcodec_decode_audio2(codecContext, buffer, &bytesout, packet.data, packet.size) < 0) + int bytesout = AVCODEC_MAX_AUDIO_FRAME_SIZE; /* see constructor, it malloc()'s buffer to this */ + int samples; + /* returns negative if error, 0 if no frame decoded, number of bytes used on success */ + if (avcodec_decode_audio2(codecContext, buffer, &bytesout, packet.data, packet.size) <= 0) throw _T("Failed to decode audio"); - if (bytesout == 0) + if (bytesout == 0) /* sanity checking */ break; samples = bytesout >> 1;