All pastes #1878651 Raw Edit

anssi

public text v1 · immutable
#1878651 ·published 2010-06-07 20:18 UTC
rendered paste body
diff --git a/xbmc/cores/paplayer/CodecFactory.cpp b/xbmc/cores/paplayer/CodecFactory.cppindex 3bee90b..30652e5 100644--- a/xbmc/cores/paplayer/CodecFactory.cpp+++ b/xbmc/cores/paplayer/CodecFactory.cpp@@ -168,6 +168,13 @@ ICodec* CodecFactory::CreateCodecDemux(const CStdString& strFile, const CStdStri       return codec;     }     delete codec;+#else+    codec = new DVDPlayerCodec(CODEC_ID_DTS);+    if (codec->Init(strFile, filecache))+    {+      return codec;+    }+    delete codec; #endif #ifdef USE_LIBA52_DECODER     codec = new AC3Codec();@@ -176,9 +183,8 @@ ICodec* CodecFactory::CreateCodecDemux(const CStdString& strFile, const CStdStri       return codec;     }     delete codec;-#endif-#if !defined(USE_LIBDTS_DECODER) || !defined(USE_LIBA52_DECODER)-    codec = new DVDPlayerCodec();+#else+    codec = new DVDPlayerCodec(CODEC_ID_AC3);     if (codec->Init(strFile, filecache))     {       return codec;@@ -213,6 +219,13 @@ ICodec* CodecFactory::CreateCodecDemux(const CStdString& strFile, const CStdStri       return codec;     }     delete codec;+#else+    codec = new DVDPlayerCodec(CODEC_ID_DTS);+    if (codec->Init(strFile, filecache))+    {+      return codec;+    }+    delete codec; #endif #ifdef HAS_AC3_CDDA_CODEC     codec = new AC3CDDACodec();@@ -221,9 +234,8 @@ ICodec* CodecFactory::CreateCodecDemux(const CStdString& strFile, const CStdStri       return codec;     }     delete codec;-#endif-#if !defined(USE_LIBDTS_DECODER) || !defined(HAS_AC3_CDDA_CODEC)-    codec = new DVDPlayerCodec();+#else+    codec = new DVDPlayerCodec(CODEC_ID_AC3);     if (codec->Init(strFile, filecache))     {       return codec;diff --git a/xbmc/cores/paplayer/DVDPlayerCodec.cpp b/xbmc/cores/paplayer/DVDPlayerCodec.cppindex 9c4d494..1cdb19f 100644--- a/xbmc/cores/paplayer/DVDPlayerCodec.cpp+++ b/xbmc/cores/paplayer/DVDPlayerCodec.cpp@@ -31,7 +31,7 @@  #include "AudioDecoder.h" -DVDPlayerCodec::DVDPlayerCodec()+DVDPlayerCodec::DVDPlayerCodec(CodecID codec) {   m_CodecName = "DVDPlayer";   m_pDemuxer = NULL;@@ -41,6 +41,7 @@ DVDPlayerCodec::DVDPlayerCodec()   m_pPacket = NULL;   m_decoded = NULL;;   m_nDecodedLen = 0;+  m_codec = codec; }  DVDPlayerCodec::~DVDPlayerCodec()@@ -129,6 +130,13 @@ bool DVDPlayerCodec::Init(const CStdString &strFile, unsigned int filecache)   }    CDVDStreamInfo hint(*pStream, true);+  if (m_codec) {+    hint.codec = m_codec;+    hint.channels = 0;+    hint.samplerate = 0;+    hint.bitspersample = 0;+  }+   m_pAudioCodec = CDVDFactoryCodec::CreateAudioCodec(hint);   if (!m_pAudioCodec)   {@@ -142,11 +150,13 @@ bool DVDPlayerCodec::Init(const CStdString &strFile, unsigned int filecache)    // we have to decode initial data in order to get channels/samplerate   // for sanity - we read no more than 10 packets+  int nErrors = 0;   for (int nPacket=0; nPacket < 10 && (m_Channels == 0 || m_SampleRate == 0); nPacket++)   {     BYTE dummy[256];     int nSize = 256;-    ReadPCM(dummy, nSize, &nSize);+    if (ReadPCM(dummy, nSize, &nSize) == READ_ERROR)+      ++nErrors;      // We always ask ffmpeg to return s16le     m_BitsPerSample = m_pAudioCodec->GetBitsPerSample();@@ -154,6 +164,11 @@ bool DVDPlayerCodec::Init(const CStdString &strFile, unsigned int filecache)     m_Channels = m_pAudioCodec->GetChannels();    }+  if (nErrors >= 10)+  {+    CLog::Log(LOGDEBUG, "%s: Could not decode data", __FUNCTION__);+    return false;+  }    m_nDecodedLen = 0; diff --git a/xbmc/cores/paplayer/DVDPlayerCodec.h b/xbmc/cores/paplayer/DVDPlayerCodec.hindex f6d06a6..6055fbf 100644--- a/xbmc/cores/paplayer/DVDPlayerCodec.h+++ b/xbmc/cores/paplayer/DVDPlayerCodec.h@@ -32,7 +32,7 @@ class DVDPlayerCodec : public ICodec { public:-  DVDPlayerCodec();+  DVDPlayerCodec(CodecID codec = CODEC_ID_NONE);   virtual ~DVDPlayerCodec();    virtual bool Init(const CStdString &strFile, unsigned int filecache);@@ -58,6 +58,8 @@ private:    BYTE *m_decoded;   int  m_nDecodedLen;+  +  CodecID m_codec; };  #endif