diff options
author | Mikhail Naganov <mnaganov@google.com> | 2019-12-11 12:36:26 -0800 |
---|---|---|
committer | Mikhail Naganov <mnaganov@google.com> | 2019-12-13 19:28:37 -0800 |
commit | 6c070ca4e89c4d5d044153d05bc53f9339b36f3c (patch) | |
tree | f159215b275ae94f7969284f6ea201be37ea6dff /audio/core/all-versions/default/Device.cpp | |
parent | c13049c6c336058c580cff4e6fbef7c00ae3a35f (diff) |
audio: Add IDevice::updateAudioPatch method
Add method 'updateAudioPatch' which should be used when
an existing patch needs to be updated with new routing.
Use of this method allows audio HAL to avoid disrupting
audio stream while changing routing.
Bug: 79248321
Test: atest VtsHalAudioV6_0TargetTest
Change-Id: I6c87f67fa4f2463ba9e8f0272a3232f5c9c55714
Diffstat (limited to 'audio/core/all-versions/default/Device.cpp')
-rw-r--r-- | audio/core/all-versions/default/Device.cpp | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/audio/core/all-versions/default/Device.cpp b/audio/core/all-versions/default/Device.cpp index ad841caf2e..47e31c1801 100644 --- a/audio/core/all-versions/default/Device.cpp +++ b/audio/core/all-versions/default/Device.cpp @@ -269,12 +269,21 @@ Return<bool> Device::supportsAudioPatches() { Return<void> Device::createAudioPatch(const hidl_vec<AudioPortConfig>& sources, const hidl_vec<AudioPortConfig>& sinks, createAudioPatch_cb _hidl_cb) { + auto [retval, patch] = createOrUpdateAudioPatch( + static_cast<AudioPatchHandle>(AudioHandleConsts::AUDIO_PATCH_HANDLE_NONE), sources, + sinks); + _hidl_cb(retval, patch); + return Void(); +} + +std::tuple<Result, AudioPatchHandle> Device::createOrUpdateAudioPatch( + AudioPatchHandle patch, const hidl_vec<AudioPortConfig>& sources, + const hidl_vec<AudioPortConfig>& sinks) { Result retval(Result::NOT_SUPPORTED); - AudioPatchHandle patch = 0; if (version() >= AUDIO_DEVICE_API_VERSION_3_0) { std::unique_ptr<audio_port_config[]> halSources(HidlUtils::audioPortConfigsToHal(sources)); std::unique_ptr<audio_port_config[]> halSinks(HidlUtils::audioPortConfigsToHal(sinks)); - audio_patch_handle_t halPatch = AUDIO_PATCH_HANDLE_NONE; + audio_patch_handle_t halPatch = static_cast<audio_patch_handle_t>(patch); retval = analyzeStatus("create_audio_patch", mDevice->create_audio_patch(mDevice, sources.size(), &halSources[0], sinks.size(), &halSinks[0], &halPatch)); @@ -282,8 +291,7 @@ Return<void> Device::createAudioPatch(const hidl_vec<AudioPortConfig>& sources, patch = static_cast<AudioPatchHandle>(halPatch); } } - _hidl_cb(retval, patch); - return Void(); + return {retval, patch}; } Return<Result> Device::releaseAudioPatch(int32_t patch) { @@ -438,6 +446,19 @@ Return<Result> Device::removeDeviceEffect(AudioPortHandle device, uint64_t effec } } +Return<void> Device::updateAudioPatch(int32_t previousPatch, + const hidl_vec<AudioPortConfig>& sources, + const hidl_vec<AudioPortConfig>& sinks, + createAudioPatch_cb _hidl_cb) { + if (previousPatch != static_cast<int32_t>(AudioHandleConsts::AUDIO_PATCH_HANDLE_NONE)) { + auto [retval, patch] = createOrUpdateAudioPatch(previousPatch, sources, sinks); + _hidl_cb(retval, patch); + } else { + _hidl_cb(Result::INVALID_ARGUMENTS, previousPatch); + } + return Void(); +} + #endif } // namespace implementation |