Skip to content

Commit

Permalink
VideoPlayer: fix race introduced by double caching av infos
Browse files Browse the repository at this point in the history
  • Loading branch information
FernetMenta authored and popcornmix committed Jan 26, 2016
1 parent 2493c8c commit a9785c8
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 11 deletions.
1 change: 1 addition & 0 deletions xbmc/cores/VideoPlayer/DVDMessage.h
Expand Up @@ -73,6 +73,7 @@ class CDVDMsg : public IDVDResourceCounted<CDVDMsg>
PLAYER_CHANNEL_SELECT_NUMBER, // switches to the channel with the provided channel number PLAYER_CHANNEL_SELECT_NUMBER, // switches to the channel with the provided channel number
PLAYER_CHANNEL_SELECT, // switches to the provided channel PLAYER_CHANNEL_SELECT, // switches to the provided channel
PLAYER_STARTED, // sent whenever a sub player has finished it's first frame after open PLAYER_STARTED, // sent whenever a sub player has finished it's first frame after open
PLAYER_AVCHANGE, // signal a change in audio or video parameters


// demuxer related messages // demuxer related messages


Expand Down
13 changes: 12 additions & 1 deletion xbmc/cores/VideoPlayer/VideoPlayer.cpp
Expand Up @@ -670,7 +670,7 @@ CVideoPlayer::CVideoPlayer(IPlayerCallback& callback)
m_CurrentTeletext(STREAM_TELETEXT, VideoPlayer_TELETEXT), m_CurrentTeletext(STREAM_TELETEXT, VideoPlayer_TELETEXT),
m_CurrentRadioRDS(STREAM_RADIO_RDS, VideoPlayer_RDS), m_CurrentRadioRDS(STREAM_RADIO_RDS, VideoPlayer_RDS),
m_messenger("player"), m_messenger("player"),
m_renderManager(m_clock), m_renderManager(m_clock, this),
m_ready(true) m_ready(true)
{ {
m_players_created = false; m_players_created = false;
Expand Down Expand Up @@ -2886,6 +2886,12 @@ void CVideoPlayer::HandleMessages()
if (((CDVDMsgGeneralSynchronize*)pMsg)->Wait(100, SYNCSOURCE_OWNER)) if (((CDVDMsgGeneralSynchronize*)pMsg)->Wait(100, SYNCSOURCE_OWNER))
CLog::Log(LOGDEBUG, "CVideoPlayer - CDVDMsg::GENERAL_SYNCHRONIZE"); CLog::Log(LOGDEBUG, "CVideoPlayer - CDVDMsg::GENERAL_SYNCHRONIZE");
} }
else if (pMsg->IsType(CDVDMsg::PLAYER_AVCHANGE))
{
UpdateStreamInfos();
g_dataCacheCore.SignalAudioInfoChange();
g_dataCacheCore.SignalVideoInfoChange();
}


pMsg->Release(); pMsg->Release();
} }
Expand Down Expand Up @@ -5035,6 +5041,11 @@ std::string CVideoPlayer::GetRenderVSyncState()
return m_renderManager.GetVSyncState(); return m_renderManager.GetVSyncState();
} }


void CVideoPlayer::VideoParamsChange()
{
m_messenger.Put(new CDVDMsg(CDVDMsg::PLAYER_AVCHANGE));
}

// IDispResource interface // IDispResource interface
void CVideoPlayer::OnLostDisplay() void CVideoPlayer::OnLostDisplay()
{ {
Expand Down
5 changes: 3 additions & 2 deletions xbmc/cores/VideoPlayer/VideoPlayer.h
Expand Up @@ -226,7 +226,7 @@ class CSelectionStreams
void Update (CDVDInputStream* input, CDVDDemux* demuxer, std::string filename2 = ""); void Update (CDVDInputStream* input, CDVDDemux* demuxer, std::string filename2 = "");
}; };


class CVideoPlayer : public IPlayer, public CThread, public IVideoPlayer, public IDispResource class CVideoPlayer : public IPlayer, public CThread, public IVideoPlayer, public IDispResource, public IRenderMsg
{ {
public: public:
CVideoPlayer(IPlayerCallback& callback); CVideoPlayer(IPlayerCallback& callback);
Expand Down Expand Up @@ -302,7 +302,6 @@ class CVideoPlayer : public IPlayer, public CThread, public IVideoPlayer, public
virtual int GetSourceBitrate(); virtual int GetSourceBitrate();
virtual bool GetStreamDetails(CStreamDetails &details); virtual bool GetStreamDetails(CStreamDetails &details);
virtual void GetAudioStreamInfo(int index, SPlayerAudioStreamInfo &info); virtual void GetAudioStreamInfo(int index, SPlayerAudioStreamInfo &info);
virtual void UpdateStreamInfos();


virtual std::string GetPlayerState(); virtual std::string GetPlayerState();
virtual bool SetPlayerState(const std::string& state); virtual bool SetPlayerState(const std::string& state);
Expand Down Expand Up @@ -361,6 +360,7 @@ class CVideoPlayer : public IPlayer, public CThread, public IVideoPlayer, public
virtual void OnStartup(); virtual void OnStartup();
virtual void OnExit(); virtual void OnExit();
virtual void Process(); virtual void Process();
virtual void VideoParamsChange() override;


void CreatePlayers(); void CreatePlayers();
void DestroyPlayers(); void DestroyPlayers();
Expand Down Expand Up @@ -435,6 +435,7 @@ class CVideoPlayer : public IPlayer, public CThread, public IVideoPlayer, public


void UpdateApplication(double timeout); void UpdateApplication(double timeout);
void UpdatePlayState(double timeout); void UpdatePlayState(double timeout);
void UpdateStreamInfos();


double m_UpdateApplication; double m_UpdateApplication;


Expand Down
5 changes: 2 additions & 3 deletions xbmc/cores/VideoPlayer/VideoPlayerAudio.cpp
Expand Up @@ -28,7 +28,6 @@
#include "utils/MathUtils.h" #include "utils/MathUtils.h"
#include "cores/AudioEngine/AEFactory.h" #include "cores/AudioEngine/AEFactory.h"
#include "cores/AudioEngine/Utils/AEUtil.h" #include "cores/AudioEngine/Utils/AEUtil.h"
#include "cores/DataCacheCore.h"
#ifdef TARGET_RASPBERRY_PI #ifdef TARGET_RASPBERRY_PI
#include "linux/RBP.h" #include "linux/RBP.h"
#endif #endif
Expand Down Expand Up @@ -162,7 +161,7 @@ void CVideoPlayerAudio::OpenStream(CDVDStreamInfo &hints, CDVDAudioCodec* codec)


m_maxspeedadjust = 5.0; m_maxspeedadjust = 5.0;


g_dataCacheCore.SignalAudioInfoChange(); m_messageParent.Put(new CDVDMsg(CDVDMsg::PLAYER_AVCHANGE));
m_syncState = IDVDStreamPlayer::SYNC_STARTING; m_syncState = IDVDStreamPlayer::SYNC_STARTING;
} }


Expand Down Expand Up @@ -451,7 +450,7 @@ void CVideoPlayerAudio::Process()


m_streaminfo.channels = audioframe.format.m_channelLayout.Count(); m_streaminfo.channels = audioframe.format.m_channelLayout.Count();


g_dataCacheCore.SignalAudioInfoChange(); m_messageParent.Put(new CDVDMsg(CDVDMsg::PLAYER_AVCHANGE));
} }


// Zero out the frame data if we are supposed to silence the audio // Zero out the frame data if we are supposed to silence the audio
Expand Down
8 changes: 4 additions & 4 deletions xbmc/cores/VideoPlayer/VideoRenderers/RenderManager.cpp
Expand Up @@ -33,7 +33,6 @@
#include "settings/MediaSettings.h" #include "settings/MediaSettings.h"
#include "settings/Settings.h" #include "settings/Settings.h"
#include "guilib/GUIFontManager.h" #include "guilib/GUIFontManager.h"
#include "cores/DataCacheCore.h"


#if defined(HAS_GL) #if defined(HAS_GL)
#include "LinuxRendererGL.h" #include "LinuxRendererGL.h"
Expand Down Expand Up @@ -117,7 +116,7 @@ static std::string GetRenderFormatName(ERenderFormat format)


unsigned int CRenderManager::m_nextCaptureId = 0; unsigned int CRenderManager::m_nextCaptureId = 0;


CRenderManager::CRenderManager(CDVDClock &clock) : m_dvdClock(clock) CRenderManager::CRenderManager(CDVDClock &clock, IRenderMsg *player) : m_dvdClock(clock)
{ {
m_pRenderer = nullptr; m_pRenderer = nullptr;
m_renderState = STATE_UNCONFIGURED; m_renderState = STATE_UNCONFIGURED;
Expand All @@ -137,6 +136,7 @@ CRenderManager::CRenderManager(CDVDClock &clock) : m_dvdClock(clock)
m_format = RENDER_FMT_NONE; m_format = RENDER_FMT_NONE;
m_renderedOverlay = false; m_renderedOverlay = false;
m_captureWaitCounter = 0; m_captureWaitCounter = 0;
m_playerPort = player;
} }


CRenderManager::~CRenderManager() CRenderManager::~CRenderManager()
Expand Down Expand Up @@ -901,7 +901,7 @@ void CRenderManager::SetViewMode(int iViewMode)
CSingleLock lock(m_statelock); CSingleLock lock(m_statelock);
if (m_pRenderer) if (m_pRenderer)
m_pRenderer->SetViewMode(iViewMode); m_pRenderer->SetViewMode(iViewMode);
g_dataCacheCore.SignalVideoInfoChange(); m_playerPort->VideoParamsChange();
} }


void CRenderManager::FlipPage(volatile bool& bStop, double timestamp /* = 0LL*/, double pts /* = 0 */, int source /*= -1*/, EFIELDSYNC sync /*= FS_NONE*/) void CRenderManager::FlipPage(volatile bool& bStop, double timestamp /* = 0LL*/, double pts /* = 0 */, int source /*= -1*/, EFIELDSYNC sync /*= FS_NONE*/)
Expand Down Expand Up @@ -1155,8 +1155,8 @@ void CRenderManager::UpdateResolution()
UpdateDisplayLatency(); UpdateDisplayLatency();
} }
m_bTriggerUpdateResolution = false; m_bTriggerUpdateResolution = false;
m_playerPort->VideoParamsChange();
} }
g_dataCacheCore.SignalVideoInfoChange();
} }
} }


Expand Down
11 changes: 10 additions & 1 deletion xbmc/cores/VideoPlayer/VideoRenderers/RenderManager.h
Expand Up @@ -49,11 +49,19 @@ class CMMALRenderer;
class CLinuxRenderer; class CLinuxRenderer;
class CLinuxRendererGL; class CLinuxRendererGL;
class CLinuxRendererGLES; class CLinuxRendererGLES;
class CRenderManager;

class IRenderMsg
{
friend CRenderManager;
protected:
virtual void VideoParamsChange() = 0;
};


class CRenderManager class CRenderManager
{ {
public: public:
CRenderManager(CDVDClock &clock); CRenderManager(CDVDClock &clock, IRenderMsg *player);
~CRenderManager(); ~CRenderManager();


// Functions called from render thread // Functions called from render thread
Expand Down Expand Up @@ -239,6 +247,7 @@ class CRenderManager
CEvent m_flushEvent; CEvent m_flushEvent;
double m_clock_framefinish; double m_clock_framefinish;
CDVDClock &m_dvdClock; CDVDClock &m_dvdClock;
IRenderMsg *m_playerPort;


void RenderCapture(CRenderCapture* capture); void RenderCapture(CRenderCapture* capture);
void RemoveCaptures(); void RemoveCaptures();
Expand Down

0 comments on commit a9785c8

Please sign in to comment.