diff options
author | Mikhail Naganov <mnaganov@google.com> | 2019-11-14 13:57:15 -0800 |
---|---|---|
committer | Mikhail Naganov <mnaganov@google.com> | 2019-11-21 10:56:25 -0800 |
commit | d041930df973ead927260d1f317a81a16276d8ae (patch) | |
tree | 8a5e49d98c614a24fd7fe515fb983df1e116bf72 /audio/core/all-versions/default/StreamIn.cpp | |
parent | 942de9e663138ca90bff873d65c7f2c8c36562b7 (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/StreamIn.cpp')
-rw-r--r-- | audio/core/all-versions/default/StreamIn.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/audio/core/all-versions/default/StreamIn.cpp b/audio/core/all-versions/default/StreamIn.cpp index d316f83617..f1152ca542 100644 --- a/audio/core/all-versions/default/StreamIn.cpp +++ b/audio/core/all-versions/default/StreamIn.cpp @@ -139,8 +139,7 @@ bool ReadThread::threadLoop() { } // namespace StreamIn::StreamIn(const sp<Device>& device, audio_stream_in_t* stream) - : mIsClosed(false), - mDevice(device), + : mDevice(device), mStream(stream), mStreamCommon(new Stream(&stream->common)), mStreamMmap(new StreamMmap<audio_stream_in_t>(stream)), @@ -159,7 +158,9 @@ StreamIn::~StreamIn() { status_t status = EventFlag::deleteEventFlag(&mEfGroup); ALOGE_IF(status, "read MQ event flag deletion error: %s", strerror(-status)); } +#if MAJOR_VERSION <= 5 mDevice->closeInputStream(mStream); +#endif mStream = nullptr; } @@ -303,14 +304,16 @@ Return<void> StreamIn::getMmapPosition(getMmapPosition_cb _hidl_cb) { } Return<Result> StreamIn::close() { - if (mIsClosed) return Result::INVALID_STATE; - mIsClosed = true; - if (mReadThread.get()) { - mStopReadThread.store(true, std::memory_order_release); + if (mStopReadThread.load(std::memory_order_relaxed)) { // only this thread writes + return Result::INVALID_STATE; } + mStopReadThread.store(true, std::memory_order_release); if (mEfGroup) { mEfGroup->wake(static_cast<uint32_t>(MessageQueueFlagBits::NOT_FULL)); } +#if MAJOR_VERSION >= 6 + mDevice->closeInputStream(mStream); +#endif return Result::OK; } |