From: <ar...@us...> - 2010-12-29 09:37:07
|
Revision: 30766 http://xbmc4xbox.svn.sourceforge.net/xbmc4xbox/?rev=30766&view=rev Author: arnova Date: 2010-12-29 09:37:00 +0000 (Wed, 29 Dec 2010) Log Message: ----------- merged: xbmc mainline/trunk revisions 35747,35612,35640,35641 (dvdplayer updates/fixes) Modified Paths: -------------- trunk/xbmc/cores/dvdplayer/DVDMessage.cpp trunk/xbmc/cores/dvdplayer/DVDMessage.h trunk/xbmc/cores/dvdplayer/DVDPlayer.cpp trunk/xbmc/cores/dvdplayer/DVDPlayerAudio.cpp trunk/xbmc/cores/dvdplayer/DVDPlayerAudio.h trunk/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp trunk/xbmc/cores/dvdplayer/DVDPlayerVideo.h Modified: trunk/xbmc/cores/dvdplayer/DVDMessage.cpp =================================================================== --- trunk/xbmc/cores/dvdplayer/DVDMessage.cpp 2010-12-29 09:18:34 UTC (rev 30765) +++ trunk/xbmc/cores/dvdplayer/DVDMessage.cpp 2010-12-29 09:37:00 UTC (rev 30766) @@ -24,22 +24,7 @@ #include "DVDDemuxers/DVDDemuxUtils.h" #include "DVDStreamInfo.h" -/** - * CDVDMsgGeneralStreamChange --- GENERAL_STREAMCHANGE - */ -CDVDMsgGeneralStreamChange::CDVDMsgGeneralStreamChange(CDVDStreamInfo* pInfo) : CDVDMsg(GENERAL_STREAMCHANGE) -{ - m_pInfo = pInfo; -} -CDVDMsgGeneralStreamChange::~CDVDMsgGeneralStreamChange() -{ - if (m_pInfo) - { - delete m_pInfo; - } -} - /** * CDVDMsgGeneralSynchronize --- GENERAL_SYNCRONIZR */ Modified: trunk/xbmc/cores/dvdplayer/DVDMessage.h =================================================================== --- trunk/xbmc/cores/dvdplayer/DVDMessage.h 2010-12-29 09:18:34 UTC (rev 30765) +++ trunk/xbmc/cores/dvdplayer/DVDMessage.h 2010-12-29 09:37:00 UTC (rev 30766) @@ -164,17 +164,6 @@ bool m_clock; }; -class CDVDStreamInfo; -class CDVDMsgGeneralStreamChange : public CDVDMsg -{ -public: - CDVDMsgGeneralStreamChange(CDVDStreamInfo* pInfo); - virtual ~CDVDMsgGeneralStreamChange(); - CDVDStreamInfo* GetStreamInfo() { return m_pInfo; } -private: - CDVDStreamInfo* m_pInfo; -}; - #define SYNCSOURCE_AUDIO 0x00000001 #define SYNCSOURCE_VIDEO 0x00000002 #define SYNCSOURCE_SUB 0x00000004 Modified: trunk/xbmc/cores/dvdplayer/DVDPlayer.cpp =================================================================== --- trunk/xbmc/cores/dvdplayer/DVDPlayer.cpp 2010-12-29 09:18:34 UTC (rev 30765) +++ trunk/xbmc/cores/dvdplayer/DVDPlayer.cpp 2010-12-29 09:37:00 UTC (rev 30766) @@ -2088,6 +2088,15 @@ } __int64 time = GetTime(); + if(g_application.CurrentFileItem().IsStack() + && (seek > GetTotalTimeInMsec() || seek < 0)) + { + g_application.SeekTime((seek - time) * 0.001 + g_application.GetTime()); + // warning, don't access any dvdplayer variables here as + // the dvdplayer object may have been destroyed + return; + } + m_messenger.Put(new CDVDMsgPlayerSeek((int)seek, !bPlus, true, false, restore)); SynchronizeDemuxer(100); if (seek < 0) seek = 0; @@ -2363,12 +2372,6 @@ if(m_CurrentAudio.id < 0 || m_CurrentAudio.hint != hint) { - if(m_CurrentAudio.id >= 0) - { - CLog::Log(LOGDEBUG, " - codecs hints have changed, must close previous stream"); - CloseAudioStream(true); - } - if (!m_dvdPlayerAudio.OpenStream( hint )) { /* mark stream as disabled, to disallaw further attempts*/ @@ -2420,12 +2423,6 @@ if(m_CurrentVideo.id < 0 || m_CurrentVideo.hint != hint) { - if(m_CurrentVideo.id >= 0) - { - CLog::Log(LOGDEBUG, " - codecs hints have changed, must close previous stream"); - CloseVideoStream(true); - } - if (!m_dvdPlayerVideo.OpenStream(hint)) { /* mark stream as disabled, to disallaw further attempts */ Modified: trunk/xbmc/cores/dvdplayer/DVDPlayerAudio.cpp =================================================================== --- trunk/xbmc/cores/dvdplayer/DVDPlayerAudio.cpp 2010-12-29 09:18:34 UTC (rev 30765) +++ trunk/xbmc/cores/dvdplayer/DVDPlayerAudio.cpp 2010-12-29 09:37:00 UTC (rev 30766) @@ -124,6 +124,24 @@ return DVD_NOPTS_VALUE; } + +class CDVDMsgAudioCodecChange : public CDVDMsg +{ +public: + CDVDMsgAudioCodecChange(const CDVDStreamInfo &hints, CDVDAudioCodec* codec) + : CDVDMsg(GENERAL_STREAMCHANGE) + , m_codec(codec) + , m_hints(hints) + {} + ~CDVDMsgAudioCodecChange() + { + delete m_codec; + } + CDVDAudioCodec* m_codec; + CDVDStreamInfo m_hints; +}; + + CDVDPlayerAudio::CDVDPlayerAudio(CDVDClock* pClock, CDVDMessageQueue& parent) : CThread() , m_messageQueue("audio") @@ -160,21 +178,42 @@ bool CDVDPlayerAudio::OpenStream( CDVDStreamInfo &hints ) { - // should alway's be NULL!!!!, it will probably crash anyway when deleting m_pAudioCodec here. - if (m_pAudioCodec) + + CLog::Log(LOGNOTICE, "Finding audio codec for: %i", hints.codec); + CDVDAudioCodec* codec = CDVDFactoryCodec::CreateAudioCodec(hints); + if( !codec ) { - CLog::Log(LOGFATAL, "CDVDPlayerAudio::OpenStream() m_pAudioCodec != NULL"); + CLog::Log(LOGERROR, "Unsupported audio codec"); return false; } - /* try to open decoder without probing, we could actually allow us to continue here */ - if( !OpenDecoder(hints) ) return false; + if(m_messageQueue.IsInited()) + m_messageQueue.Put(new CDVDMsgAudioCodecChange(hints, codec), 0); + else + { + OpenStream(hints, codec); + m_messageQueue.Init(); + CLog::Log(LOGNOTICE, "Creating audio thread"); + Create(); + } + return true; +} - m_messageQueue.Init(); +void CDVDPlayerAudio::OpenStream( CDVDStreamInfo &hints, CDVDAudioCodec* codec ) +{ + SAFE_DELETE(m_pAudioCodec); + m_pAudioCodec = codec; + /* store our stream hints */ + m_streaminfo = hints; + + /* update codec information from what codec gave ut */ + m_streaminfo.channels = m_pAudioCodec->GetChannels(); + m_streaminfo.samplerate = m_pAudioCodec->GetSampleRate(); + m_droptime = 0; m_audioClock = 0; - m_stalled = true; + m_stalled = m_messageQueue.GetPacketCount(CDVDMsg::DEMUXER_PACKET) == 0; m_started = false; m_error = 0; @@ -182,10 +221,7 @@ m_errorcount = 0; m_syncclock = true; m_errortime = CurrentHostCounter(); - CLog::Log(LOGNOTICE, "Creating audio thread"); - Create(); - return true; } void CDVDPlayerAudio::CloseStream(bool bWaitForBuffers) @@ -226,36 +262,6 @@ m_ptsOutput.Flush(); } -bool CDVDPlayerAudio::OpenDecoder(CDVDStreamInfo &hints, BYTE* buffer /* = NULL*/, unsigned int size /* = 0*/) -{ - /* close current audio codec */ - if( m_pAudioCodec ) - { - CLog::Log(LOGNOTICE, "Deleting audio codec"); - m_pAudioCodec->Dispose(); - SAFE_DELETE(m_pAudioCodec); - } - - /* store our stream hints */ - m_streaminfo = hints; - - CLog::Log(LOGNOTICE, "Finding audio codec for: %i", m_streaminfo.codec); - m_pAudioCodec = CDVDFactoryCodec::CreateAudioCodec( m_streaminfo ); - if( !m_pAudioCodec ) - { - CLog::Log(LOGERROR, "Unsupported audio codec"); - - m_streaminfo.Clear(); - return false; - } - - /* update codec information from what codec gave ut */ - m_streaminfo.channels = m_pAudioCodec->GetChannels(); - m_streaminfo.samplerate = m_pAudioCodec->GetSampleRate(); - - return true; -} - // decode one audio frame and returns its uncompressed size int CDVDPlayerAudio::DecodeFrame(DVDAudioFrame &audioframe, bool bDropPacket) { @@ -366,17 +372,6 @@ m_decode.Attach((CDVDMsgDemuxerPacket*)pMsg); m_ptsInput.Add( m_decode.size, m_decode.dts ); } - else if (pMsg->IsType(CDVDMsg::GENERAL_STREAMCHANGE)) - { - CDVDMsgGeneralStreamChange* pMsgStreamChange = (CDVDMsgGeneralStreamChange*)pMsg; - CDVDStreamInfo* hints = pMsgStreamChange->GetStreamInfo(); - - /* received a stream change, reopen codec. */ - /* we should really not do this until first packet arrives, to have a probe buffer */ - - /* try to open decoder, if none is found keep consuming packets */ - OpenDecoder( *hints ); - } else if (pMsg->IsType(CDVDMsg::GENERAL_SYNCHRONIZE)) { ((CDVDMsgGeneralSynchronize*)pMsg)->Wait( &m_bStop, SYNCSOURCE_AUDIO ); @@ -457,6 +452,13 @@ else m_dvdAudio.Resume(); } + else if (pMsg->IsType(CDVDMsg::GENERAL_STREAMCHANGE)) + { + CDVDMsgAudioCodecChange* msg(static_cast<CDVDMsgAudioCodecChange*>(pMsg)); + OpenStream(msg->m_hints, msg->m_codec); + msg->m_codec = NULL; + } + pMsg->Release(); } return 0; Modified: trunk/xbmc/cores/dvdplayer/DVDPlayerAudio.h =================================================================== --- trunk/xbmc/cores/dvdplayer/DVDPlayerAudio.h 2010-12-29 09:18:34 UTC (rev 30765) +++ trunk/xbmc/cores/dvdplayer/DVDPlayerAudio.h 2010-12-29 09:37:00 UTC (rev 30766) @@ -92,6 +92,7 @@ void UnRegisterAudioCallback() { m_dvdAudio.UnRegisterAudioCallback(); } bool OpenStream(CDVDStreamInfo &hints); + void OpenStream(CDVDStreamInfo &hints, CDVDAudioCodec* codec); void CloseStream(bool bWaitForBuffers); void SetSpeed(int speed); @@ -127,9 +128,6 @@ int DecodeFrame(DVDAudioFrame &audioframe, bool bDropPacket); - // tries to open a decoder for the given data. - bool OpenDecoder(CDVDStreamInfo &hint, BYTE* buffer = NULL, unsigned int size = 0); - double m_audioClock; // data for audio decoding Modified: trunk/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp =================================================================== --- trunk/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp 2010-12-29 09:18:34 UTC (rev 30765) +++ trunk/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp 2010-12-29 09:37:00 UTC (rev 30766) @@ -41,6 +41,23 @@ using namespace std; +class CDVDMsgVideoCodecChange : public CDVDMsg +{ +public: + CDVDMsgVideoCodecChange(const CDVDStreamInfo &hints, CDVDVideoCodec* codec) + : CDVDMsg(GENERAL_STREAMCHANGE) + , m_codec(codec) + , m_hints(hints) + {} + ~CDVDMsgVideoCodecChange() + { + delete m_codec; + } + CDVDVideoCodec* m_codec; + CDVDStreamInfo m_hints; +}; + + CDVDPlayerVideo::CDVDPlayerVideo( CDVDClock* pClock , CDVDOverlayContainer* pOverlayContainer , CDVDMessageQueue& parent) @@ -107,7 +124,29 @@ bool CDVDPlayerVideo::OpenStream( CDVDStreamInfo &hint ) { + CLog::Log(LOGNOTICE, "Creating video codec with codec id: %i", hint.codec); + CDVDVideoCodec* codec = CDVDFactoryCodec::CreateVideoCodec( hint ); + if(!codec) + { + CLog::Log(LOGERROR, "Unsupported video codec"); + return false; + } + if(m_messageQueue.IsInited()) + m_messageQueue.Put(new CDVDMsgVideoCodecChange(hint, codec), 0); + else + { + OpenStream(hint, codec); + CLog::Log(LOGNOTICE, "Creating video thread"); + m_messageQueue.Init(); + Create(); + } + return true; +} + +void CDVDPlayerVideo::OpenStream(CDVDStreamInfo &hint, CDVDVideoCodec* codec) +{ + //reported fps is usually not completely correct if (hint.fpsrate && hint.fpsscale) { m_fFrameRate = (float)hint.fpsrate / hint.fpsscale; @@ -135,33 +174,14 @@ // use aspect in stream if available m_fForcedAspectRatio = hint.aspect; - // should alway's be NULL!!!!, it will probably crash anyway when deleting m_pVideoCodec here. if (m_pVideoCodec) - { - CLog::Log(LOGFATAL, "CDVDPlayerVideo::OpenStream() m_pVideoCodec != NULL"); - return false; - } + delete m_pVideoCodec; - CLog::Log(LOGNOTICE, "Creating video codec with codec id: %i", hint.codec); - m_pVideoCodec = CDVDFactoryCodec::CreateVideoCodec( hint ); - - if( !m_pVideoCodec ) - { - CLog::Log(LOGERROR, "Unsupported video codec"); - return false; - } - + m_pVideoCodec = codec; m_hints = hint; - m_stalled = false; + m_stalled = m_messageQueue.GetPacketCount(CDVDMsg::DEMUXER_PACKET) == 0; m_started = false; m_codecname = m_pVideoCodec->GetName(); - - m_messageQueue.Init(); - - CLog::Log(LOGNOTICE, "Creating video thread"); - Create(); - - return true; } void CDVDPlayerVideo::CloseStream(bool bWaitForBuffers) @@ -356,6 +376,12 @@ if(m_started) m_messageParent.Put(new CDVDMsgInt(CDVDMsg::PLAYER_STARTED, DVDPLAYER_VIDEO)); } + else if (pMsg->IsType(CDVDMsg::GENERAL_STREAMCHANGE)) + { + CDVDMsgVideoCodecChange* msg(static_cast<CDVDMsgVideoCodecChange*>(pMsg)); + OpenStream(msg->m_hints, msg->m_codec); + msg->m_codec = NULL; + } if (pMsg->IsType(CDVDMsg::DEMUXER_PACKET)) { Modified: trunk/xbmc/cores/dvdplayer/DVDPlayerVideo.h =================================================================== --- trunk/xbmc/cores/dvdplayer/DVDPlayerVideo.h 2010-12-29 09:18:34 UTC (rev 30765) +++ trunk/xbmc/cores/dvdplayer/DVDPlayerVideo.h 2010-12-29 09:37:00 UTC (rev 30766) @@ -46,6 +46,7 @@ virtual ~CDVDPlayerVideo(); bool OpenStream(CDVDStreamInfo &hint); + void OpenStream(CDVDStreamInfo &hint, CDVDVideoCodec* codec); void CloseStream(bool bWaitForBuffers); void StepFrame(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |