Loading audio/aidl/default/Stream.cpp +13 −3 Original line number Diff line number Diff line Loading @@ -14,6 +14,8 @@ * limitations under the License. */ #include <pthread.h> #define LOG_TAG "AHAL_Stream" #include <android-base/logging.h> #include <android/binder_ibinder_platform.h> Loading Loading @@ -94,6 +96,14 @@ void StreamContext::reset() { mDataMQ.reset(); } pid_t StreamWorkerCommonLogic::getTid() const { #if defined(__ANDROID__) return pthread_gettid_np(pthread_self()); #else return 0; #endif } std::string StreamWorkerCommonLogic::init() { if (mContext->getCommandMQ() == nullptr) return "Command MQ is null"; if (mContext->getReplyMQ() == nullptr) return "Reply MQ is null"; Loading Loading @@ -164,7 +174,7 @@ StreamInWorkerLogic::Status StreamInWorkerLogic::cycle() { switch (command.getTag()) { case Tag::halReservedExit: if (const int32_t cookie = command.get<Tag::halReservedExit>(); cookie == mContext->getInternalCommandCookie()) { cookie == (mContext->getInternalCommandCookie() ^ getTid())) { mDriver->shutdown(); setClosed(); // This is an internal command, no need to reply. Loading Loading @@ -384,7 +394,7 @@ StreamOutWorkerLogic::Status StreamOutWorkerLogic::cycle() { switch (command.getTag()) { case Tag::halReservedExit: if (const int32_t cookie = command.get<Tag::halReservedExit>(); cookie == mContext->getInternalCommandCookie()) { cookie == (mContext->getInternalCommandCookie() ^ getTid())) { mDriver->shutdown(); setClosed(); // This is an internal command, no need to reply. Loading Loading @@ -717,7 +727,7 @@ void StreamCommonImpl::stopWorker() { if (auto commandMQ = mContext.getCommandMQ(); commandMQ != nullptr) { LOG(DEBUG) << __func__ << ": asking the worker to exit..."; auto cmd = StreamDescriptor::Command::make<StreamDescriptor::Command::Tag::halReservedExit>( mContext.getInternalCommandCookie()); mContext.getInternalCommandCookie() ^ mWorker->getTid()); // Note: never call 'pause' and 'resume' methods of StreamWorker // in the HAL implementation. These methods are to be used by // the client side only. Preventing the worker loop from running Loading audio/aidl/default/include/core-impl/Stream.h +1 −0 Original line number Diff line number Diff line Loading @@ -223,6 +223,7 @@ class StreamWorkerCommonLogic : public ::android::hardware::audio::common::Strea : mContext(context), mDriver(driver), mTransientStateDelayMs(context->getTransientStateDelayMs()) {} pid_t getTid() const; std::string init() override; void populateReply(StreamDescriptor::Reply* reply, bool isConnected) const; void populateReplyWrongState(StreamDescriptor::Reply* reply, Loading Loading
audio/aidl/default/Stream.cpp +13 −3 Original line number Diff line number Diff line Loading @@ -14,6 +14,8 @@ * limitations under the License. */ #include <pthread.h> #define LOG_TAG "AHAL_Stream" #include <android-base/logging.h> #include <android/binder_ibinder_platform.h> Loading Loading @@ -94,6 +96,14 @@ void StreamContext::reset() { mDataMQ.reset(); } pid_t StreamWorkerCommonLogic::getTid() const { #if defined(__ANDROID__) return pthread_gettid_np(pthread_self()); #else return 0; #endif } std::string StreamWorkerCommonLogic::init() { if (mContext->getCommandMQ() == nullptr) return "Command MQ is null"; if (mContext->getReplyMQ() == nullptr) return "Reply MQ is null"; Loading Loading @@ -164,7 +174,7 @@ StreamInWorkerLogic::Status StreamInWorkerLogic::cycle() { switch (command.getTag()) { case Tag::halReservedExit: if (const int32_t cookie = command.get<Tag::halReservedExit>(); cookie == mContext->getInternalCommandCookie()) { cookie == (mContext->getInternalCommandCookie() ^ getTid())) { mDriver->shutdown(); setClosed(); // This is an internal command, no need to reply. Loading Loading @@ -384,7 +394,7 @@ StreamOutWorkerLogic::Status StreamOutWorkerLogic::cycle() { switch (command.getTag()) { case Tag::halReservedExit: if (const int32_t cookie = command.get<Tag::halReservedExit>(); cookie == mContext->getInternalCommandCookie()) { cookie == (mContext->getInternalCommandCookie() ^ getTid())) { mDriver->shutdown(); setClosed(); // This is an internal command, no need to reply. Loading Loading @@ -717,7 +727,7 @@ void StreamCommonImpl::stopWorker() { if (auto commandMQ = mContext.getCommandMQ(); commandMQ != nullptr) { LOG(DEBUG) << __func__ << ": asking the worker to exit..."; auto cmd = StreamDescriptor::Command::make<StreamDescriptor::Command::Tag::halReservedExit>( mContext.getInternalCommandCookie()); mContext.getInternalCommandCookie() ^ mWorker->getTid()); // Note: never call 'pause' and 'resume' methods of StreamWorker // in the HAL implementation. These methods are to be used by // the client side only. Preventing the worker loop from running Loading
audio/aidl/default/include/core-impl/Stream.h +1 −0 Original line number Diff line number Diff line Loading @@ -223,6 +223,7 @@ class StreamWorkerCommonLogic : public ::android::hardware::audio::common::Strea : mContext(context), mDriver(driver), mTransientStateDelayMs(context->getTransientStateDelayMs()) {} pid_t getTid() const; std::string init() override; void populateReply(StreamDescriptor::Reply* reply, bool isConnected) const; void populateReplyWrongState(StreamDescriptor::Reply* reply, Loading