Wait on the display link callback before rendering to reduce latency
This commit is contained in:
parent
6d3d51553b
commit
9790c218dc
1 changed files with 13 additions and 10 deletions
|
|
@ -158,6 +158,19 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
virtual void waitToRender() override
|
||||
{
|
||||
if (m_DisplayLink != nullptr) {
|
||||
// Vsync is enabled, so wait for a swap before returning
|
||||
SDL_LockMutex(m_VsyncMutex);
|
||||
if (SDL_CondWaitTimeout(m_VsyncPassed, m_VsyncMutex, 100) == SDL_MUTEX_TIMEDOUT) {
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"V-sync wait timed out after 100 ms");
|
||||
}
|
||||
SDL_UnlockMutex(m_VsyncMutex);
|
||||
}
|
||||
}
|
||||
|
||||
// Caller frees frame after we return
|
||||
virtual void renderFrame(AVFrame* frame) override
|
||||
{
|
||||
|
|
@ -230,16 +243,6 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
if (m_DisplayLink != nullptr) {
|
||||
// Vsync is enabled, so wait for a swap before returning
|
||||
SDL_LockMutex(m_VsyncMutex);
|
||||
if (SDL_CondWaitTimeout(m_VsyncPassed, m_VsyncMutex, 100) == SDL_MUTEX_TIMEDOUT) {
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"V-sync wait timed out after 100 ms");
|
||||
}
|
||||
SDL_UnlockMutex(m_VsyncMutex);
|
||||
}
|
||||
|
||||
// Queue this sample for the next v-sync
|
||||
CMSampleTimingInfo timingInfo = {
|
||||
.duration = kCMTimeInvalid,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue