From e56bb6785f7a9e1dbbfad4764b0b631e64b0b471 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sat, 18 Dec 2021 21:07:35 -0600 Subject: [PATCH] Change display mode when using KMSDRM backend --- app/streaming/session.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/app/streaming/session.cpp b/app/streaming/session.cpp index 2ebadd86..91dc2db7 100644 --- a/app/streaming/session.cpp +++ b/app/streaming/session.cpp @@ -919,6 +919,24 @@ void Session::updateOptimalWindowDisplayMode() } } + // For KMSDRM backends where we exclusively own the display, we should opt + // to change the resolution if that allows us to hit the desired frame rate + if (bestMode.refresh_rate == 0 && strcmp(SDL_GetCurrentVideoDriver(), "KMSDRM") == 0) { + for (int i = 0; i < SDL_GetNumDisplayModes(displayIndex); i++) { + if (SDL_GetDisplayMode(displayIndex, i, &mode) == 0) { + SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, + "Detected display mode: %dx%dx%d", + mode.w, mode.h, mode.refresh_rate); + if (mode.w >= m_ActiveVideoWidth && mode.h >= m_ActiveVideoHeight && + mode.refresh_rate % m_StreamConfig.fps == 0) { + if (mode.refresh_rate > bestMode.refresh_rate) { + bestMode = mode; + } + } + } + } + } + if (bestMode.refresh_rate == 0) { // We may find no match if the user has moved a 120 FPS // stream onto a 60 Hz monitor (since no refresh rate can