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

Commit 676171da authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "audiopolicy: Remove global static initializers"

parents 27c20f48 80ae6b47
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -33,7 +33,10 @@

namespace android {

DeviceTypeSet APM_AUDIO_OUT_DEVICE_REMOTE_ALL = {AUDIO_DEVICE_OUT_REMOTE_SUBMIX};
static const DeviceTypeSet& getAllOutRemoteDevices() {
    static const DeviceTypeSet allOutRemoteDevices = {AUDIO_DEVICE_OUT_REMOTE_SUBMIX};
    return allOutRemoteDevices;
}

AudioOutputDescriptor::AudioOutputDescriptor(const sp<PolicyAudioPort>& policyAudioPort,
                                             AudioPolicyClientInterface *clientInterface)
@@ -681,7 +684,7 @@ bool SwAudioOutputCollection::isActiveLocally(VolumeSource volumeSource, uint32_
        const sp<SwAudioOutputDescriptor> outputDesc = this->valueAt(i);
        if (outputDesc->isActive(volumeSource, inPastMs, sysTime)
                && (!(outputDesc->devices()
                        .containsDeviceAmongTypes(APM_AUDIO_OUT_DEVICE_REMOTE_ALL)))) {
                        .containsDeviceAmongTypes(getAllOutRemoteDevices())))) {
            return true;
        }
    }
@@ -693,7 +696,7 @@ bool SwAudioOutputCollection::isActiveRemotely(VolumeSource volumeSource, uint32
    nsecs_t sysTime = systemTime();
    for (size_t i = 0; i < size(); i++) {
        const sp<SwAudioOutputDescriptor> outputDesc = valueAt(i);
        if (outputDesc->devices().containsDeviceAmongTypes(APM_AUDIO_OUT_DEVICE_REMOTE_ALL) &&
        if (outputDesc->devices().containsDeviceAmongTypes(getAllOutRemoteDevices()) &&
                outputDesc->isActive(volumeSource, inPastMs, sysTime)) {
            // do not consider re routing (when the output is going to a dynamic policy)
            // as "remote playback"
+17 −13
Original line number Diff line number Diff line
@@ -41,7 +41,8 @@ namespace audio_policy
{

struct legacy_strategy_map { const char *name; legacy_strategy id; };
static const std::vector<legacy_strategy_map> gLegacyStrategy = {
static const std::vector<legacy_strategy_map>& getLegacyStrategy() {
    static const std::vector<legacy_strategy_map> legacyStrategy = {
        { "STRATEGY_NONE", STRATEGY_NONE },
        { "STRATEGY_MEDIA", STRATEGY_MEDIA },
        { "STRATEGY_PHONE", STRATEGY_PHONE },
@@ -54,6 +55,8 @@ static const std::vector<legacy_strategy_map> gLegacyStrategy = {
        { "STRATEGY_REROUTING", STRATEGY_REROUTING },
        { "STRATEGY_PATCH", STRATEGY_REROUTING }, // boiler to manage stream patch volume
    };
    return legacyStrategy;
};

Engine::Engine()
{
@@ -62,7 +65,8 @@ Engine::Engine()
             "Policy Engine configuration is partially invalid, skipped %zu elements",
             result.nbSkippedElement);

    for (const auto &strategy : gLegacyStrategy) {
    auto legacyStrategy = getLegacyStrategy();
    for (const auto &strategy : legacyStrategy) {
        mLegacyStrategyMap[getProductStrategyByName(strategy.name)] = strategy.id;
    }
}