From 6a13954d67143fb3c4ac8a4a7624c23e3ecb9a3c Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 10 Apr 2020 01:45:45 +0200 Subject: vo: further reduce redundant wakeups In display-sync mode, the core doesn't need to woken up every vsync, but only every time a new actual video frame needs to be queued. So don't wake up if there are still frames to repeat. In audio-sync mode, the wakeup is simply redundant, since there's a separate timer (in->wakeup_pts) to control when to queue a new frame. I think. This finally brings the required playloop iterations down to almost the number of video frames. (As originally intended, really.) Also a fairly risky change. --- video/out/vo.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/video/out/vo.c b/video/out/vo.c index e01bb055d3..2b15543a99 100644 --- a/video/out/vo.c +++ b/video/out/vo.c @@ -938,8 +938,14 @@ static bool render_frame(struct vo *vo) in->rendering = true; in->hasframe_rendered = true; int64_t prev_drop_count = vo->in->drop_count; + // Can the core queue new video now? Non-display-sync uses a separate + // timer instead. + bool can_queue = + !in->frame_queued && in->current_frame->num_vsyncs < 1 && use_vsync; pthread_mutex_unlock(&in->lock); - wakeup_core(vo); // core can queue new video now + + if (can_queue) + wakeup_core(vo); stats_time_start(in->stats, "video-draw"); -- cgit v1.2.3