input/camera_api: fix coverity issue 83/317483/2
authorInki Dae <inki.dae@samsung.com>
Wed, 11 Sep 2024 01:56:47 +0000 (10:56 +0900)
committerInki Dae <inki.dae@samsung.com>
Wed, 11 Sep 2024 03:58:47 +0000 (12:58 +0900)
Fix coverity issue - CID 1789471 - Waiting while holding the lock by unlocking
just after the completion of _capture_event.wait_for().

Change-Id: Ia2cb4f9878f57c030273a62d2aadaf30d38e70fe
Signed-off-by: Inki Dae <inki.dae@samsung.com>
input/backends/camera_api/include/CameraApiBackend.h
input/backends/camera_api/src/CameraApiBackend.cpp

index 159a9b6a96e4ba6c6f6fe22b9c8e98259a8a450f..5e73758e172154f92c56b023c73a4ceca4d633ed 100644 (file)
@@ -88,7 +88,10 @@ private:
        static void captureCompletedCb(void *user_data);
        static bool previewFpsCb(camera_attr_fps_e fps, void *user_data);
        static bool compareSizesDescending(const cv::Size &a, const cv::Size &b);
-       std::mutex &getMutex() { return _capture_mutex; }
+       std::mutex &getMutex()
+       {
+               return _capture_mutex;
+       }
 
 public:
        CameraApiBackend();
index 0bee899f793c47070f4fb6f5fc29c7c8d29223e1..69c354b3c1d24d8bc8fe58e43d9975469ea7be4a 100644 (file)
@@ -344,6 +344,8 @@ void CameraApiBackend::capture(BaseDataType &out_data)
        if (!event_ret)
                throw InvalidOperation("Camera device not working");
 
+       lock.unlock();
+
        auto &image_data = dynamic_cast<ImageDataType &>(out_data);
 
        image_data.width = _cvCaptureImage.cols;