Loading media/libaudiohal/impl/DeviceHalHidl.cpp +30 −10 Original line number Original line Diff line number Diff line Loading @@ -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; Loading @@ -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) { Loading Loading
media/libaudiohal/impl/DeviceHalHidl.cpp +30 −10 Original line number Original line Diff line number Diff line Loading @@ -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; Loading @@ -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) { Loading