Correct mistakes in CameraManager::Open and CameraManager::Close

This commit is contained in:
capitalistspz 2025-03-24 11:19:49 +00:00
parent 154eacd85c
commit 062ac500e4

View file

@ -56,12 +56,13 @@ bool CameraManager::Open(bool weak)
m_stream = stream; m_stream = stream;
m_captureThread = std::thread(&CameraManager::CaptureWorker, this); m_captureThread = std::thread(&CameraManager::CaptureWorker, this);
} }
else if (!weak) if (!weak)
m_refCount += 1; m_refCount += 1;
return true; return true;
} }
void CameraManager::Close() void CameraManager::Close()
{ {
{
std::scoped_lock lock(m_mutex); std::scoped_lock lock(m_mutex);
if (m_refCount == 0) if (m_refCount == 0)
return; return;
@ -71,6 +72,7 @@ void CameraManager::Close()
Cap_closeStream(m_ctx, *m_stream); Cap_closeStream(m_ctx, *m_stream);
m_stream = std::nullopt; m_stream = std::nullopt;
m_capturing = false; m_capturing = false;
}
m_captureThread.join(); m_captureThread.join();
} }