Implement flushing and improve request tracking.
BUG: https://b/29937783, https://b/32941326
TEST: unit tests pass, fixes 8 failing cts tests
Change-Id: Idc390bdc1e51ba2bdbda91d90acc459a09a5f174
diff --git a/modules/camera/3_4/v4l2_wrapper.h b/modules/camera/3_4/v4l2_wrapper.h
index f25f80e..8c10d4b 100644
--- a/modules/camera/3_4/v4l2_wrapper.h
+++ b/modules/camera/3_4/v4l2_wrapper.h
@@ -45,8 +45,9 @@
Connection(std::shared_ptr<V4L2Wrapper> device)
: device_(std::move(device)), connect_result_(device_->Connect()) {}
~Connection() {
- if (connect_result_ == 0)
+ if (connect_result_ == 0) {
device_->Disconnect();
+ }
}
// Check whether the connection succeeded or not.
inline int status() const { return connect_result_; }
@@ -77,8 +78,9 @@
virtual int SetFormat(const default_camera_hal::Stream& stream,
uint32_t* result_max_buffers);
// Manage buffers.
- virtual int EnqueueBuffer(const camera3_stream_buffer_t* camera_buffer);
- virtual int DequeueBuffer(v4l2_buffer* buffer);
+ virtual int EnqueueBuffer(const camera3_stream_buffer_t* camera_buffer,
+ uint32_t* enqueued_index = nullptr);
+ virtual int DequeueBuffer(uint32_t* dequeued_index = nullptr);
private:
// Constructor is private to allow failing on bad input.
@@ -93,8 +95,8 @@
// Perform an ioctl call in a thread-safe fashion.
template <typename T>
int IoctlLocked(int request, T data);
- // Adjust buffers any time a device is connected/reformatted.
- int SetupBuffers();
+ // Request/release userspace buffer mode via VIDIOC_REQBUFS.
+ int RequestBuffers(uint32_t num_buffers);
inline bool connected() { return device_fd_.get() >= 0; }