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

Commit 88fe2622 authored by Jyoti Bhayana's avatar Jyoti Bhayana Committed by Android (Google) Code Review
Browse files

Merge "Fix the race condition around onIdle callback" into main

parents 260b99c8 ac9637d2
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -2676,6 +2676,7 @@ void CameraDeviceClient::onResultAvailable(const CaptureResult& result) {
}

void CameraDeviceClient::markClientActive() {
    Mutex::Autolock l(mDevice->mSharedDeviceActiveLock);
    if (mDeviceActive) {
        // Already in active state.
        return;
@@ -2689,6 +2690,7 @@ void CameraDeviceClient::markClientActive() {
}

void CameraDeviceClient::markClientIdle() {
    Mutex::Autolock l(mDevice->mSharedDeviceActiveLock);
    if (!mDeviceActive) {
        // Already in idle state.
        return;
+3 −0
Original line number Diff line number Diff line
@@ -594,6 +594,9 @@ class CameraDeviceBase : public virtual FrameProducer {
    virtual status_t injectSessionParams(
        const CameraMetadata& sessionParams) = 0;

    // Lock to synchronize onDeviceActive and onDeviceIdle callbacks when camera
    // has been opened in shared mode.
    mutable Mutex mSharedDeviceActiveLock;
protected:
    bool mImageDumpMask = 0;
    std::vector<int64_t> mStreamUseCaseOverrides;
+2 −0
Original line number Diff line number Diff line
@@ -591,6 +591,7 @@ void AidlCamera3SharedDevice::notifyError(
}

status_t AidlCamera3SharedDevice::notifyActive(float maxPreviewFps) {
    Mutex::Autolock l(mSharedDeviceActiveLock);
    for (auto activeClient : mClientRequestIds) {
        sp<NotificationListener> listener =  mClientListeners[activeClient.first].promote();
        if (listener != NULL) {
@@ -605,6 +606,7 @@ void AidlCamera3SharedDevice::notifyIdle(int64_t requestCount, int64_t resultEr
                                     bool deviceError,
                                     std::pair<int32_t, int32_t> mostRequestedFpsRange,
                                     const std::vector<hardware::CameraStreamStats>& stats) {
    Mutex::Autolock l(mSharedDeviceActiveLock);
    for (auto clientListener : mClientListeners) {
        sp<NotificationListener> listener =  clientListener.second.promote();
        if (listener != NULL) {