Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 828363da authored by Igor Murashkin's avatar Igor Murashkin Committed by Android (Google) Code Review
Browse files

Merge "camera2: Don't race while dumping last frame metadata" into klp-dev

parents a676e96c 215bb349
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -66,7 +66,14 @@ status_t FrameProcessorBase::removeListener(int32_t minId,
void FrameProcessorBase::dump(int fd, const Vector<String16>& /*args*/) {
    String8 result("    Latest received frame:\n");
    write(fd, result.string(), result.size());
    mLastFrame.dump(fd, 2, 6);

    CameraMetadata lastFrame;
    {
        // Don't race while dumping metadata
        Mutex::Autolock al(mLastFrameMutex);
        lastFrame = CameraMetadata(mLastFrame);
    }
    lastFrame.dump(fd, 2, 6);
}

bool FrameProcessorBase::threadLoop() {
@@ -113,6 +120,7 @@ void FrameProcessorBase::processNewFrames(const sp<CameraDeviceBase> &device) {
        }

        if (!frame.isEmpty()) {
            Mutex::Autolock al(mLastFrameMutex);
            mLastFrame.acquire(frame);
        }
    }
+1 −0
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ class FrameProcessorBase: public Thread {
    virtual bool threadLoop();

    Mutex mInputMutex;
    Mutex mLastFrameMutex;

    struct RangeListener {
        int32_t minId;