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

Commit 5a26e665 authored by Phil Burk's avatar Phil Burk
Browse files

aaudio: do not assert if deleting an unopened stream

Bug: 63440754
Test: write_sine.cpp, see bug for repro case
Change-Id: I1f7ed1bd97d4cfcd54d27d41d708c6c03d3d88ac
parent c06dd405
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -137,6 +137,7 @@ aaudio_handle_t AAudioService::openStream(const aaudio::AAudioStreamRequest &req
        aaudio_handle_t handle = mHandleTracker.put(AAUDIO_HANDLE_TYPE_STREAM, serviceStream.get());
        if (handle < 0) {
            ALOGE("AAudioService::openStream(): handle table full");
            serviceStream->close();
            serviceStream.clear();
        } else {
            ALOGD("AAudioService::openStream(): handle = 0x%08X", handle);
+5 −4
Original line number Diff line number Diff line
@@ -42,10 +42,11 @@ AAudioServiceStreamBase::AAudioServiceStreamBase()

AAudioServiceStreamBase::~AAudioServiceStreamBase() {
    ALOGD("AAudioServiceStreamBase::~AAudioServiceStreamBase() destroying %p", this);
    // If the stream is deleted without closing then audio resources will leak.
    // Not being closed here would indicate an internal error. So we want to find this ASAP.
    LOG_ALWAYS_FATAL_IF(mState != AAUDIO_STREAM_STATE_CLOSED,
                        "service stream not closed, state = %d", mState);
    // If the stream is deleted when OPEN or in use then audio resources will leak.
    // This would indicate an internal error. So we want to find this ASAP.
    LOG_ALWAYS_FATAL_IF(!(mState == AAUDIO_STREAM_STATE_CLOSED
                        || mState == AAUDIO_STREAM_STATE_UNINITIALIZED),
                        "service stream still open, state = %d", mState);
}

std::string AAudioServiceStreamBase::dump() const {
+8 −0
Original line number Diff line number Diff line
@@ -144,8 +144,16 @@ public:
        mHandle = handle;
    }

    aaudio_stream_state_t getState() const {
        return mState;
    }

protected:

    void setState(aaudio_stream_state_t state) {
        mState = state;
    }

    aaudio_result_t writeUpMessageQueue(AAudioServiceMessage *command);

    aaudio_result_t sendCurrentTimestamp();
+1 −0
Original line number Diff line number Diff line
@@ -215,6 +215,7 @@ aaudio_result_t AAudioServiceStreamMMAP::open(const aaudio::AAudioStreamRequest
    configurationOutput.setAudioFormat(mAudioFormat);
    configurationOutput.setDeviceId(deviceId);

    setState(AAUDIO_STREAM_STATE_OPEN);
    return AAUDIO_OK;
}

+1 −0
Original line number Diff line number Diff line
@@ -177,6 +177,7 @@ aaudio_result_t AAudioServiceStreamShared::open(const aaudio::AAudioStreamReques
        goto error;
    }

    setState(AAUDIO_STREAM_STATE_OPEN);
    return AAUDIO_OK;

error: