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

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

Merge "libaudiohal: Use IDevice::updateAudioPatch in V6"

parents 1e994a5d 73bdf575
Loading
Loading
Loading
Loading
+30 −10
Original line number Original line Diff line number Diff line
@@ -323,17 +323,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;
@@ -341,7 +347,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) {