From 93c683be3ab74b52b89e35b2fc92a9e1f2be7960 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sat, 8 Sep 2018 15:27:21 -0700 Subject: [PATCH] Allow renderers that force V-sync on to run without it when streaming higher than the display refresh rate --- app/streaming/video/ffmpeg.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/streaming/video/ffmpeg.cpp b/app/streaming/video/ffmpeg.cpp index 1f3935cd..bd304b86 100644 --- a/app/streaming/video/ffmpeg.cpp +++ b/app/streaming/video/ffmpeg.cpp @@ -1,5 +1,6 @@ #include #include "ffmpeg.h" +#include "streaming/streamutils.h" #ifdef Q_OS_WIN32 #include "ffmpeg-renderers/dxva2.h" @@ -127,9 +128,13 @@ bool FFmpegVideoDecoder::completeInitialization(AVCodec* decoder, SDL_Window* wi enableVsync = false; } else if (vsyncConstraint == IFFmpegRenderer::VSYNC_FORCE_ON && !enableVsync) { - SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, - "V-sync is forcefully enabled by the active renderer"); - enableVsync = true; + // FIXME: This duplicates logic in Session.cpp + int displayHz = StreamUtils::getDisplayRefreshRate(window); + if (displayHz + 5 >= maxFps) { + SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, + "V-sync is forcefully enabled by the active renderer"); + enableVsync = true; + } } m_Pacer = new Pacer(m_Renderer);