@@ -119,7 +119,6 @@ DelayedControls::DelayedControls(V4L2Device *device,
*/
void DelayedControls::reset(unsigned int cookie)
{
- queueCount_ = 1;
writeCount_ = 0;
cookies_[0] = cookie;
@@ -155,8 +154,8 @@ bool DelayedControls::push(const ControlList &controls, const unsigned int cooki
{
/* Copy state from previous frame. */
for (auto &ctrl : values_) {
- Info &info = ctrl.second[queueCount_];
- info = values_[ctrl.first][queueCount_ - 1];
+ Info &info = ctrl.second[writeCount_];
+ info = values_[ctrl.first][writeCount_ - 1];
info.updated = false;
}
@@ -175,18 +174,17 @@ bool DelayedControls::push(const ControlList &controls, const unsigned int cooki
if (controlParams_.find(id) == controlParams_.end())
return false;
- Info &info = values_[id][queueCount_];
+ Info &info = values_[id][writeCount_];
info = Info(control.second);
LOG(RPiDelayedControls, Debug)
<< "Queuing " << id->name()
<< " to " << info.toString()
- << " at index " << queueCount_;
+ << " at index " << writeCount_;
}
- cookies_[queueCount_] = cookie;
- queueCount_++;
+ cookies_[writeCount_] = cookie;
return true;
}
@@ -277,12 +275,12 @@ void DelayedControls::applyControls(uint32_t sequence)
}
}
- writeCount_ = sequence + 1;
-
- while (writeCount_ > queueCount_) {
+ while (writeCount_ < sequence + 1) {
+ writeCount_++;
LOG(RPiDelayedControls, Debug)
- << "Queue is empty, auto queue no-op.";
- push({}, cookies_[queueCount_ - 1]);
+ << "Pushing noop with for index " << writeCount_
+ << " with cookie " << cookies_[writeCount_ - 1];
+ push({}, cookies_[writeCount_ - 1]);
}
device_->setControls(&out);
@@ -76,7 +76,6 @@ private:
std::unordered_map<const ControlId *, ControlParams> controlParams_;
unsigned int maxDelay_;
- uint32_t queueCount_;
uint32_t writeCount_;
std::unordered_map<const ControlId *, RingBuffer<Info>> values_;
RingBuffer<unsigned int> cookies_;
The queueCount field in the DelayedControls is actually redundant. Remove it. Signed-off-by: David Plowman <david.plowman@raspberrypi.com> --- .../pipeline/rpi/common/delayed_controls.cpp | 22 +++++++++---------- .../pipeline/rpi/common/delayed_controls.h | 1 - 2 files changed, 10 insertions(+), 13 deletions(-)