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

Commit eb9834d3 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "aaudio: fix race when disconnecting" into rvc-dev am: 5a126eaf

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/av/+/11761087

Change-Id: I3479eed015b3c3e7b8cf305ca6a1076bbac50680
parents b6d503a1 5a126eaf
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -95,9 +95,16 @@ std::vector<android::sp<AAudioServiceStreamBase>>
        mRegisteredStreams.swap(streamsDisconnected);
    }
    mConnected.store(false);
    // We need to stop all the streams before we disconnect them.
    // Otherwise there is a race condition where the first disconnected app
    // tries to reopen a stream as MMAP but is blocked by the second stream,
    // which hasn't stopped yet. Then the first app ends up with a Legacy stream.
    for (const auto &stream : streamsDisconnected) {
        ALOGD("%s() - stop and disconnect port %d", __func__, stream->getPortHandle());
        ALOGD("%s() - stop(), port = %d", __func__, stream->getPortHandle());
        stream->stop();
    }
    for (const auto &stream : streamsDisconnected) {
        ALOGD("%s() - disconnect(), port = %d", __func__, stream->getPortHandle());
        stream->disconnect();
    }
    return streamsDisconnected;