Fix uninitialized variables and a race condition with CVDisplayLinkStart()

This commit is contained in:
Cameron Gutman
2019-05-21 09:09:16 -07:00
parent 3df9a5d01c
commit 4f74fd5354

View File

@@ -23,7 +23,9 @@ public:
m_DisplayLayer(nullptr),
m_FormatDesc(nullptr),
m_StreamView(nullptr),
m_DisplayLink(nullptr)
m_DisplayLink(nullptr),
m_VsyncMutex(nullptr),
m_VsyncPassed(nullptr)
{
SDL_zero(m_OverlayTextFields);
}
@@ -118,6 +120,11 @@ public:
return false;
}
// The CVDisplayLink callback uses these, so we must initialize them before
// starting the callbacks.
m_VsyncMutex = SDL_CreateMutex();
m_VsyncPassed = SDL_CreateCond();
status = CVDisplayLinkStart(m_DisplayLink);
if (status != kCVReturnSuccess) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
@@ -126,9 +133,6 @@ public:
return false;
}
m_VsyncMutex = SDL_CreateMutex();
m_VsyncPassed = SDL_CreateCond();
return true;
}