diff options
author | Mikhail Naganov <mnaganov@google.com> | 2017-02-06 16:34:41 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2017-02-06 16:34:42 +0000 |
commit | 9bb90a55d6ddc81d40556f05a3f2e3f4612b9b8b (patch) | |
tree | add1c618715948de717910aff9d913eb7f404624 /audio/2.0/default/StreamIn.cpp | |
parent | a7426f7147ae565a212f46c1dbdc351425b5b278 (diff) | |
parent | b0abafbf0a6174e8c8933cc5fb19501a2d22c53b (diff) |
Merge "audiohal: Make closing of effects and streams fast"
Diffstat (limited to 'audio/2.0/default/StreamIn.cpp')
-rw-r--r-- | audio/2.0/default/StreamIn.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/audio/2.0/default/StreamIn.cpp b/audio/2.0/default/StreamIn.cpp index 1cde4ac1b9..9c49170ef0 100644 --- a/audio/2.0/default/StreamIn.cpp +++ b/audio/2.0/default/StreamIn.cpp @@ -16,10 +16,12 @@ #define LOG_TAG "StreamInHAL" //#define LOG_NDEBUG 0 +#define ATRACE_TAG ATRACE_TAG_AUDIO #include <android/log.h> #include <hardware/audio.h> #include <mediautils/SchedulingPolicyService.h> +#include <utils/Trace.h> #include "StreamIn.h" @@ -156,7 +158,18 @@ StreamIn::StreamIn(audio_hw_device_t* device, audio_stream_in_t* stream) } StreamIn::~StreamIn() { + ATRACE_CALL(); close(); + if (mReadThread.get()) { + ATRACE_NAME("mReadThread->join"); + status_t status = mReadThread->join(); + ALOGE_IF(status, "read thread exit error: %s", strerror(-status)); + } + if (mEfGroup) { + status_t status = EventFlag::deleteEventFlag(&mEfGroup); + ALOGE_IF(status, "read MQ event flag deletion error: %s", strerror(-status)); + } + mDevice->close_input_stream(mDevice, mStream); mStream = nullptr; mDevice = nullptr; } @@ -276,14 +289,10 @@ Return<Result> StreamIn::close() { mIsClosed = true; if (mReadThread.get()) { mStopReadThread.store(true, std::memory_order_release); - status_t status = mReadThread->requestExitAndWait(); - ALOGE_IF(status, "read thread exit error: %s", strerror(-status)); } if (mEfGroup) { - status_t status = EventFlag::deleteEventFlag(&mEfGroup); - ALOGE_IF(status, "read MQ event flag deletion error: %s", strerror(-status)); + mEfGroup->wake(static_cast<uint32_t>(MessageQueueFlagBits::NOT_FULL)); } - mDevice->close_input_stream(mDevice, mStream); return Result::OK; } |