Skip to content

Commit

Permalink
Merge pull request #10144 from popcornmix/vsyncslop
Browse files Browse the repository at this point in the history
mmalrender: Allow a frame of slop when waiting for vsync
  • Loading branch information
popcornmix committed Jul 20, 2016
2 parents d3258c0 + 2c19d48 commit 29db2f8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ CMMALRenderer::CMMALRenderer() : CThread("MMALRenderer")
m_inflight = 0;
m_queue = nullptr;
m_error = 0.0;
m_vsync_count = ~0U;
}

CMMALRenderer::~CMMALRenderer()
Expand Down Expand Up @@ -464,7 +465,15 @@ void CMMALRenderer::RenderUpdate(bool clear, DWORD flags, DWORD alpha)

exit:
lock.Leave();
g_RBP.WaitVsync();
uint32_t v = g_RBP.WaitVsync(m_vsync_count);
// allow a frame of slop
if (m_vsync_count == ~0U || !(v == m_vsync_count))
{
CLog::Log(LOGDEBUG, "%s::%s - vsync %d (+%d)", CLASSNAME, __func__, m_vsync_count, v - m_vsync_count);
m_vsync_count = v + 1;
}
else
m_vsync_count++;
}

void CMMALRenderer::FlipPage(int source)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ class CMMALRenderer : public CBaseRenderer, public CThread
double m_error;

bool init_vout(ERenderFormat format, AVPixelFormat pixfmt, bool opaque);
uint32_t m_vsync_count;
void ReleaseBuffers();
void UnInitMMAL();
};
2 changes: 1 addition & 1 deletion xbmc/linux/RBP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ uint32_t CRBP::WaitVsync(uint32_t target)
if (!m_vsync_cond.wait(vlock, delay.MillisLeft()))
break;
}
if (m_vsync_count < target)
if ((signed)(m_vsync_count - target) < 0)
CLog::Log(LOGDEBUG, "CRBP::%s no vsync %d/%d display:%x(%x) delay:%d", __FUNCTION__, m_vsync_count, target, m_display, display, delay.MillisLeft());

return m_vsync_count;
Expand Down

0 comments on commit 29db2f8

Please sign in to comment.