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

Commit 3786f3d5 authored by Ajender Reddy's avatar Ajender Reddy
Browse files

libaudiohal@aidl: Fix drain expectation

drain in IDLE or STANDBY is treated as success

BUG: 353460645

Test: play compress offload playback

Change-Id: I169d9f23fcacc9b7a614945d58c269f78e03a72e
parent cf076344
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -798,8 +798,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;
    }
+10 −0
Original line number Diff line number Diff line
@@ -220,6 +220,16 @@ 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;
    }

    status_t getLatency(uint32_t *latency);

    // Always returns non-negative values.