Skip to content

Commit

Permalink
VideoPlayer: drop FlipPage from RMs public interface
Browse files Browse the repository at this point in the history
  • Loading branch information
FernetMenta committed Jul 14, 2017
1 parent 82e43a2 commit acb36f2
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 58 deletions.
7 changes: 1 addition & 6 deletions xbmc/cores/RetroPlayer/RetroPlayerVideo.cpp
Expand Up @@ -208,14 +208,9 @@ void CRetroPlayerVideo::SendPicture(VideoPicture& picture)
{
std::atomic_bool bAbortOutput(false); //! @todo

int index = m_renderManager.AddVideoPicture(picture);
if (index < 0)
if (!m_renderManager.AddVideoPicture(picture, bAbortOutput, VS_INTERLACEMETHOD_NONE, false))
{
// Video device might not be done yet, drop the frame
m_droppedFrames++;
}
else
{
m_renderManager.FlipPage(bAbortOutput, 0.0, VS_INTERLACEMETHOD_NONE, FS_NONE, false);
}
}
35 changes: 6 additions & 29 deletions xbmc/cores/VideoPlayer/VideoPlayerVideo.cpp
Expand Up @@ -903,24 +903,8 @@ int CVideoPlayerVideo::OutputPicture(const VideoPicture* pPicture)
return result | EOS_DROPPED;
}

// set fieldsync if picture is interlaced
EINTERLACEMETHOD deintMethod = EINTERLACEMETHOD::VS_INTERLACEMETHOD_NONE;
EFIELDSYNC mDisplayField = FS_NONE;
if (pPicture->iFlags & DVP_FLAG_INTERLACED)
{
deintMethod = CMediaSettings::GetInstance().GetCurrentVideoSettings().m_InterlaceMethod;
if (!m_processInfo.Supports(deintMethod))
deintMethod = m_processInfo.GetDeinterlacingMethodDefault();
if (deintMethod != EINTERLACEMETHOD::VS_INTERLACEMETHOD_NONE)
{
if (pPicture->iFlags & DVP_FLAG_TOP_FIELD_FIRST)
mDisplayField = FS_TOP;
else
mDisplayField = FS_BOT;
}
}

int timeToDisplay = DVD_TIME_TO_MSEC(pPicture->pts - iPlayingClock);

// make sure waiting time is not negative
int maxWaitTime = std::min(std::max(timeToDisplay + 500, 50), 500);
// don't wait when going ff
Expand All @@ -935,24 +919,17 @@ int CVideoPlayerVideo::OutputPicture(const VideoPicture* pPicture)

ProcessOverlays(pPicture, pPicture->pts);

int index = m_renderManager.AddVideoPicture(*pPicture);

// video device might not be done yet
while (index < 0 && !m_bAbortOutput &&
m_pClock->GetAbsoluteClock(false) < iCurrentClock + DVD_MSEC_TO_TIME(500))
{
Sleep(1);
index = m_renderManager.AddVideoPicture(*pPicture);
}
EINTERLACEMETHOD deintMethod = EINTERLACEMETHOD::VS_INTERLACEMETHOD_NONE;
deintMethod = CMediaSettings::GetInstance().GetCurrentVideoSettings().m_InterlaceMethod;
if (!m_processInfo.Supports(deintMethod))
deintMethod = m_processInfo.GetDeinterlacingMethodDefault();

if (index < 0)
if (!m_renderManager.AddVideoPicture(*pPicture, m_bAbortOutput, deintMethod, (m_syncState == ESyncState::SYNC_STARTING)))
{
m_droppingStats.AddOutputDropGain(pPicture->pts, 1);
return EOS_DROPPED;
}

m_renderManager.FlipPage(m_bAbortOutput, pPicture->pts, deintMethod, mDisplayField, (m_syncState == ESyncState::SYNC_STARTING));

return result;
}

Expand Down
24 changes: 19 additions & 5 deletions xbmc/cores/VideoPlayer/VideoRenderers/RenderManager.cpp
Expand Up @@ -965,23 +965,37 @@ void CRenderManager::ToggleDebug()
m_debugTimer.SetExpired();
}

int CRenderManager::AddVideoPicture(const VideoPicture& pic)
bool CRenderManager::AddVideoPicture(const VideoPicture& picture, volatile std::atomic_bool& bStop, EINTERLACEMETHOD deintMethod, bool wait)
{
int index;
{
CSingleLock lock(m_presentlock);
if (m_free.empty())
return -1;
return false;
index = m_free.front();
}

CSingleLock lock(m_datalock);
if (!m_pRenderer)
return -1;
return false;

m_pRenderer->AddVideoPicture(pic, index, m_dvdClock.GetClock());
m_pRenderer->AddVideoPicture(picture, index, m_dvdClock.GetClock());

// set fieldsync if picture is interlaced
EFIELDSYNC displayField = FS_NONE;
if (picture.iFlags & DVP_FLAG_INTERLACED)
{
if (deintMethod != EINTERLACEMETHOD::VS_INTERLACEMETHOD_NONE)
{
if (picture.iFlags & DVP_FLAG_TOP_FIELD_FIRST)
displayField = FS_TOP;
else
displayField = FS_BOT;
}
}

return index;
FlipPage(bStop, picture.pts, deintMethod, displayField, wait);
return true;
}

void CRenderManager::AddOverlay(CDVDOverlay* o, double pts)
Expand Down
21 changes: 3 additions & 18 deletions xbmc/cores/VideoPlayer/VideoRenderers/RenderManager.h
Expand Up @@ -107,24 +107,7 @@ class CRenderManager
*/
bool Configure(const VideoPicture& picture, float fps, unsigned flags, unsigned int orientation, int buffers = 0);

int AddVideoPicture(const VideoPicture& picture);

/**
* Called by video player to flip render buffers
* If buffering is enabled this method does not block. In case of disabled buffering
* this method blocks waiting for the render thread to pass by.
* When buffering is used there might be no free buffer available after the call to
* this method. Player has to call WaitForBuffer. A free buffer will become
* available after the main thread has flipped front / back buffers.
*
* @param bStop reference to stop flag of calling thread
* @param timestamp of frame delivered with AddVideoPicture
* @param pts used for lateness detection
* @param method for deinterlacing
* @param sync signals frame, top, or bottom field
* @param wait: block until pic has been rendered
*/
void FlipPage(volatile std::atomic_bool& bStop, double pts, EINTERLACEMETHOD deintMethod, EFIELDSYNC sync, bool wait);
bool AddVideoPicture(const VideoPicture& picture, volatile std::atomic_bool& bStop, EINTERLACEMETHOD deintMethod, bool wait);

void AddOverlay(CDVDOverlay* o, double pts);

Expand Down Expand Up @@ -170,6 +153,8 @@ class CRenderManager
void UpdateDisplayLatency();
void CheckEnableClockSync();

void FlipPage(volatile std::atomic_bool& bStop, double pts, EINTERLACEMETHOD deintMethod, EFIELDSYNC sync, bool wait);

CBaseRenderer *m_pRenderer = nullptr;
OVERLAY::CRenderer m_overlays;
CDebugRenderer m_debugRenderer;
Expand Down

0 comments on commit acb36f2

Please sign in to comment.