From 2f8b4975a3371b70b6045e9b1c076bc3993203c5 Mon Sep 17 00:00:00 2001 From: Abs62 Date: Tue, 15 Jul 2014 18:47:08 +0400 Subject: [PATCH] Fix play ADPCM wav files via internal player --- ffmpegaudio.cc | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/ffmpegaudio.cc b/ffmpegaudio.cc index 1e68af78..2a13e770 100644 --- a/ffmpegaudio.cc +++ b/ffmpegaudio.cc @@ -348,12 +348,21 @@ bool DecoderContext::play( QString & errorString ) { if ( packet.stream_index == audioStream_->index ) { + AVPacket pack = packet; int gotFrame = 0; - avcodec_decode_audio4( codecContext_, frame, &gotFrame, &packet ); - if ( !isCancelled_ && gotFrame ) + do { - playFrame( frame ); + int len = avcodec_decode_audio4( codecContext_, frame, &gotFrame, &pack ); + if ( !isCancelled_ && gotFrame ) + { + playFrame( frame ); + } + if( len <= 0 || isCancelled_ ) + break; + pack.size -= len; + pack.data += len; } + while( pack.size > 0 ); } // av_free_packet() must be called after each call to av_read_frame() av_free_packet( &packet );