From b12d4934b7d3fed75d1255793893070768636555 Mon Sep 17 00:00:00 2001 From: Oleksandr Tyshchenko Date: Sat, 19 Jun 2021 20:50:51 +0300 Subject: [PATCH] CameraHandler: Do not call streamStop() with lock held The problem is that streamStop() needs to wait for eventThread to finish which in turn might hold the same lock if there is a work to do, see CommandHandler::onFrameDoneCallback() for details. If the streamStop() *must* be protected by the lock, we need either consider dropping the lock from onFrameDoneCallback() or terminate eventThread forcely. Signed-off-by: Oleksandr Tyshchenko --- src/CameraHandler.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/CameraHandler.cpp b/src/CameraHandler.cpp index d083fdf..0dfd485 100644 --- a/src/CameraHandler.cpp +++ b/src/CameraHandler.cpp @@ -456,14 +456,16 @@ void CameraHandler::streamStop(domid_t domId, const xencamera_req& aReq, return; } - std::lock_guard lock(mLock); + std::unique_lock lock(mLock); DLOG(mLog, DEBUG) << "Handle command [STREAM STOP] dom " << std::to_string(domId); mStreamingNow.erase(domId); - if (!mStreamingNow.size()) + if (!mStreamingNow.size()) { + lock.unlock(); mCamera->streamStop(); + } } void CameraHandler::release()