Merge "aaudio: prevent apps from affecting a stream they do not own" into oc-dr1-dev
diff --git a/services/camera/libcameraservice/device3/Camera3Device.cpp b/services/camera/libcameraservice/device3/Camera3Device.cpp
index a11f4e2..e022057 100644
--- a/services/camera/libcameraservice/device3/Camera3Device.cpp
+++ b/services/camera/libcameraservice/device3/Camera3Device.cpp
@@ -2326,7 +2326,11 @@
if (res < 0) return res;
if (mInFlightMap.size() == 1) {
- mStatusTracker->markComponentActive(mInFlightStatusId);
+ // hold mLock to prevent race with disconnect
+ Mutex::Autolock l(mLock);
+ if (mStatusTracker != nullptr) {
+ mStatusTracker->markComponentActive(mInFlightStatusId);
+ }
}
return OK;
@@ -2353,7 +2357,11 @@
// Indicate idle inFlightMap to the status tracker
if (mInFlightMap.size() == 0) {
- mStatusTracker->markComponentIdle(mInFlightStatusId, Fence::NO_FENCE);
+ // hold mLock to prevent race with disconnect
+ Mutex::Autolock l(mLock);
+ if (mStatusTracker != nullptr) {
+ mStatusTracker->markComponentIdle(mInFlightStatusId, Fence::NO_FENCE);
+ }
}
}
@@ -3590,7 +3598,8 @@
// Abort the input buffers for reprocess requests.
if ((*it)->mInputStream != NULL) {
camera3_stream_buffer_t inputBuffer;
- status_t res = (*it)->mInputStream->getInputBuffer(&inputBuffer);
+ status_t res = (*it)->mInputStream->getInputBuffer(&inputBuffer,
+ /*respectHalLimit*/ false);
if (res != OK) {
ALOGW("%s: %d: couldn't get input buffer while clearing the request "
"list: %s (%d)", __FUNCTION__, __LINE__, strerror(-res), res);
diff --git a/services/camera/libcameraservice/device3/Camera3Stream.cpp b/services/camera/libcameraservice/device3/Camera3Stream.cpp
index ba352c4..9297ac8 100644
--- a/services/camera/libcameraservice/device3/Camera3Stream.cpp
+++ b/services/camera/libcameraservice/device3/Camera3Stream.cpp
@@ -544,7 +544,7 @@
return res;
}
-status_t Camera3Stream::getInputBuffer(camera3_stream_buffer *buffer) {
+status_t Camera3Stream::getInputBuffer(camera3_stream_buffer *buffer, bool respectHalLimit) {
ATRACE_CALL();
Mutex::Autolock l(mLock);
status_t res = OK;
@@ -557,7 +557,7 @@
}
// Wait for new buffer returned back if we are running into the limit.
- if (getHandoutInputBufferCountLocked() == camera3_stream::max_buffers) {
+ if (getHandoutInputBufferCountLocked() == camera3_stream::max_buffers && respectHalLimit) {
ALOGV("%s: Already dequeued max input buffers (%d), wait for next returned one.",
__FUNCTION__, camera3_stream::max_buffers);
res = mInputBufferReturnedSignal.waitRelative(mLock, kWaitForBufferDuration);
diff --git a/services/camera/libcameraservice/device3/Camera3Stream.h b/services/camera/libcameraservice/device3/Camera3Stream.h
index b5a9c5d..b6c8396 100644
--- a/services/camera/libcameraservice/device3/Camera3Stream.h
+++ b/services/camera/libcameraservice/device3/Camera3Stream.h
@@ -308,8 +308,10 @@
* For bidirectional streams, this method applies to the input-side
* buffers.
*
+ * Normally this call will block until the handed out buffer count is less than the stream
+ * max buffer count; if respectHalLimit is set to false, this is ignored.
*/
- status_t getInputBuffer(camera3_stream_buffer *buffer);
+ status_t getInputBuffer(camera3_stream_buffer *buffer, bool respectHalLimit = true);
/**
* Return a buffer to the stream after use by the HAL.
diff --git a/services/camera/libcameraservice/device3/Camera3StreamInterface.h b/services/camera/libcameraservice/device3/Camera3StreamInterface.h
index 37b7c36..c695a10 100644
--- a/services/camera/libcameraservice/device3/Camera3StreamInterface.h
+++ b/services/camera/libcameraservice/device3/Camera3StreamInterface.h
@@ -232,8 +232,10 @@
* For bidirectional streams, this method applies to the input-side
* buffers.
*
+ * Normally this call will block until the handed out buffer count is less than the stream
+ * max buffer count; if respectHalLimit is set to false, this is ignored.
*/
- virtual status_t getInputBuffer(camera3_stream_buffer *buffer) = 0;
+ virtual status_t getInputBuffer(camera3_stream_buffer *buffer, bool respectHalLimit = true) = 0;
/**
* Return a buffer to the stream after use by the HAL.