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

Commit fedb5986 authored by Aniket Kumar Lata's avatar Aniket Kumar Lata Committed by Eric Laurent
Browse files

audiopolicy: add null pointer check for primary hw



When sound card detection fails, primary HW cannot be opened.
add null pointer check to avoid further crashes in audioserver.

Bug: 136060200
Test: make
authored-by: default avatarWeiyin Jiang <wjiang@codeaurora.org>
Change-Id: Ief07a36ca8aed0e6013d533bd0aa66e122e3070c
parent ba810b88
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -472,6 +472,10 @@ status_t AudioPolicyManager::getHwOffloadEncodingFormatsSupportedForA2DP(
    std::unordered_set<audio_format_t> formatSet;
    sp<HwModule> primaryModule =
            mHwModules.getModuleFromName(AUDIO_HARDWARE_MODULE_ID_PRIMARY);
    if (primaryModule == nullptr) {
        ALOGE("%s() unable to get primary module", __func__);
        return NO_INIT;
    }
    DeviceVector declaredDevices = primaryModule->getDeclaredDevices().getDevicesFromTypeMask(
            AUDIO_DEVICE_OUT_ALL_A2DP);
    for (const auto& device : declaredDevices) {