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

Commit bab7bf46 authored by Haynes Mathew George's avatar Haynes Mathew George Committed by Eric Laurent
Browse files

audiopolicy: Synchronize calls to Effects state

Synchronize calls that might access Effects state (alternate approach)

Bug: 26516500

Change-Id: Ie03de9c67232e0ac7f5db5cbfe87ec058acbfc8e
parent b74dc56b
Loading
Loading
Loading
Loading
+5 −0
Original line number Original line Diff line number Diff line
@@ -497,6 +497,7 @@ status_t AudioPolicyService::registerEffect(const effect_descriptor_t *desc,
    if (mAudioPolicyManager == NULL) {
    if (mAudioPolicyManager == NULL) {
        return NO_INIT;
        return NO_INIT;
    }
    }
    Mutex::Autolock _l(mEffectsLock);
    return mAudioPolicyManager->registerEffect(desc, io, strategy, session, id);
    return mAudioPolicyManager->registerEffect(desc, io, strategy, session, id);
}
}


@@ -505,6 +506,7 @@ status_t AudioPolicyService::unregisterEffect(int id)
    if (mAudioPolicyManager == NULL) {
    if (mAudioPolicyManager == NULL) {
        return NO_INIT;
        return NO_INIT;
    }
    }
    Mutex::Autolock _l(mEffectsLock);
    return mAudioPolicyManager->unregisterEffect(id);
    return mAudioPolicyManager->unregisterEffect(id);
}
}


@@ -513,6 +515,7 @@ status_t AudioPolicyService::setEffectEnabled(int id, bool enabled)
    if (mAudioPolicyManager == NULL) {
    if (mAudioPolicyManager == NULL) {
        return NO_INIT;
        return NO_INIT;
    }
    }
    Mutex::Autolock _l(mEffectsLock);
    return mAudioPolicyManager->setEffectEnabled(id, enabled);
    return mAudioPolicyManager->setEffectEnabled(id, enabled);
}
}


@@ -577,6 +580,8 @@ bool AudioPolicyService::isOffloadSupported(const audio_offload_info_t& info)
        return false;
        return false;
    }
    }
    Mutex::Autolock _l(mLock);
    Mutex::Autolock _l(mLock);
    Mutex::Autolock _le(mEffectsLock); // isOffloadSupported queries for
                                      // non-offloadable effects
    return mAudioPolicyManager->isOffloadSupported(info);
    return mAudioPolicyManager->isOffloadSupported(info);
}
}


+4 −0
Original line number Original line Diff line number Diff line
@@ -553,6 +553,10 @@ private:


    mutable Mutex mLock;    // prevents concurrent access to AudioPolicy manager functions changing
    mutable Mutex mLock;    // prevents concurrent access to AudioPolicy manager functions changing
                            // device connection state  or routing
                            // device connection state  or routing
    mutable Mutex mEffectsLock; // serialize access to Effect state within APM.
    // Note: lock acquisition order is always mLock > mEffectsLock:
    // mLock protects AudioPolicyManager methods that can call into audio flinger
    // and possibly back in to audio policy service and acquire mEffectsLock.
    sp<AudioCommandThread> mAudioCommandThread;     // audio commands thread
    sp<AudioCommandThread> mAudioCommandThread;     // audio commands thread
    sp<AudioCommandThread> mTonePlaybackThread;     // tone playback thread
    sp<AudioCommandThread> mTonePlaybackThread;     // tone playback thread
    sp<AudioCommandThread> mOutputCommandThread;    // process stop and release output
    sp<AudioCommandThread> mOutputCommandThread;    // process stop and release output