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

Commit 249617e8 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "aaudio: stop buzzing when MMAP stream disconnected" into oc-mr1-dev

parents 4d519c7b ea04d970
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -254,3 +254,7 @@ void AudioEndpoint::dump() const {
    ALOGD("AudioEndpoint: data readCounter  = %lld", (long long) mDataQueue->getReadCounter());
    ALOGD("AudioEndpoint: data writeCounter = %lld", (long long) mDataQueue->getWriteCounter());
}

void AudioEndpoint::eraseDataMemory() {
    mDataQueue->eraseMemory();
}
+5 −0
Original line number Diff line number Diff line
@@ -86,6 +86,11 @@ public:

    int32_t getBufferCapacityInFrames() const;

    /**
     * Write zeros to the data queue memory.
     */
    void eraseDataMemory();

    void dump() const;

private:
+5 −1
Original line number Diff line number Diff line
@@ -440,10 +440,14 @@ aaudio_result_t AudioStreamInternal::onEventFromServer(AAudioServiceMessage *mes
            setState(AAUDIO_STREAM_STATE_CLOSED);
            break;
        case AAUDIO_SERVICE_EVENT_DISCONNECTED:
            // Prevent hardware from looping on old data and making buzzing sounds.
            if (getDirection() == AAUDIO_DIRECTION_OUTPUT) {
                mAudioEndpoint.eraseDataMemory();
            }
            result = AAUDIO_ERROR_DISCONNECTED;
            setState(AAUDIO_STREAM_STATE_DISCONNECTED);
            ALOGW("WARNING - AudioStreamInternal::onEventFromServer()"
                          " AAUDIO_SERVICE_EVENT_DISCONNECTED");
                          " AAUDIO_SERVICE_EVENT_DISCONNECTED - FIFO cleared");
            break;
        case AAUDIO_SERVICE_EVENT_VOLUME:
            mStreamVolume = (float)message->event.dataDouble;
+6 −0
Original line number Diff line number Diff line
@@ -210,3 +210,9 @@ fifo_frames_t FifoBuffer::getBufferCapacityInFrames() {
    return mFifo->getCapacity();
}

void FifoBuffer::eraseMemory() {
    int32_t numBytes = convertFramesToBytes(getBufferCapacityInFrames());
    if (numBytes > 0) {
        memset(mStorage, 0, (size_t) numBytes);
    }
}
+5 −0
Original line number Diff line number Diff line
@@ -111,6 +111,11 @@ public:
        mFifo->setWriteCounter(n);
    }

    /*
     * This is generally only called before or after the buffer is used.
     */
    void eraseMemory();

private:

    void fillWrappingBuffer(WrappingBuffer *wrappingBuffer,