wait for space on flip queue and ensuring the queue gets properly drained

This commit is contained in:
Dmugetsu 2025-05-27 16:41:18 -06:00 committed by Dmugetsu
parent 7bd134ae87
commit 8a4eb9ef7a

View File

@ -220,10 +220,11 @@ bool VideoOutDriver::SubmitFlip(VideoOutPort* port, s32 index, s64 flip_arg,
bool is_eop /*= false*/) {
{
std::unique_lock lock{port->port_mutex};
if (index != -1 && port->flip_status.flip_pending_num >= port->NumRegisteredBuffers()) {
LOG_ERROR(Lib_VideoOut, "Flip queue is full");
return false;
}
// wait until there is space in the flip queue
port->vo_cv.wait(lock, [&]() {
return index == -1 || port->flip_status.flip_pending_num < port->NumRegisteredBuffers();
});
if (is_eop) {
++port->flip_status.gc_queue_num;
@ -310,6 +311,15 @@ void VideoOutDriver::PresentThread(std::stop_token token) {
}
} else {
Flip(request);
{
std::scoped_lock lock{request.port->port_mutex};
request.port->flip_status.flip_pending_num--;
if (request.eop) {
request.port->flip_status.gc_queue_num--;
}
request.port->vo_cv
.notify_one(); // this wake up threads waiting to submit more flips
}
FRAME_END;
}
}