Permalink
Browse files

VideoPlayer: fix race introduced by double caching av infos

  • Loading branch information...
FernetMenta authored and popcornmix committed Jan 22, 2016
1 parent 2493c8c commit a9785c822a1153d1c98f86e2ae26314f5ecc7857
@@ -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, // switches to the provided channel
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
@@ -670,7 +670,7 @@ CVideoPlayer::CVideoPlayer(IPlayerCallback& callback)
m_CurrentTeletext(STREAM_TELETEXT, VideoPlayer_TELETEXT),
m_CurrentRadioRDS(STREAM_RADIO_RDS, VideoPlayer_RDS),
m_messenger("player"),
m_renderManager(m_clock),
m_renderManager(m_clock, this),
m_ready(true)
{
m_players_created = false;
@@ -2886,6 +2886,12 @@ void CVideoPlayer::HandleMessages()
if (((CDVDMsgGeneralSynchronize*)pMsg)->Wait(100, SYNCSOURCE_OWNER))
CLog::Log(LOGDEBUG, "CVideoPlayer - CDVDMsg::GENERAL_SYNCHRONIZE");
}
else if (pMsg->IsType(CDVDMsg::PLAYER_AVCHANGE))
{
UpdateStreamInfos();
g_dataCacheCore.SignalAudioInfoChange();
g_dataCacheCore.SignalVideoInfoChange();
}
pMsg->Release();
}
@@ -5035,6 +5041,11 @@ std::string CVideoPlayer::GetRenderVSyncState()
return m_renderManager.GetVSyncState();
}
void CVideoPlayer::VideoParamsChange()
{
m_messenger.Put(new CDVDMsg(CDVDMsg::PLAYER_AVCHANGE));
}
// IDispResource interface
void CVideoPlayer::OnLostDisplay()
{
@@ -226,7 +226,7 @@ class CSelectionStreams
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:
CVideoPlayer(IPlayerCallback& callback);
@@ -302,7 +302,6 @@ class CVideoPlayer : public IPlayer, public CThread, public IVideoPlayer, public
virtual int GetSourceBitrate();
virtual bool GetStreamDetails(CStreamDetails &details);
virtual void GetAudioStreamInfo(int index, SPlayerAudioStreamInfo &info);
virtual void UpdateStreamInfos();
virtual std::string GetPlayerState();
virtual bool SetPlayerState(const std::string& state);
@@ -361,6 +360,7 @@ class CVideoPlayer : public IPlayer, public CThread, public IVideoPlayer, public
virtual void OnStartup();
virtual void OnExit();
virtual void Process();
virtual void VideoParamsChange() override;
void CreatePlayers();
void DestroyPlayers();
@@ -435,6 +435,7 @@ class CVideoPlayer : public IPlayer, public CThread, public IVideoPlayer, public
void UpdateApplication(double timeout);
void UpdatePlayState(double timeout);
void UpdateStreamInfos();
double m_UpdateApplication;
@@ -28,7 +28,6 @@
#include "utils/MathUtils.h"
#include "cores/AudioEngine/AEFactory.h"
#include "cores/AudioEngine/Utils/AEUtil.h"
#include "cores/DataCacheCore.h"
#ifdef TARGET_RASPBERRY_PI
#include "linux/RBP.h"
#endif
@@ -162,7 +161,7 @@ void CVideoPlayerAudio::OpenStream(CDVDStreamInfo &hints, CDVDAudioCodec* codec)
m_maxspeedadjust = 5.0;
g_dataCacheCore.SignalAudioInfoChange();
m_messageParent.Put(new CDVDMsg(CDVDMsg::PLAYER_AVCHANGE));
m_syncState = IDVDStreamPlayer::SYNC_STARTING;
}
@@ -451,7 +450,7 @@ void CVideoPlayerAudio::Process()
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
@@ -33,7 +33,6 @@
#include "settings/MediaSettings.h"
#include "settings/Settings.h"
#include "guilib/GUIFontManager.h"
#include "cores/DataCacheCore.h"
#if defined(HAS_GL)
#include "LinuxRendererGL.h"
@@ -117,7 +116,7 @@ static std::string GetRenderFormatName(ERenderFormat format)
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_renderState = STATE_UNCONFIGURED;
@@ -137,6 +136,7 @@ CRenderManager::CRenderManager(CDVDClock &clock) : m_dvdClock(clock)
m_format = RENDER_FMT_NONE;
m_renderedOverlay = false;
m_captureWaitCounter = 0;
m_playerPort = player;
}
CRenderManager::~CRenderManager()
@@ -901,7 +901,7 @@ void CRenderManager::SetViewMode(int iViewMode)
CSingleLock lock(m_statelock);
if (m_pRenderer)
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*/)
@@ -1155,8 +1155,8 @@ void CRenderManager::UpdateResolution()
UpdateDisplayLatency();
}
m_bTriggerUpdateResolution = false;
m_playerPort->VideoParamsChange();
}
g_dataCacheCore.SignalVideoInfoChange();
}
}
@@ -49,11 +49,19 @@ class CMMALRenderer;
class CLinuxRenderer;
class CLinuxRendererGL;
class CLinuxRendererGLES;
class CRenderManager;
class IRenderMsg
{
friend CRenderManager;
protected:
virtual void VideoParamsChange() = 0;
};
class CRenderManager
{
public:
CRenderManager(CDVDClock &clock);
CRenderManager(CDVDClock &clock, IRenderMsg *player);
~CRenderManager();
// Functions called from render thread
@@ -239,6 +247,7 @@ class CRenderManager
CEvent m_flushEvent;
double m_clock_framefinish;
CDVDClock &m_dvdClock;
IRenderMsg *m_playerPort;
void RenderCapture(CRenderCapture* capture);
void RemoveCaptures();

0 comments on commit a9785c8

Please sign in to comment.