diff options
author | Mikhail Naganov <mnaganov@google.com> | 2019-11-14 13:57:15 -0800 |
---|---|---|
committer | Mikhail Naganov <mnaganov@google.com> | 2019-11-18 11:39:26 -0800 |
commit | 7623ed9258081a20a530e6b052121966e1f1f55e (patch) | |
tree | 75249a48dcadb192eb8045b6af0e0ffca506c694 /audio/core/all-versions/default/Device.cpp | |
parent | 81c40d7f81340f0ff9bed49006b89f0d9dd8a9f3 (diff) |
Audio V6 wrapper: IDevice|IStream|IEffect.close releases HAL resource
Fixed behavior of IStream|IEffect.close to release the underlying
HAL resource synchronously. This is to avoid adding artificial
delays in VTS that become totally unpractical in V6.
Added clarification about expected client behavior for
IStream|IEffect.close w.r.t. audio data transfer.
Added IDevice.close method which releases HAL device resource.
Updated VTS tests to remove delays in V6.
Bug: 114451103
Bug: 141989952
Test: atest VtsHalAudioV6_0TargetTest
Change-Id: I439f0f923c091af2ab234d15ca847cfade341f25
Diffstat (limited to 'audio/core/all-versions/default/Device.cpp')
-rw-r--r-- | audio/core/all-versions/default/Device.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/audio/core/all-versions/default/Device.cpp b/audio/core/all-versions/default/Device.cpp index 1a9df217e1..5ea4c8df59 100644 --- a/audio/core/all-versions/default/Device.cpp +++ b/audio/core/all-versions/default/Device.cpp @@ -39,11 +39,10 @@ namespace implementation { using ::android::hardware::audio::common::CPP_VERSION::implementation::HidlUtils; -Device::Device(audio_hw_device_t* device) : mDevice(device) {} +Device::Device(audio_hw_device_t* device) : mIsClosed(false), mDevice(device) {} Device::~Device() { - int status = audio_hw_device_close(mDevice); - ALOGW_IF(status, "Error closing audio hw device %p: %s", mDevice, strerror(-status)); + (void)doClose(); mDevice = nullptr; } @@ -383,6 +382,18 @@ Return<Result> Device::setConnectedState(const DeviceAddress& address, bool conn } #endif +Result Device::doClose() { + if (mIsClosed) return Result::INVALID_STATE; + mIsClosed = true; + return analyzeStatus("close", audio_hw_device_close(mDevice)); +} + +#if MAJOR_VERSION >= 6 +Return<Result> Device::close() { + return doClose(); +} +#endif + } // namespace implementation } // namespace CPP_VERSION } // namespace audio |