diff options
author | anssih <anssih@svn> | 2010-08-26 22:30:44 +0000 |
---|---|---|
committer | anssih <anssih@svn> | 2010-08-26 22:30:44 +0000 |
commit | 82230a7108cee6d26c6f102ecde595dbadf06a73 (patch) | |
tree | ba646214a187d67640a20dd96550224760a09b81 | |
parent | 6fab01d64654f8c5294cfe748f4283255dd0e4d1 (diff) |
fixed: playback of files with invalid packets in DVDPlayerCodec of paplayer
For example, a dts stream may contain garbage in the beginning, or there
may simply be a corrupted packet. dvdplayer codecs assume the caller
retries if necessary, while paplayer codec failures are assumed to be
fatal.
Therefore, retry with the next packet in case of a decoding failure.
(cherry picked from commit 8236fc14e1b0dee9ab19c6620a86c6dc4eb50ca3)
git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/branches/Dharma@33191 568bbfeb-2a22-0410-94d2-cc84cf5bfa90
-rw-r--r-- | xbmc/cores/paplayer/DVDPlayerCodec.cpp | 42 |
1 files changed, 26 insertions, 16 deletions
diff --git a/xbmc/cores/paplayer/DVDPlayerCodec.cpp b/xbmc/cores/paplayer/DVDPlayerCodec.cpp index 6903527c11..106ee39231 100644 --- a/xbmc/cores/paplayer/DVDPlayerCodec.cpp +++ b/xbmc/cores/paplayer/DVDPlayerCodec.cpp @@ -236,28 +236,38 @@ int DVDPlayerCodec::ReadPCM(BYTE *pBuffer, int size, int *actualsize) m_decoded = NULL; m_nDecodedLen = 0; - if (m_pPacket && m_audioPos >= m_pPacket->iSize) + // dvdplayer returns a read error on a single invalid packet, while + // in paplayer READ_ERROR is a fatal error. + // Therefore skip over invalid packets here. + int decodeLen = -1; + for (int tries = 0; decodeLen < 0 && tries < 2; ++tries) { - CDVDDemuxUtils::FreeDemuxPacket(m_pPacket); - m_audioPos = 0; - m_pPacket = NULL; - } - - if (m_pPacket == NULL) - { - do + if (m_pPacket && m_audioPos >= m_pPacket->iSize) { - m_pPacket = m_pDemuxer->Read(); - } while (m_pPacket && m_pPacket->iStreamId != m_nAudioStream); + CDVDDemuxUtils::FreeDemuxPacket(m_pPacket); + m_audioPos = 0; + m_pPacket = NULL; + } - if (!m_pPacket) + if (m_pPacket == NULL) { - return READ_EOF; + do + { + m_pPacket = m_pDemuxer->Read(); + } while (m_pPacket && m_pPacket->iStreamId != m_nAudioStream); + + if (!m_pPacket) + { + return READ_EOF; + } + m_audioPos = 0; } - m_audioPos = 0; - } - int decodeLen = m_pAudioCodec->Decode(m_pPacket->pData + m_audioPos, m_pPacket->iSize - m_audioPos); + decodeLen = m_pAudioCodec->Decode(m_pPacket->pData + m_audioPos, m_pPacket->iSize - m_audioPos); + + if (decodeLen < 0) + m_audioPos = m_pPacket->iSize; // skip packet + } if (decodeLen < 0) { |