Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0e1a0a93 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "audio: Fix handling of a thread exit command with a bad cookie" into...

Merge "audio: Fix handling of a thread exit command with a bad cookie" into main am: 759fb986 am: 0ad71fd5

Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/2908743



Change-Id: Ie84a5f1384d1fd74602f5fb97a2b90f619e29de7
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 928ae6ca 0ad71fd5
Loading
Loading
Loading
Loading
+18 −12
Original line number Original line Diff line number Diff line
@@ -180,17 +180,20 @@ StreamInWorkerLogic::Status StreamInWorkerLogic::cycle() {
    StreamDescriptor::Reply reply{};
    StreamDescriptor::Reply reply{};
    reply.status = STATUS_BAD_VALUE;
    reply.status = STATUS_BAD_VALUE;
    switch (command.getTag()) {
    switch (command.getTag()) {
        case Tag::halReservedExit:
        case Tag::halReservedExit: {
            if (const int32_t cookie = command.get<Tag::halReservedExit>();
            const int32_t cookie = command.get<Tag::halReservedExit>();
                cookie == (mContext->getInternalCommandCookie() ^ getTid())) {
            if (cookie == (mContext->getInternalCommandCookie() ^ getTid())) {
                mDriver->shutdown();
                mDriver->shutdown();
                setClosed();
                setClosed();
                // This is an internal command, no need to reply.
                return Status::EXIT;
            } else {
            } else {
                LOG(WARNING) << __func__ << ": EXIT command has a bad cookie: " << cookie;
                LOG(WARNING) << __func__ << ": EXIT command has a bad cookie: " << cookie;
            }
            }
            if (cookie != 0) {  // This is an internal command, no need to reply.
                return Status::EXIT;
            } else {
                break;
                break;
            }
        }
        case Tag::getStatus:
        case Tag::getStatus:
            populateReply(&reply, mIsConnected);
            populateReply(&reply, mIsConnected);
            break;
            break;
@@ -400,17 +403,20 @@ StreamOutWorkerLogic::Status StreamOutWorkerLogic::cycle() {
    reply.status = STATUS_BAD_VALUE;
    reply.status = STATUS_BAD_VALUE;
    using Tag = StreamDescriptor::Command::Tag;
    using Tag = StreamDescriptor::Command::Tag;
    switch (command.getTag()) {
    switch (command.getTag()) {
        case Tag::halReservedExit:
        case Tag::halReservedExit: {
            if (const int32_t cookie = command.get<Tag::halReservedExit>();
            const int32_t cookie = command.get<Tag::halReservedExit>();
                cookie == (mContext->getInternalCommandCookie() ^ getTid())) {
            if (cookie == (mContext->getInternalCommandCookie() ^ getTid())) {
                mDriver->shutdown();
                mDriver->shutdown();
                setClosed();
                setClosed();
                // This is an internal command, no need to reply.
                return Status::EXIT;
            } else {
            } else {
                LOG(WARNING) << __func__ << ": EXIT command has a bad cookie: " << cookie;
                LOG(WARNING) << __func__ << ": EXIT command has a bad cookie: " << cookie;
            }
            }
            if (cookie != 0) {  // This is an internal command, no need to reply.
                return Status::EXIT;
            } else {
                break;
                break;
            }
        }
        case Tag::getStatus:
        case Tag::getStatus:
            populateReply(&reply, mIsConnected);
            populateReply(&reply, mIsConnected);
            break;
            break;
+1 −1
Original line number Original line Diff line number Diff line
@@ -90,7 +90,7 @@ class StreamContext {
                  std::weak_ptr<sounddose::StreamDataProcessorInterface> streamDataProcessor,
                  std::weak_ptr<sounddose::StreamDataProcessorInterface> streamDataProcessor,
                  DebugParameters debugParameters)
                  DebugParameters debugParameters)
        : mCommandMQ(std::move(commandMQ)),
        : mCommandMQ(std::move(commandMQ)),
          mInternalCommandCookie(std::rand()),
          mInternalCommandCookie(std::rand() | 1 /* make sure it's not 0 */),
          mReplyMQ(std::move(replyMQ)),
          mReplyMQ(std::move(replyMQ)),
          mFormat(format),
          mFormat(format),
          mChannelLayout(channelLayout),
          mChannelLayout(channelLayout),