From 18dd6b09bbc3055bb72981e68265615d47f4e186 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Wed, 1 Aug 2018 18:26:50 -0700 Subject: [PATCH] Remove 10 ms sleep hidden inside SDL_WaitEvent(). This fixes mouse polling rate being capped at 100 Hz (1 second / 10 ms) and the rendering FPS being capped at 90 FPS. --- README.md | 2 +- app/settings/streamingpreferences.cpp | 6 +++--- app/streaming/session.cpp | 10 +++++++++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 575de0ba..05b9bb7b 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ You can follow development on our [Discord server](https://discord.gg/6ERtzFY). ## Features - Hardware accelerated video decoding on Windows, Mac, and Linux - - Supports streaming at up to 90 FPS on high refresh rate monitors + - Supports streaming at up to 120 FPS on high refresh rate monitors - Supports streaming at 720p, 1080p, 1440p, or 4K - 5.1 surround sound audio - HEVC support for better image quality at reduced bandwidth diff --git a/app/settings/streamingpreferences.cpp b/app/settings/streamingpreferences.cpp index 15a02b2f..c50f4f81 100644 --- a/app/settings/streamingpreferences.cpp +++ b/app/settings/streamingpreferences.cpp @@ -82,9 +82,9 @@ int StreamingPreferences::getMaximumStreamingFrameRate() for (int i = 0; i < SDL_GetNumVideoDisplays(); i++) { SDL_DisplayMode mode; if (SDL_GetCurrentDisplayMode(i, &mode) == 0) { - // Cap the frame rate at 90 FPS, since I can't seem to get - // much more out of GFE even with the game rendering at > 300 FPS. - maxFrameRate = qMax(maxFrameRate, qMin(90, mode.refresh_rate)); + // Cap the frame rate at 120 FPS. Past this, the encoders start + // to max out and drop frames. + maxFrameRate = qMax(maxFrameRate, qMin(120, mode.refresh_rate)); } } diff --git a/app/streaming/session.cpp b/app/streaming/session.cpp index dd7abc34..402f5d2b 100644 --- a/app/streaming/session.cpp +++ b/app/streaming/session.cpp @@ -667,7 +667,15 @@ void Session::exec() // Hijack this thread to be the SDL main thread. We have to do this // because we want to suspend all Qt processing until the stream is over. SDL_Event event; - while (SDL_WaitEvent(&event)) { + for (;;) { + // We explicitly use SDL_PollEvent() and SDL_Delay() because + // SDL_WaitEvent() has an internal SDL_Delay(10) inside which + // blocks this thread too long for high polling rate mice and high + // refresh rate displays. + if (!SDL_PollEvent(&event)) { + SDL_Delay(1); + continue; + } switch (event.type) { case SDL_QUIT: SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,