summaryrefslogtreecommitdiff
path: root/audio/core/all-versions/default/Device.cpp
diff options
context:
space:
mode:
authorMikhail Naganov <mnaganov@google.com>2019-11-14 13:57:15 -0800
committerMikhail Naganov <mnaganov@google.com>2019-11-21 10:56:25 -0800
commitd041930df973ead927260d1f317a81a16276d8ae (patch)
tree8a5e49d98c614a24fd7fe515fb983df1e116bf72 /audio/core/all-versions/default/Device.cpp
parent942de9e663138ca90bff873d65c7f2c8c36562b7 (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 Merged-In: I439f0f923c091af2ab234d15ca847cfade341f25
Diffstat (limited to 'audio/core/all-versions/default/Device.cpp')
-rw-r--r--audio/core/all-versions/default/Device.cpp17
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