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

Commit 83d804d0 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge changes Ia7f3461d,I169d9f23 into main am: a3820347

parents e56328bc a3820347
Loading
Loading
Loading
Loading
+26 −7
Original line number Diff line number Diff line
@@ -421,8 +421,16 @@ status_t StreamHalAidl::pause(StreamDescriptor::Reply* reply) {
    ALOGD("%p %s::%s", this, getClassName().c_str(), __func__);
    TIME_CHECK();
    if (!mStream) return NO_INIT;
    return sendCommand(makeHalCommand<HalCommand::Tag::pause>(), reply,

    if (const auto state = getState(); isInPlayOrRecordState(state)) {
        return sendCommand(
                makeHalCommand<HalCommand::Tag::pause>(), reply,
                true /*safeFromNonWorkerThread*/);  // The workers stops its I/O activity first.
    } else {
        ALOGD("%s: already stream in one of the PAUSED kind of states, current state: %s", __func__,
              toString(state).c_str());
        return OK;
    }
}

status_t StreamHalAidl::resume(StreamDescriptor::Reply* reply) {
@@ -477,8 +485,19 @@ status_t StreamHalAidl::flush(StreamDescriptor::Reply* reply) {
    ALOGD("%p %s::%s", this, getClassName().c_str(), __func__);
    TIME_CHECK();
    if (!mStream) return NO_INIT;
    return sendCommand(makeHalCommand<HalCommand::Tag::flush>(), reply,

    if (const auto state = getState(); isInPausedState(state)) {
        return sendCommand(
                makeHalCommand<HalCommand::Tag::flush>(), reply,
                true /*safeFromNonWorkerThread*/);  // The workers stops its I/O activity first.
    } else if (isInPlayOrRecordState(state)) {
        ALOGE("%s: found stream in non-flushable state: %s", __func__, toString(state).c_str());
        return INVALID_OPERATION;
    } else {
        ALOGD("%s: already stream in one of the flushable state: current state: %s", __func__,
              toString(state).c_str());
        return OK;
    }
}

status_t StreamHalAidl::exit() {
@@ -802,8 +821,8 @@ status_t StreamOutHalAidl::supportsDrain(bool *supportsDrain) {
status_t StreamOutHalAidl::drain(bool earlyNotify) {
    if (!mStream) return NO_INIT;

    if(const auto state = getState(); state == StreamDescriptor::State::IDLE) {
        ALOGD("%p %s stream already in IDLE state", this, __func__);
    if (const auto state = getState(); isInDrainedState(state)) {
        ALOGD("%p %s stream already in %s", this, __func__, toString(state).c_str());
        if (mContext.isAsynchronous()) onDrainReady();
        return OK;
    }
+35 −0
Original line number Diff line number Diff line
@@ -220,6 +220,41 @@ class StreamHalAidl : public virtual StreamHalInterface, public ConversionHelper
        return mLastReply.state;
    }

    bool isInDrainedState(
            const ::aidl::android::hardware::audio::core::StreamDescriptor::State state) {
        if (state == ::aidl::android::hardware::audio::core::StreamDescriptor::State::IDLE ||
            state == ::aidl::android::hardware::audio::core::StreamDescriptor::State::STANDBY) {
            // drain equivalent states
            return true;
        }
        return false;
    }

    bool isInPlayOrRecordState(
            const ::aidl::android::hardware::audio::core::StreamDescriptor::State state) {
        if (state == ::aidl::android::hardware::audio::core::StreamDescriptor::State::ACTIVE ||
            state ==
                    ::aidl::android::hardware::audio::core::StreamDescriptor::State::TRANSFERRING ||
            state == ::aidl::android::hardware::audio::core::StreamDescriptor::State::DRAINING) {
            // play or record equivalent states
            return true;
        }
        return false;
    }

    bool isInPausedState(
            const ::aidl::android::hardware::audio::core::StreamDescriptor::State& state) {
        if (state == ::aidl::android::hardware::audio::core::StreamDescriptor::State::PAUSED ||
            state ==
                    ::aidl::android::hardware::audio::core::StreamDescriptor::State::DRAIN_PAUSED ||
            state == ::aidl::android::hardware::audio::core::StreamDescriptor::State::
                             TRANSFER_PAUSED) {
            // pause equivalent states
            return true;
        }
        return false;
    }

    status_t getLatency(uint32_t *latency);

    // Always returns non-negative values.