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

Commit 3a66794d authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "libaudiohal@aidl: Resolve async callbacks concurrency" into main

parents b6d489f4 fba97d88
Loading
Loading
Loading
Loading
+16 −2
Original line number Diff line number Diff line
@@ -544,7 +544,14 @@ status_t StreamHalAidl::exit() {
}

void StreamHalAidl::onAsyncTransferReady() {
    if (auto state = getState(); state == StreamDescriptor::State::TRANSFERRING) {
    StreamDescriptor::State state;
    {
        // Use 'mCommandReplyLock' to ensure that 'sendCommand' has finished updating the state
        // after the reply from the 'burst' command.
        std::lock_guard l(mCommandReplyLock);
        state = getState();
    }
    if (state == StreamDescriptor::State::TRANSFERRING) {
        // Retrieve the current state together with position counters unconditionally
        // to ensure that the state on our side gets updated.
        sendCommand(makeHalCommand<HalCommand::Tag::getStatus>(),
@@ -555,7 +562,14 @@ void StreamHalAidl::onAsyncTransferReady() {
}

void StreamHalAidl::onAsyncDrainReady() {
    if (auto state = getState(); state == StreamDescriptor::State::DRAINING) {
    StreamDescriptor::State state;
    {
        // Use 'mCommandReplyLock' to ensure that 'sendCommand' has finished updating the state
        // after the reply from the 'drain' command.
        std::lock_guard l(mCommandReplyLock);
        state = getState();
    }
    if (state == StreamDescriptor::State::DRAINING) {
        // Retrieve the current state together with position counters unconditionally
        // to ensure that the state on our side gets updated.
        sendCommand(makeHalCommand<HalCommand::Tag::getStatus>(), nullptr,