From 8a4eb9ef7aac9ae1b2793f295f2cd462dd5cf383 Mon Sep 17 00:00:00 2001 From: Dmugetsu Date: Tue, 27 May 2025 16:41:18 -0600 Subject: [PATCH] wait for space on flip queue and ensuring the queue gets properly drained --- src/core/libraries/videoout/driver.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/core/libraries/videoout/driver.cpp b/src/core/libraries/videoout/driver.cpp index fd57fde2d..41aeff142 100644 --- a/src/core/libraries/videoout/driver.cpp +++ b/src/core/libraries/videoout/driver.cpp @@ -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; } }