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

Commit b27cb9ba authored by Mikhail Naganov's avatar Mikhail Naganov
Browse files

libaudiohal@aidl: Handle stream resume uniformly

Extend the logic of asynchronous streams to all output streams.

Bug: 331551164
Test: atest audiorecord_tests trackplayerbase_tests CtsMediaAudioTestCases
Change-Id: Ia4d08557e6f4c370e5dbc980c9140649810f27f5
parent 005302b9
Loading
Loading
Loading
Loading
+16 −14
Original line number Diff line number Diff line
@@ -366,11 +366,9 @@ status_t StreamHalAidl::resume(StreamDescriptor::Reply* reply) {
    if (mIsInput) {
        return sendCommand(makeHalCommand<HalCommand::Tag::burst>(0), reply);
    } else {
        if (mContext.isAsynchronous()) {
        if (const auto state = getState(); state == StreamDescriptor::State::IDLE) {
            // Handle pause-flush-resume sequence. 'flush' from PAUSED goes to
            // IDLE. We move here from IDLE to ACTIVE (same as 'start' from PAUSED).
            const auto state = getState();
            if (state == StreamDescriptor::State::IDLE) {
            StreamDescriptor::Reply localReply{};
            StreamDescriptor::Reply* innerReply = reply ?: &localReply;
            RETURN_STATUS_IF_ERROR(
@@ -381,9 +379,13 @@ status_t StreamHalAidl::resume(StreamDescriptor::Reply* reply) {
                return INVALID_OPERATION;
            }
            return OK;
            }
        }
        } else if (state == StreamDescriptor::State::PAUSED) {
            return sendCommand(makeHalCommand<HalCommand::Tag::start>(), reply);
        } else {
            ALOGE("%s: unexpected stream state: %s (expected IDLE or PAUSED)",
                        __func__, toString(state).c_str());
            return INVALID_OPERATION;
        }
    }
}