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

Commit 73bdf575 authored by Mikhail Naganov's avatar Mikhail Naganov
Browse files

libaudiohal: Use IDevice::updateAudioPatch in V6

Use new method IDevice::updateAudioPatch when the patch handle
passed to DeviceHalHidl::createAudioPatch is not "NONE" instead
of releasing and re-creating the patch.

Bug: 79248321
Test: audio "smoke" test on coral
Change-Id: Ifa37d828eb7817105d14d6451ed6121e9d6bb48f
parent b7a56c52
Loading
Loading
Loading
Loading
+30 −10
Original line number Original line Diff line number Diff line
@@ -319,17 +319,23 @@ status_t DeviceHalHidl::createAudioPatch(
    if (mDevice == 0) return NO_INIT;
    if (mDevice == 0) return NO_INIT;
    if (patch == nullptr) return BAD_VALUE;
    if (patch == nullptr) return BAD_VALUE;


#if MAJOR_VERSION < 6
    if (*patch != AUDIO_PATCH_HANDLE_NONE) {
    if (*patch != AUDIO_PATCH_HANDLE_NONE) {
        status_t status = releaseAudioPatch(*patch);
        status_t status = releaseAudioPatch(*patch);
        ALOGW_IF(status != NO_ERROR, "%s error %d releasing patch handle %d",
        ALOGW_IF(status != NO_ERROR, "%s error %d releasing patch handle %d",
            __func__, status, *patch);
            __func__, status, *patch);
        *patch = AUDIO_PATCH_HANDLE_NONE;
    }
    }
#endif


    hidl_vec<AudioPortConfig> hidlSources, hidlSinks;
    hidl_vec<AudioPortConfig> hidlSources, hidlSinks;
    HidlUtils::audioPortConfigsFromHal(num_sources, sources, &hidlSources);
    HidlUtils::audioPortConfigsFromHal(num_sources, sources, &hidlSources);
    HidlUtils::audioPortConfigsFromHal(num_sinks, sinks, &hidlSinks);
    HidlUtils::audioPortConfigsFromHal(num_sinks, sinks, &hidlSinks);
    Result retval;
    Result retval = Result::OK;
    Return<void> ret = mDevice->createAudioPatch(
    Return<void> ret;
    std::string methodName = "createAudioPatch";
    if (*patch == AUDIO_PATCH_HANDLE_NONE) {  // always true for MAJOR_VERSION < 6
        ret = mDevice->createAudioPatch(
                hidlSources, hidlSinks,
                hidlSources, hidlSinks,
                [&](Result r, AudioPatchHandle hidlPatch) {
                [&](Result r, AudioPatchHandle hidlPatch) {
                    retval = r;
                    retval = r;
@@ -337,7 +343,21 @@ status_t DeviceHalHidl::createAudioPatch(
                        *patch = static_cast<audio_patch_handle_t>(hidlPatch);
                        *patch = static_cast<audio_patch_handle_t>(hidlPatch);
                    }
                    }
                });
                });
    return processReturn("createAudioPatch", ret, retval);
    } else {
#if MAJOR_VERSION >= 6
        ret = mDevice->updateAudioPatch(
                *patch,
                hidlSources, hidlSinks,
                [&](Result r, AudioPatchHandle hidlPatch) {
                    retval = r;
                    if (retval == Result::OK) {
                        *patch = static_cast<audio_patch_handle_t>(hidlPatch);
                    }
                });
        methodName = "updateAudioPatch";
#endif
    }
    return processReturn(methodName.c_str(), ret, retval);
}
}


status_t DeviceHalHidl::releaseAudioPatch(audio_patch_handle_t patch) {
status_t DeviceHalHidl::releaseAudioPatch(audio_patch_handle_t patch) {