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

Commit 4f1d4e92 authored by Eric Laurent's avatar Eric Laurent
Browse files

AudioFlinger: fix createEffect() for second client attached

The refactoring of AudioFlinger::createEffect() with AIDL (commit ce182940)
introduced a regression for the case where a second client
connects to an already existing effect.
In this case, the conventional return status of ALREADY_EXISTS is
interpreted as an error by the AIDL infrastructure and the response
data is dropped during the transaction causing the effect creation
to fail.

Test: atest audioeffect_tests:DefaultEffectTest#ManageSourceDefaultEffects

Change-Id: I858dd0ee2a200901ec229d4a5cabdf4a458ee88c
parent 2685aa09
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -128,6 +128,9 @@ status_t AudioEffect::set(const effect_uuid_t *type,
    mStatus = audioFlinger->createEffect(request, &response);

    if (mStatus == OK) {
        if (response.alreadyExists) {
            mStatus = ALREADY_EXISTS;
        }
        mId = response.id;
        enabled = response.enabled;
        iEffect = response.effect;
+1 −0
Original line number Diff line number Diff line
@@ -29,4 +29,5 @@ parcelable CreateEffectResponse {
    boolean enabled;
    @nullable IEffect effect;
    EffectDescriptor desc;
    boolean alreadyExists;
}
+6 −0
Original line number Diff line number Diff line
@@ -3990,6 +3990,12 @@ status_t AudioFlinger::createEffect(const media::CreateEffectRequest& request,

Register:
    if (!probe && (lStatus == NO_ERROR || lStatus == ALREADY_EXISTS)) {
        if (lStatus == ALREADY_EXISTS) {
            response->alreadyExists = true;
            lStatus = NO_ERROR;
        } else {
            response->alreadyExists = false;
        }
        // Check CPU and memory usage
        sp<EffectBase> effect = handle->effect().promote();
        if (effect != nullptr) {