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

Commit 931c0d90 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "libaudiohal@aidl: Fix the implementation of MMap 'start'/'stop'" into...

Merge "libaudiohal@aidl: Fix the implementation of MMap 'start'/'stop'" into main am: 6ab2d9be am: 434938f8

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



Change-Id: I2815bb6b265e9e53100c9dfa559a73042d663286
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents c034c8b2 434938f8
Loading
Loading
Loading
Loading
+58 −7
Original line number Diff line number Diff line
@@ -257,20 +257,71 @@ status_t StreamHalAidl::start() {
    ALOGD("%p %s::%s", this, getClassName().c_str(), __func__);
    TIME_CHECK();
    if (!mStream) return NO_INIT;
    const auto state = getState();
    if (!mContext.isMmapped()) {
        return BAD_VALUE;
    }
    StreamDescriptor::Reply reply;
    if (state == StreamDescriptor::State::STANDBY) {
        RETURN_STATUS_IF_ERROR(sendCommand(makeHalCommand<HalCommand::Tag::start>(), &reply, true));
        return sendCommand(makeHalCommand<HalCommand::Tag::burst>(0), &reply, true);
    RETURN_STATUS_IF_ERROR(updateCountersIfNeeded(&reply));
    switch (reply.state) {
        case StreamDescriptor::State::STANDBY:
            RETURN_STATUS_IF_ERROR(
                    sendCommand(makeHalCommand<HalCommand::Tag::start>(), &reply, true));
            if (reply.state != StreamDescriptor::State::IDLE) {
                ALOGE("%s: unexpected stream state: %s (expected IDLE)",
                        __func__, toString(reply.state).c_str());
                return INVALID_OPERATION;
            }

            FALLTHROUGH_INTENDED;
        case StreamDescriptor::State::IDLE:
            RETURN_STATUS_IF_ERROR(
                    sendCommand(makeHalCommand<HalCommand::Tag::burst>(0), &reply, true));
            if (reply.state != StreamDescriptor::State::ACTIVE) {
                ALOGE("%s: unexpected stream state: %s (expected ACTIVE)",
                        __func__, toString(reply.state).c_str());
                return INVALID_OPERATION;
            }
            FALLTHROUGH_INTENDED;
        case StreamDescriptor::State::ACTIVE:
            return OK;
        case StreamDescriptor::State::DRAINING:
            RETURN_STATUS_IF_ERROR(
                    sendCommand(makeHalCommand<HalCommand::Tag::start>(), &reply, true));
            if (reply.state != StreamDescriptor::State::ACTIVE) {
                ALOGE("%s: unexpected stream state: %s (expected ACTIVE)",
                        __func__, toString(reply.state).c_str());
                return INVALID_OPERATION;
            }
            return OK;
        default:
            ALOGE("%s: not supported from %s stream state %s",
                    __func__, mIsInput ? "input" : "output", toString(reply.state).c_str());
            return INVALID_OPERATION;
    }
}

status_t StreamHalAidl::stop() {
    ALOGD("%p %s::%s", this, getClassName().c_str(), __func__);
    TIME_CHECK();
    if (!mStream) return NO_INIT;
    return standby();
    if (!mContext.isMmapped()) {
        return BAD_VALUE;
    }
    StreamDescriptor::Reply reply;
    RETURN_STATUS_IF_ERROR(updateCountersIfNeeded(&reply));
    if (const auto state = reply.state; state == StreamDescriptor::State::ACTIVE) {
        return drain(false /*earlyNotify*/, nullptr);
    } else if (state == StreamDescriptor::State::DRAINING) {
        RETURN_STATUS_IF_ERROR(pause());
        return flush();
    } else if (state == StreamDescriptor::State::PAUSED) {
        return flush();
    } else if (state != StreamDescriptor::State::IDLE &&
            state != StreamDescriptor::State::STANDBY) {
        ALOGE("%s: not supported from %s stream state %s",
                __func__, mIsInput ? "input" : "output", toString(state).c_str());
        return INVALID_OPERATION;
    }
    return OK;
}

status_t StreamHalAidl::getLatency(uint32_t *latency) {