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

Commit 163ce833 authored by François Gaffie's avatar François Gaffie Committed by Shunkai Yao
Browse files

audio effect: fix registration of default device effects



Bug: 268441977
Test: dumpsys media.audio_policy shows registered default device
effect(s)
dumpsys media.audio_flinger shows enabled / registered default device
effect(s).

Device effects are initialized asynchronously when audio policy service
is created. During the initialization, these effects will register to
audio policy service. However, the service is declared available only at
the late init.
It leads to erratic registration of default device effects.

Change-Id: Ia6e2c4f05ef600ab1e47d78505e5cae9df5c525d
Signed-off-by: default avatarFrançois Gaffie <francois.gaffie@renault.com>
parent 0f66058e
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -512,11 +512,12 @@ NO_THREAD_SAFETY_ANALYSIS // conditional try lock
    if (!locked) {
        result.append("\t\tCould not lock Fx mutex:\n");
    }

    result.append("\t\tSession State Registered Enabled Suspended:\n");
    result.appendFormat("\t\t%05d   %03d   %s          %s       %s\n",
            mSessionId, mState, mPolicyRegistered ? "y" : "n",
            mPolicyEnabled ? "y" : "n", mSuspended ? "y" : "n");
    bool isInternal = isInternal_l();
    result.append("\t\tSession State Registered Internal Enabled Suspended:\n");
    result.appendFormat("\t\t%05d   %03d   %s          %s        %s       %s\n",
            mSessionId, mState, mPolicyRegistered ? "y" : "n", isInternal ? "y" : "n",
            ((isInternal && isEnabled()) || (!isInternal && mPolicyEnabled)) ? "y" : "n",
            mSuspended ? "y" : "n");

    result.append("\t\tDescriptor:\n");
    char uuidStr[64];
+6 −4
Original line number Diff line number Diff line
@@ -44,10 +44,7 @@ using content::AttributionSourceState;
AudioPolicyEffects::AudioPolicyEffects(const sp<EffectsFactoryHalInterface>& effectsFactoryHal) {
    // load xml config with effectsFactoryHal
    status_t loadResult = loadAudioEffectConfig(effectsFactoryHal);
    if (loadResult == NO_ERROR) {
        mDefaultDeviceEffectFuture =
                std::async(std::launch::async, &AudioPolicyEffects::initDefaultDeviceEffects, this);
    } else if (loadResult < 0) {
    if (loadResult < 0) {
        ALOGW("Failed to query effect configuration, fallback to load .conf");
        // load automatic audio effect modules
        if (access(AUDIO_EFFECT_VENDOR_CONFIG_FILE, R_OK) == 0) {
@@ -60,6 +57,11 @@ AudioPolicyEffects::AudioPolicyEffects(const sp<EffectsFactoryHalInterface>& eff
    }
}

void AudioPolicyEffects::setDefaultDeviceEffects() {
    mDefaultDeviceEffectFuture = std::async(
                std::launch::async, &AudioPolicyEffects::initDefaultDeviceEffects, this);
}

AudioPolicyEffects::~AudioPolicyEffects()
{
    size_t i = 0;
+2 −0
Original line number Diff line number Diff line
@@ -117,6 +117,8 @@ public:
    // Remove the default stream effect from wherever it's attached.
    status_t removeStreamDefaultEffect(audio_unique_id_t id);

    void setDefaultDeviceEffects();

private:
    void initDefaultDeviceEffects();

+3 −0
Original line number Diff line number Diff line
@@ -305,6 +305,9 @@ void AudioPolicyService::onFirstRef()
        }
    }
    AudioSystem::audioPolicyReady();
    // AudioFlinger will handle effect creation and register these effects on audio_policy
    // service. Hence, audio_policy service must be ready.
    audioPolicyEffects->setDefaultDeviceEffects();
}

void AudioPolicyService::unloadAudioPolicyManager()