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

Commit 4db16c96 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "audiopolicy: Fix crash in getMsdPatches"

parents dadea624 86112351
Loading
Loading
Loading
Loading
+10 −10
Original line number Diff line number Diff line
@@ -1110,19 +1110,19 @@ audio_devices_t AudioPolicyManager::getMsdAudioOutDeviceTypes() const {

const AudioPatchCollection AudioPolicyManager::getMsdPatches() const {
    AudioPatchCollection msdPatches;
    audio_module_handle_t msdModuleHandle = mHwModules.getModuleFromName(
            AUDIO_HARDWARE_MODULE_ID_MSD)->getHandle();
    if (msdModuleHandle == AUDIO_MODULE_HANDLE_NONE) return msdPatches;
    sp<HwModule> msdModule = mHwModules.getModuleFromName(AUDIO_HARDWARE_MODULE_ID_MSD);
    if (msdModule != 0) {
        for (size_t i = 0; i < mAudioPatches.size(); ++i) {
            sp<AudioPatch> patch = mAudioPatches.valueAt(i);
            for (size_t j = 0; j < patch->mPatch.num_sources; ++j) {
                const struct audio_port_config *source = &patch->mPatch.sources[j];
                if (source->type == AUDIO_PORT_TYPE_DEVICE &&
                    source->ext.device.hw_module == msdModuleHandle) {
                        source->ext.device.hw_module == msdModule->getHandle()) {
                    msdPatches.addAudioPatch(patch->mHandle, patch);
                }
            }
        }
    }
    return msdPatches;
}