aaudio: free endpoint to prevent crashes
Free the AudioEndpoint and check for nullptr to
prevent accessing shared memory that had been freed.
This is to protect against calls to the stream after
AAudioStream_release() has been called.
Bug: 154274446
Bug: 154274027
Test: libaaudio/tests/test_various.cpp
Change-Id: I194d502fd48c4d31602ffce76aca6b28753ad7d2
diff --git a/media/libaaudio/src/client/AudioStreamInternal.h b/media/libaaudio/src/client/AudioStreamInternal.h
index 42f2889..61591b3 100644
--- a/media/libaaudio/src/client/AudioStreamInternal.h
+++ b/media/libaaudio/src/client/AudioStreamInternal.h
@@ -155,7 +155,8 @@
IsochronousClockModel mClockModel; // timing model for chasing the HAL
- AudioEndpoint mAudioEndpoint; // source for reads or sink for writes
+ std::unique_ptr<AudioEndpoint> mAudioEndpoint; // source for reads or sink for writes
+
aaudio_handle_t mServiceStreamHandle; // opaque handle returned from service
int32_t mFramesPerBurst = MIN_FRAMES_PER_BURST; // frames per HAL transfer
@@ -178,6 +179,9 @@
float mStreamVolume = 1.0f;
+ int64_t mLastFramesWritten = 0;
+ int64_t mLastFramesRead = 0;
+
private:
/*
* Asynchronous write with data conversion.
@@ -207,6 +211,8 @@
int32_t mDeviceChannelCount = 0;
int32_t mBufferSizeInFrames = 0; // local threshold to control latency
+ int32_t mBufferCapacityInFrames = 0;
+
};