Skip to content

reduce queue size to camInstance.buffer_frame_count_-1 , not just by 1 item #3

@bjudkewitz

Description

@bjudkewitz

In this section where we handle full queues...

if (!camInstance.seqMode_){
if ((int)camInstance.frameQueue_.size() >= camInstance.buffer_frame_count_) {
//printf("Queue size: %zd",camInstance.frameQueue_.size());
//printf("Buffer size: %zd",camInstance.buffer_frame_count_);
camInstance.frameQueue_.pop();
printf("Lost frame\n");
}
}
frame.count = camInstance.frameCnt_;
camInstance.frameQueue_.push(frame);
camInstance.newData_ = true;

... I believe we should reduce the queue size down to (camInstance.buffer_frame_count_-1) , not just by -1. Imagine that the system is temporarily overloaded and the queue size grows multiple items beyond camInstance.buffer_frame_count_. It has no chance of getting reduced again because a few lines further down we always push one frame back in.

So I believe we need a while loop

if ((int)camInstance.frameQueue_.size() >= camInstance.buffer_frame_count_) { 
   int n_dropped = 0
    while ((int)camInstance.frameQueue_.size() >= camInstance.buffer_frame_count_) { 
        camInstance.frameQueue_.pop(); 
        n_dropped++
    }
    printf("Dropped %zd frame(s)\n", n_dropped); 
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions