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

Commit 502db1c0 authored by Mikhail Naganov's avatar Mikhail Naganov Committed by Automerger Merge Worker
Browse files

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

Merge "APM: Avoid calling 'setOutputDevices' after adding output for HIDL" into main am: 45da66b9 am: c7f7db11

Original change: https://android-review.googlesource.com/c/platform/frameworks/av/+/3285181



Change-Id: Ie94ac7b5b5dc5d8c05b97cc331f4f0e544d8b346
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 9200d56f c7f7db11
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
@@ -1704,11 +1704,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();
@@ -9062,11 +9062,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
@@ -500,6 +500,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);
@@ -531,7 +534,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);