diff options
author | Christian Gmeiner <christian.gmeiner@gmail.com> | 2009-12-05 21:38:47 +0100 |
---|---|---|
committer | Christian Gmeiner <christian.gmeiner@gmail.com> | 2009-12-05 21:38:47 +0100 |
commit | 41f0211ca48e2c5a5af1fe41f9af644012fe91c4 (patch) | |
tree | 3480773077e97cd59d7315907cb1567c8c8fa411 /dxr3audiodecoder.c | |
parent | db60f10e5c1d76799ba397c3791ed86aa8b6f7c6 (diff) | |
download | vdr-plugin-dxr3-41f0211ca48e2c5a5af1fe41f9af644012fe91c4.tar.gz vdr-plugin-dxr3-41f0211ca48e2c5a5af1fe41f9af644012fe91c4.tar.bz2 |
fix audio problems with vdr 1.7.10
Diffstat (limited to 'dxr3audiodecoder.c')
-rw-r--r-- | dxr3audiodecoder.c | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/dxr3audiodecoder.c b/dxr3audiodecoder.c index 8eeb68a..f3dd0ca 100644 --- a/dxr3audiodecoder.c +++ b/dxr3audiodecoder.c @@ -90,8 +90,7 @@ void cDxr3AudioDecoder::Init() //! decode given buffer void cDxr3AudioDecoder::Decode(cDxr3PesFrame *frame, uint32_t pts, cDxr3SyncBuffer &aBuf) { - int len; - int out_size = AVCODEC_MAX_AUDIO_FRAME_SIZE; + int len, out_size; const uint8_t *buf = frame->GetPayload(); int length = frame->GetPayloadLength(); @@ -109,31 +108,33 @@ void cDxr3AudioDecoder::Decode(cDxr3PesFrame *frame, uint32_t pts, cDxr3SyncBuff } } + uint8_t *ptr = const_cast<uint8_t *>(buf); + + while (length > 0) { + out_size = AVCODEC_MAX_AUDIO_FRAME_SIZE; + #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(51, 29, 0) - len = avcodec_decode_audio( + len = avcodec_decode_audio(contextAudio, (short *)(&pcmbuf), &out_size, ptr, length); #else - len = avcodec_decode_audio2( + len = avcodec_decode_audio2(contextAudio, (short *)(&pcmbuf), &out_size, ptr, length); #endif - contextAudio, (short *)(&pcmbuf), &out_size, const_cast<uint8_t *>(buf), length); - - if (len < 0) { - esyslog("[dxr3-decoder] failed to decode audio"); - return; - } - // can this happen? - if ((length - len) > 0) { - esyslog("[dxr3-decoder] TODO: more to decode"); - } + if (len < 0) { + esyslog("[dxr3-decoder] failed to decode audio"); + return; + } - if (out_size) { - cFixedLengthFrame* pTempFrame = aBuf.Push(pcmbuf, - out_size, pts); - if (pTempFrame) { - // TODO: should we break out of the loop on push timeout? - pTempFrame->SetChannelCount(contextAudio->channels); - pTempFrame->SetSampleRate(contextAudio->sample_rate); + if (out_size) { + cFixedLengthFrame* pTempFrame = aBuf.Push(pcmbuf, + out_size, pts); + if (pTempFrame) { + pTempFrame->SetChannelCount(contextAudio->channels); + pTempFrame->SetSampleRate(contextAudio->sample_rate); + } } + + length -= len; + ptr += len; } } |