From 7ddbd15d2907b90920a1ef1bc6e60e2d6b307eca Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Fri, 14 Apr 2006 23:59:24 +0000 Subject: [PATCH] fix empty audio frames case Originally committed to SVN as r341. --- core/audio_provider_lavc.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/audio_provider_lavc.cpp b/core/audio_provider_lavc.cpp index 31961639c..f79d06c8d 100644 --- a/core/audio_provider_lavc.cpp +++ b/core/audio_provider_lavc.cpp @@ -136,10 +136,13 @@ void LAVCAudioProvider::GetAudio(void *buf, __int64 start, __int64 count) AVPacket packet; while (_count > 0 && av_read_frame(lavcfile->fctx, &packet) >= 0) { - if(packet.stream_index == audStream) { + while (packet.stream_index == audStream) { int bytesout = 0, samples; if (avcodec_decode_audio(codecContext, buffer, &bytesout, packet.data, packet.size) < 0) throw _T("Failed to decode audio"); + if (bytesout == 0) + break; + samples = bytesout >> 1; if (rsct) { if ((__int64)(samples * resample_ratio) > _count) @@ -156,6 +159,7 @@ void LAVCAudioProvider::GetAudio(void *buf, __int64 start, __int64 count) _buf += samples; _count -= samples; + break; } av_free_packet(&packet);