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

Commit 085dd093 authored by Yin-Chia Yeh's avatar Yin-Chia Yeh
Browse files

CameraNDK: prevent double closing session

Bug: 27102995
Change-Id: Ie3e9870d1fc1025cab7a1019ed7d056fe07536ad
parent 97d5e4eb
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -39,6 +39,15 @@ ACameraCaptureSession::~ACameraCaptureSession() {

void
ACameraCaptureSession::closeByApp() {
    {
        Mutex::Autolock _l(mSessionLock);
        if (mClosedByApp) {
            // Do not close twice
            return;
        }
        mClosedByApp = true;
    }

    sp<CameraDevice> dev = getDeviceSp();
    if (dev != nullptr) {
        dev->lockDeviceForSessionOps();
+1 −0
Original line number Diff line number Diff line
@@ -103,6 +103,7 @@ struct ACameraCaptureSession : public RefBase {
    const ACameraCaptureSession_stateCallbacks mUserSessionCallback;
    const wp<CameraDevice> mDevice;
    bool  mIsClosed = false;
    bool  mClosedByApp = false;
    bool  mIdle = true;
    Mutex mSessionLock;
};