Prevent duplicate buffer indices
Track which buffer indices are in use to prevent duplicates.
BUG: 31831808
TEST: Test app runs, enqueue errors no longer showing up in logs.
Change-Id: I319f9a1906170c861e194e357bdb57fab81d8c34
diff --git a/modules/camera/3_4/v4l2_wrapper.h b/modules/camera/3_4/v4l2_wrapper.h
index 3798c14..f25f80e 100644
--- a/modules/camera/3_4/v4l2_wrapper.h
+++ b/modules/camera/3_4/v4l2_wrapper.h
@@ -22,6 +22,7 @@
#include <mutex>
#include <set>
#include <string>
+#include <vector>
#include <nativehelper/ScopedFd.h>
@@ -107,8 +108,12 @@
bool extended_query_supported_;
// The format this device is set up for.
std::unique_ptr<StreamFormat> format_;
- // The maximum number of buffers this device can handle in its current format.
- uint32_t max_buffers_;
+ // Map indecies to buffer status. True if the index is in-flight.
+ // |buffers_.size()| will always be the maximum number of buffers this device
+ // can handle in its current format.
+ std::vector<bool> buffers_;
+ // Lock protecting use of the buffer tracker.
+ std::mutex buffer_queue_lock_;
// Lock protecting use of the device.
std::mutex device_lock_;
// Lock protecting connecting/disconnecting the device.