diff options
author | Christian Gmeiner <christian.gmeiner@gmail.com> | 2009-05-28 13:16:07 +0200 |
---|---|---|
committer | Christian Gmeiner <christian.gmeiner@gmail.com> | 2009-05-28 13:16:07 +0200 |
commit | 754e1a074274bc69bf462092b7356c1bb9273dc7 (patch) | |
tree | 8d962cc4ab25bd5357e238ea9ddfbb46256b8352 | |
parent | ef7363670fbe079eaaaa72749e3309922019370a (diff) | |
download | vdr-plugin-dxr3-754e1a074274bc69bf462092b7356c1bb9273dc7.tar.gz vdr-plugin-dxr3-754e1a074274bc69bf462092b7356c1bb9273dc7.tar.bz2 |
simplify Decode
if somebody sees TODO's in the logfile, please contact me
-rw-r--r-- | dxr3audiodecoder.c | 57 |
1 files changed, 20 insertions, 37 deletions
diff --git a/dxr3audiodecoder.c b/dxr3audiodecoder.c index a9dda79..11bd066 100644 --- a/dxr3audiodecoder.c +++ b/dxr3audiodecoder.c @@ -102,11 +102,6 @@ void cDxr3AudioDecoder::Decode(cDxr3PesFrame *frame, uint32_t pts, cDxr3SyncBuff int len; int out_size = AVCODEC_MAX_AUDIO_FRAME_SIZE; - enum audioException - { - WRONG_LENGTH, - }; - const uint8_t *buf = frame->GetPayload(); int length = frame->GetPayloadLength(); @@ -140,43 +135,31 @@ void cDxr3AudioDecoder::Decode(cDxr3PesFrame *frame, uint32_t pts, cDxr3SyncBuff } } - try { - while (length > 0 && decodeAudio) { #if LIBAVCODEC_VERSION_INT < ((51<<16)+(29<<8)+0) - len = avcodec_decode_audio( + len = avcodec_decode_audio( #else - len = avcodec_decode_audio2( + len = avcodec_decode_audio2( #endif - contextAudio, (short *)(&pcmbuf), &out_size, - const_cast<uint8_t *>(buf), length); - if (len < 0 || out_size < 0) - throw WRONG_LENGTH; - - 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); - } - } - length -= len; - buf += len; - } - } catch (audioException ex) { - switch (ex) { - case WRONG_LENGTH: - esyslog("dxr3: audiodecoder: wrong length"); - break; + contextAudio, (short *)(&pcmbuf), &out_size, const_cast<uint8_t *>(buf), length); - default: - esyslog("dxr3: audiodecoder: unexpected exception"); - break; - } + 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"); + } - esyslog("dxr3: audiodecoder: skipping %d broken data bytes", length); - Init(); + 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); + } } } |