[v3,05/16] libcamera: delayed_controls: Rename class members
diff mbox series

Message ID 20240319120517.362082-6-stefan.klug@ideasonboard.com
State New
Headers show
Series
  • Preparation for per-frame-controls and initial tests
Related show

Commit Message

Stefan Klug March 19, 2024, 12:05 p.m. UTC
In preperation for the following patch, the class members are renamed
to better express their intent. This might be a little picky, but
my head is just more used to thinking of an index than a count.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
---
 include/libcamera/internal/delayed_controls.h |  6 ++++--
 src/libcamera/delayed_controls.cpp            | 20 +++++++++----------
 2 files changed, 14 insertions(+), 12 deletions(-)

Patch
diff mbox series

diff --git a/include/libcamera/internal/delayed_controls.h b/include/libcamera/internal/delayed_controls.h
index aef37077..4f8d2424 100644
--- a/include/libcamera/internal/delayed_controls.h
+++ b/include/libcamera/internal/delayed_controls.h
@@ -72,8 +72,10 @@  private:
 	std::unordered_map<const ControlId *, ControlParams> controlParams_;
 	unsigned int maxDelay_;
 
-	uint32_t queueCount_;
-	uint32_t writeCount_;
+	/* Index of the next request to queue */
+	uint32_t queueIndex_;
+	/* Index of the next request that gets written and is guaranteed to be fully applied */
+	uint32_t writeIndex_;
 	/* \todo Evaluate if we should index on ControlId * or unsigned int */
 	std::unordered_map<const ControlId *, ControlRingBuffer> values_;
 };
diff --git a/src/libcamera/delayed_controls.cpp b/src/libcamera/delayed_controls.cpp
index 777441e8..86571cd4 100644
--- a/src/libcamera/delayed_controls.cpp
+++ b/src/libcamera/delayed_controls.cpp
@@ -115,8 +115,8 @@  DelayedControls::DelayedControls(V4L2Device *device,
  */
 void DelayedControls::reset()
 {
-	queueCount_ = 1;
-	writeCount_ = 0;
+	queueIndex_ = 1;
+	writeIndex_ = 0;
 
 	/* Retrieve control as reported by the device. */
 	std::vector<uint32_t> ids;
@@ -150,8 +150,8 @@  bool DelayedControls::push(const ControlList &controls)
 {
 	/* Copy state from previous frame. */
 	for (auto &ctrl : values_) {
-		Info &info = ctrl.second[queueCount_];
-		info = values_[ctrl.first][queueCount_ - 1];
+		Info &info = ctrl.second[queueIndex_];
+		info = values_[ctrl.first][queueIndex_ - 1];
 		info.updated = false;
 	}
 
@@ -170,17 +170,17 @@  bool DelayedControls::push(const ControlList &controls)
 		if (controlParams_.find(id) == controlParams_.end())
 			return false;
 
-		Info &info = values_[id][queueCount_];
+		Info &info = values_[id][queueIndex_];
 
 		info = Info(control.second);
 
 		LOG(DelayedControls, Debug)
 			<< "Queuing " << id->name()
 			<< " to " << info.toString()
-			<< " at index " << queueCount_;
+			<< " at index " << queueIndex_;
 	}
 
-	queueCount_++;
+	queueIndex_++;
 
 	return true;
 }
@@ -241,7 +241,7 @@  void DelayedControls::applyControls(uint32_t sequence)
 	for (auto &ctrl : values_) {
 		const ControlId *id = ctrl.first;
 		unsigned int delayDiff = maxDelay_ - controlParams_[id].delay;
-		unsigned int index = std::max<int>(0, writeCount_ - delayDiff);
+		unsigned int index = std::max<int>(0, writeIndex_ - delayDiff);
 		Info &info = ctrl.second[index];
 
 		if (info.updated) {
@@ -271,9 +271,9 @@  void DelayedControls::applyControls(uint32_t sequence)
 		}
 	}
 
-	writeCount_ = sequence + 1;
+	writeIndex_ = sequence + 1;
 
-	while (writeCount_ > queueCount_) {
+	while (writeIndex_ > queueIndex_) {
 		LOG(DelayedControls, Debug)
 			<< "Queue is empty, auto queue no-op.";
 		push({});