From 0b632afcdbb99779f7aa8ebafb06d77ccc102587 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Wed, 17 Feb 2021 00:33:39 -0800 Subject: [PATCH] Windows: Reduce camera state locks. It only needs a lock on shutdown. --- Windows/CaptureDevice.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Windows/CaptureDevice.cpp b/Windows/CaptureDevice.cpp index b1c34f7c55..f28d99b7b1 100644 --- a/Windows/CaptureDevice.cpp +++ b/Windows/CaptureDevice.cpp @@ -837,7 +837,6 @@ void WindowsCaptureDevice::sendMessage(CAPTUREDEVIDE_MESSAGE message) { // Must be unique lock std::unique_lock lock(mutex); messageQueue.push(message); - lock.unlock(); cond.notify_one(); } @@ -848,15 +847,16 @@ CAPTUREDEVIDE_MESSAGE WindowsCaptureDevice::getMessage() { cond.wait(lock, [this]() { return !messageQueue.empty(); }); message = messageQueue.front(); messageQueue.pop(); - lock.unlock(); return message; } void WindowsCaptureDevice::updateState(const CAPTUREDEVIDE_STATE &newState) { - std::unique_lock guard(stateMutex_); state = newState; - stateCond_.notify_all(); + if (isShutDown()) { + std::unique_lock guard(stateMutex_); + stateCond_.notify_all(); + } } void WindowsCaptureDevice::waitShutDown() {