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

Commit 45da66b9 authored by Mikhail Naganov's avatar Mikhail Naganov Committed by Gerrit Code Review
Browse files

Merge "APM: Avoid calling 'setOutputDevices' after adding output for HIDL" into main

parents 45063888 ccd149ce
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -137,6 +137,7 @@ private:
class HwModuleCollection : public Vector<sp<HwModule> >
{
public:
    sp<HwModule> getModuleFromHandle(audio_module_handle_t handle) const;
    sp<HwModule> getModuleFromName(const char *name) const;

    /**
+10 −0
Original line number Diff line number Diff line
@@ -283,6 +283,16 @@ void HwModule::dump(String8 *dst, int spaces) const
    dumpAudioRouteVector(mRoutes, dst, spaces);
}

sp<HwModule> HwModuleCollection::getModuleFromHandle(audio_module_handle_t handle) const
{
    for (const auto& module : *this) {
        if (module->getHandle() == handle) {
            return module;
        }
    }
    return nullptr;
}

sp <HwModule> HwModuleCollection::getModuleFromName(const char *name) const
{
    for (const auto& module : *this) {
+10 −10
Original line number Diff line number Diff line
@@ -1650,11 +1650,11 @@ status_t AudioPolicyManager::openDirectOutput(audio_stream_type_t stream,
    outputDesc->mDirectClientSession = session;

    addOutput(*output, outputDesc);
    setOutputDevices(__func__, outputDesc,
                     devices,
                     true,
                     0,
                     NULL);
    // The version check is essentially to avoid making this call in the case of the HIDL HAL.
    if (auto hwModule = mHwModules.getModuleFromHandle(mPrimaryModuleHandle); hwModule &&
            hwModule->getHalVersionMajor() >= 3) {
        setOutputDevices(__func__, outputDesc, devices, true, 0, NULL);
    }
    mPreviousOutputs = mOutputs;
    ALOGV("%s returns new direct output %d", __func__, *output);
    mpClientInterface->onAudioPortListUpdate();
@@ -8886,11 +8886,11 @@ sp<SwAudioOutputDescriptor> AudioPolicyManager::openOutputWithProfileAndDevice(
    }

    addOutput(output, desc);
    setOutputDevices(__func__, desc,
                     devices,
                     true,
                     0,
                     NULL);
    // The version check is essentially to avoid making this call in the case of the HIDL HAL.
    if (auto hwModule = mHwModules.getModuleFromHandle(mPrimaryModuleHandle); hwModule &&
            hwModule->getHalVersionMajor() >= 3) {
        setOutputDevices(__func__, desc, devices, true, 0, NULL);
    }
    sp<DeviceDescriptor> speaker = mAvailableOutputDevices.getDevice(
            AUDIO_DEVICE_OUT_SPEAKER, String8(""), AUDIO_FORMAT_DEFAULT);

+4 −1
Original line number Diff line number Diff line
@@ -498,6 +498,9 @@ INSTANTIATE_TEST_CASE_P(
void AudioPolicyManagerTestMsd::SetUpManagerConfig() {
    // TODO: Consider using Serializer to load part of the config from a string.
    ASSERT_NO_FATAL_FAILURE(AudioPolicyManagerTest::SetUpManagerConfig());
    mConfig->getHwModules().getModuleFromName(
            AUDIO_HARDWARE_MODULE_ID_PRIMARY)->setHalVersion(3, 0);

    mMsdOutputDevice = new DeviceDescriptor(AUDIO_DEVICE_OUT_BUS);
    sp<AudioProfile> pcmOutputProfile = new AudioProfile(
            AUDIO_FORMAT_PCM_16_BIT, AUDIO_CHANNEL_OUT_STEREO, k48000SamplingRate);
@@ -529,7 +532,7 @@ void AudioPolicyManagerTestMsd::SetUpManagerConfig() {
                addOutputProfile(spdifOutputProfile);
    }

    sp<HwModule> msdModule = new HwModule(AUDIO_HARDWARE_MODULE_ID_MSD, 2 /*halVersionMajor*/);
    sp<HwModule> msdModule = new HwModule(AUDIO_HARDWARE_MODULE_ID_MSD, 3 /*halVersionMajor*/);
    HwModuleCollection modules = mConfig->getHwModules();
    modules.add(msdModule);
    mConfig->setHwModules(modules);