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.
This commit is contained in:
Karl Blomster 2008-03-14 05:14:30 +00:00
parent 56370f0f4a
commit 521632cd9b
1 changed files with 5 additions and 3 deletions

View File

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