Loading media/libaaudio/src/client/AudioEndpoint.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -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(); } media/libaaudio/src/client/AudioEndpoint.h +5 −0 Original line number Diff line number Diff line Loading @@ -86,6 +86,11 @@ public: int32_t getBufferCapacityInFrames() const; /** * Write zeros to the data queue memory. */ void eraseDataMemory(); void dump() const; private: Loading media/libaaudio/src/client/AudioStreamInternal.cpp +5 −1 Original line number Diff line number Diff line Loading @@ -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; Loading media/libaaudio/src/fifo/FifoBuffer.cpp +6 −0 Original line number Diff line number Diff line Loading @@ -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); } } media/libaaudio/src/fifo/FifoBuffer.h +5 −0 Original line number Diff line number Diff line Loading @@ -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, Loading Loading
media/libaaudio/src/client/AudioEndpoint.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -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(); }
media/libaaudio/src/client/AudioEndpoint.h +5 −0 Original line number Diff line number Diff line Loading @@ -86,6 +86,11 @@ public: int32_t getBufferCapacityInFrames() const; /** * Write zeros to the data queue memory. */ void eraseDataMemory(); void dump() const; private: Loading
media/libaaudio/src/client/AudioStreamInternal.cpp +5 −1 Original line number Diff line number Diff line Loading @@ -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; Loading
media/libaaudio/src/fifo/FifoBuffer.cpp +6 −0 Original line number Diff line number Diff line Loading @@ -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); } }
media/libaaudio/src/fifo/FifoBuffer.h +5 −0 Original line number Diff line number Diff line Loading @@ -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, Loading