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

Commit b6d596e2 authored by haobo10173529's avatar haobo10173529 Committed by android-build-merger
Browse files

Merge "AudioFlinger: Fix deadlock when createEffect_l fails."

am: 39a4c1fd

Change-Id: Id9360b9cfc7aad6c3b00723eb205b62a226a06b0
parents e2bfe7ff 39a4c1fd
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -3041,16 +3041,21 @@ sp<IEffect> AudioFlinger::createEffect(
        bool pinned = (sessionId > AUDIO_SESSION_OUTPUT_MIX) && isSessionAcquired_l(sessionId);
        handle = thread->createEffect_l(client, effectClient, priority, sessionId,
                &desc, enabled, &lStatus, pinned);
        if (handle != 0 && id != NULL) {
            *id = handle->id();
        }
        if (handle == 0) {
        if (lStatus != NO_ERROR && lStatus != ALREADY_EXISTS) {
            // remove local strong reference to Client with mClientLock held
            Mutex::Autolock _cl(mClientLock);
            client.clear();
        } else {
            // handle must be valid here, but check again to be safe.
            if (handle.get() != nullptr && id != nullptr) *id = handle->id();
        }
    }

    if (lStatus != NO_ERROR && lStatus != ALREADY_EXISTS) {
        // handle must be cleared outside lock.
        handle.clear();
    }

Exit:
    *status = lStatus;
    return handle;
+1 −1
Original line number Diff line number Diff line
@@ -1354,7 +1354,7 @@ Exit:
        if (chainCreated) {
            removeEffectChain_l(chain);
        }
        handle.clear();
        // handle must be cleared by caller to avoid deadlock.
    }

    *status = lStatus;