Camera3: add dynamic buffer count water mark support
The dynamic buffer count water mark starts from zero, and grows when the max of
hand-out buffer counts grow, until reach to the max allowed total buffer count.
For the case where the clients almost always uses less number of buffers than
the max allowed total buffer count, the dynamic buffer count water mark will
remain low, and the memory footprint will be smaller.
Change-Id: I305f40232f4740d3e9bedf14ee9b76a81e29e244
diff --git a/services/camera/libcameraservice/device3/Camera3BufferManager.h b/services/camera/libcameraservice/device3/Camera3BufferManager.h
index 0b4f55c..7942ae6 100644
--- a/services/camera/libcameraservice/device3/Camera3BufferManager.h
+++ b/services/camera/libcameraservice/device3/Camera3BufferManager.h
@@ -220,8 +220,18 @@
* simultaneously, the max allocated buffer count water mark for a stream set will the max
* of all streams' total buffer counts. This will avoid new buffer allocation in steady
* streaming state.
+ *
+ * This water mark can be dynamically changed, and will grow when the hand-out buffer count
+ * of each stream increases, until it reaches the maxAllowedBufferCount.
*/
size_t allocatedBufferWaterMark;
+
+ /**
+ * The max allowed buffer count for this stream set. It is the max of total number of
+ * buffers for each stream. This is the upper bound of the allocatedBufferWaterMark.
+ */
+ size_t maxAllowedBufferCount;
+
/**
* The stream info for all streams in this set
*/
@@ -237,6 +247,7 @@
BufferCountMap handoutBufferCountMap;
StreamSet() {
allocatedBufferWaterMark = 0;
+ maxAllowedBufferCount = 0;
}
};
@@ -280,6 +291,14 @@
*
*/
GraphicBufferEntry getFirstBufferFromBufferListLocked(BufferList& buffers, int streamId);
+
+ /**
+ * Check if there is any buffer associated with this stream in the given buffer list.
+ *
+ * This method needs to be called with mLock held.
+ *
+ */
+ bool inline hasBufferForStreamLocked(BufferList& buffers, int streamId);
};
} // namespace camera3