From ca72cbb135f51c0d53b80924d51f597350d056d9 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sat, 4 Aug 2018 16:05:37 -0700 Subject: [PATCH] Implement displaying launch warnings. Fixes #12 --- app/gui/StreamSegue.qml | 8 +++++++- app/streaming/session.cpp | 36 ++++++++++++++++++++++++++---------- app/streaming/session.hpp | 2 ++ 3 files changed, 35 insertions(+), 11 deletions(-) diff --git a/app/gui/StreamSegue.qml b/app/gui/StreamSegue.qml index 02b38711..335ebce6 100644 --- a/app/gui/StreamSegue.qml +++ b/app/gui/StreamSegue.qml @@ -47,7 +47,13 @@ Item { function displayLaunchWarning(text) { - // TODO: toast + // This toast appears for 3 seconds, just shorter than how long + // Session will wait for it to be displayed. This gives it time + // to transition to invisible before continuing. + var toast = Qt.createQmlObject('import QtQuick.Controls 2.3; ToolTip {}', parent, '') + toast.text = text + toast.timeout = 3000 + toast.visible = true } onVisibleChanged: { diff --git a/app/streaming/session.cpp b/app/streaming/session.cpp index bba81280..5485324f 100644 --- a/app/streaming/session.cpp +++ b/app/streaming/session.cpp @@ -317,6 +317,22 @@ Session::Session(NvComputer* computer, NvApp& app) } } +void Session::emitLaunchWarning(QString text) +{ + // Emit the warning to the UI + emit displayLaunchWarning(text); + + // Wait a little bit so the user can actually read what we just said. + // This wait is a little longer than the actual toast timeout (3 seconds) + // to allow it to transition off the screen before continuing. + uint32_t start = SDL_GetTicks(); + while (!SDL_TICKS_PASSED(SDL_GetTicks(), start + 3500)) { + // Pump the UI loop while we wait + SDL_Delay(5); + QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents); + } +} + bool Session::validateLaunch() { QStringList warningList; @@ -337,14 +353,14 @@ bool Session::validateLaunch() m_StreamConfig.supportsHevc = false; if (hevcForced) { - emit displayLaunchWarning("This PC's GPU doesn't support HEVC decoding."); + emitLaunchWarning("This PC's GPU doesn't support HEVC decoding."); } } if (hevcForced) { if (m_Computer->maxLumaPixelsHEVC == 0) { - emit displayLaunchWarning("Your host PC GPU doesn't support HEVC. " - "A GeForce GTX 900-series (Maxwell) or later GPU is required for HEVC streaming."); + emitLaunchWarning("Your host PC GPU doesn't support HEVC. " + "A GeForce GTX 900-series (Maxwell) or later GPU is required for HEVC streaming."); } } } @@ -355,19 +371,19 @@ bool Session::validateLaunch() // Check that the app supports HDR if (!m_App.hdrSupported) { - emit displayLaunchWarning(m_App.name + " doesn't support HDR10."); + emitLaunchWarning(m_App.name + " doesn't support HDR10."); } // Check that the server GPU supports HDR else if (!(m_Computer->serverCodecModeSupport & 0x200)) { - emit displayLaunchWarning("Your host PC GPU doesn't support HDR streaming. " - "A GeForce GTX 1000-series (Pascal) or later GPU is required for HDR streaming."); + emitLaunchWarning("Your host PC GPU doesn't support HDR streaming. " + "A GeForce GTX 1000-series (Pascal) or later GPU is required for HDR streaming."); } else if (!isHardwareDecodeAvailable(m_Preferences.videoDecoderSelection, VIDEO_FORMAT_H265_MAIN10, m_StreamConfig.width, m_StreamConfig.height, m_StreamConfig.fps)) { - emit displayLaunchWarning("This PC's GPU doesn't support HEVC Main10 decoding for HDR streaming."); + emitLaunchWarning("This PC's GPU doesn't support HEVC Main10 decoding for HDR streaming."); } else { // TODO: Also validate display capabilites @@ -380,7 +396,7 @@ bool Session::validateLaunch() if (m_StreamConfig.width >= 3840) { // Only allow 4K on GFE 3.x+ if (m_Computer->gfeVersion.isNull() || m_Computer->gfeVersion.startsWith("2.")) { - emit displayLaunchWarning("GeForce Experience 3.0 or higher is required for 4K streaming."); + emitLaunchWarning("GeForce Experience 3.0 or higher is required for 4K streaming."); m_StreamConfig.width = 1920; m_StreamConfig.height = 1080; @@ -388,8 +404,8 @@ bool Session::validateLaunch() // This list is sorted from least to greatest else if (m_Computer->displayModes.last().width < 3840 || (m_Computer->displayModes.last().refreshRate < 60 && m_StreamConfig.fps >= 60)) { - emit displayLaunchWarning("Your host PC GPU doesn't support 4K streaming. " - "A GeForce GTX 900-series (Maxwell) or later GPU is required for 4K streaming."); + emitLaunchWarning("Your host PC GPU doesn't support 4K streaming. " + "A GeForce GTX 900-series (Maxwell) or later GPU is required for 4K streaming."); m_StreamConfig.width = 1920; m_StreamConfig.height = 1080; diff --git a/app/streaming/session.hpp b/app/streaming/session.hpp index 461770d1..eb9e0896 100644 --- a/app/streaming/session.hpp +++ b/app/streaming/session.hpp @@ -39,6 +39,8 @@ signals: private: bool validateLaunch(); + void emitLaunchWarning(QString text); + int getDecoderCapabilities(); int sdlDetermineAudioConfiguration();