From a5f63c3ae339bb8977c76f5df97adc7a61d56b3b Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Wed, 26 Oct 2016 23:31:18 -0700 Subject: [PATCH] SourceImpl::GetNextFrame(): Avoid spurious wakeups. --- src/SourceImpl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SourceImpl.cpp b/src/SourceImpl.cpp index 106960120f..bbeb8f24b1 100644 --- a/src/SourceImpl.cpp +++ b/src/SourceImpl.cpp @@ -56,8 +56,8 @@ Frame SourceImpl::GetCurFrame() { Frame SourceImpl::GetNextFrame() { std::unique_lock lock{m_frameMutex}; - // TODO: handle spurious wakeup by comparing frame timestamps - m_frameCv.wait(lock); + auto oldTime = m_frame.time(); + m_frameCv.wait(lock, [=] { return m_frame.time() != oldTime; }); return m_frame; }