From 4f74fd53549dd4247034ea7c7fef4602e3411955 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Tue, 21 May 2019 09:09:16 -0700 Subject: [PATCH] Fix uninitialized variables and a race condition with CVDisplayLinkStart() --- app/streaming/video/ffmpeg-renderers/vt.mm | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/streaming/video/ffmpeg-renderers/vt.mm b/app/streaming/video/ffmpeg-renderers/vt.mm index 609669bc..ce7490d9 100644 --- a/app/streaming/video/ffmpeg-renderers/vt.mm +++ b/app/streaming/video/ffmpeg-renderers/vt.mm @@ -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; }