Only initialize the video subsystem once per launch

This commit is contained in:
Cameron Gutman
2019-03-23 17:46:42 -07:00
parent c0bf8b9c25
commit fa4c0e82bd
4 changed files with 67 additions and 106 deletions

View File

@@ -5,11 +5,6 @@
SystemProperties::SystemProperties()
{
hasHardwareAcceleration =
Session::isHardwareDecodeAvailable(StreamingPreferences::VDS_AUTO,
VIDEO_FORMAT_H264,
1920, 1080, 60);
isRunningWayland = qgetenv("XDG_SESSION_TYPE") == "wayland";
#ifdef Q_OS_WIN32
@@ -51,17 +46,11 @@ void SystemProperties::querySdlVideoInfo()
{
monitorDesktopResolutions.clear();
monitorNativeResolutions.clear();
hasHardwareAcceleration = false;
// Never let the maximum drop below 60 FPS
maximumStreamingFrameRate = 60;
if (SDL_InitSubSystem(SDL_INIT_VIDEO) != 0) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"SDL_InitSubSystem(SDL_INIT_VIDEO) failed: %s",
SDL_GetError());
return;
}
SDL_DisplayMode bestMode;
for (int displayIndex = 0; displayIndex < SDL_GetNumVideoDisplays(); displayIndex++) {
SDL_DisplayMode desktopMode;
@@ -97,5 +86,19 @@ void SystemProperties::querySdlVideoInfo()
}
}
SDL_QuitSubSystem(SDL_INIT_VIDEO);
SDL_Window* testWindow = SDL_CreateWindow("", 0, 0, 1280, 720, SDL_WINDOW_HIDDEN);
if (!testWindow) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"Failed to create window for hardware decode test: %s",
SDL_GetError());
return;
}
hasHardwareAcceleration =
Session::isHardwareDecodeAvailable(testWindow,
StreamingPreferences::VDS_AUTO,
VIDEO_FORMAT_H264,
1920, 1080, 60);
SDL_DestroyWindow(testWindow);
}