diff --git a/src/process.cpp b/src/process.cpp index 08b64a6a..8ff907b5 100644 --- a/src/process.cpp +++ b/src/process.cpp @@ -216,6 +216,8 @@ namespace proc { launch_session->display_guid ); + BOOST_LOG(info) << "Virtual Display created at " << vdisplayName; + std::wstring currentPrimaryDisplayName = VDISPLAY::getPrimaryDisplay(); // Apply display settings @@ -384,17 +386,22 @@ namespace proc { // The app is still running only if the initial process launched is still running return _app_id; } - else if (_app.auto_detach && _process.native_exit_code() == 0 && - std::chrono::steady_clock::now() - _app_launch_time < 5s) { - BOOST_LOG(info) << "App exited gracefully within 5 seconds of launch. Treating the app as a detached command."sv; + else if (_app.auto_detach && std::chrono::steady_clock::now() - _app_launch_time < 5s) { + BOOST_LOG(info) << "App exited with code ["sv << _process.native_exit_code() << "] within 5 seconds of launch. Treating the app as a detached command."sv; BOOST_LOG(info) << "Adjust this behavior in the Applications tab or apps.json if this is not what you want."sv; placebo = true; + + #if defined SUNSHINE_TRAY && SUNSHINE_TRAY >= 1 + if (_process.native_exit_code() != 0) { + system_tray::update_tray_launch_error(proc::proc.get_last_run_app_name(), _process.native_exit_code()); + } + #endif + return _app_id; } // Perform cleanup actions now if needed if (_process) { - BOOST_LOG(info) << "App exited with code ["sv << _process.native_exit_code() << ']'; terminate(); } @@ -438,7 +445,11 @@ namespace proc { #ifdef _WIN32 if (vDisplayDriverStatus == VDISPLAY::DRIVER_STATUS::OK && _launch_session && this->virtual_display) { - VDISPLAY::removeVirtualDisplay(_launch_session->display_guid); + if (VDISPLAY::removeVirtualDisplay(_launch_session->display_guid)) { + BOOST_LOG(info) << "Virtual Display removed successfully"; + } else { + BOOST_LOG(info) << "Virtual Display remove failed"; + } } #endif diff --git a/src/system_tray.cpp b/src/system_tray.cpp index 9e58a821..fd6bfcb9 100644 --- a/src/system_tray.cpp +++ b/src/system_tray.cpp @@ -272,8 +272,8 @@ namespace system_tray { strcpy(force_close_msg, convertUtf8ToCurrentCodepage(force_close_msg).c_str()); #endif tray.notification_text = msg; - tray.tooltip = msg; tray.notification_icon = TRAY_ICON_PLAYING; + tray.tooltip = msg; tray.menu[2].text = force_close_msg; tray_update(&tray); } @@ -298,8 +298,8 @@ namespace system_tray { tray.icon = TRAY_ICON_PAUSING; tray.notification_title = "Stream Paused"; tray.notification_text = msg; - tray.tooltip = msg; tray.notification_icon = TRAY_ICON_PAUSING; + tray.tooltip = msg; tray_update(&tray); } @@ -329,6 +329,35 @@ namespace system_tray { tray_update(&tray); } + void + update_tray_launch_error(std::string app_name, int exit_code) { + if (!tray_initialized) { + return; + } + + tray.notification_title = NULL; + tray.notification_text = NULL; + tray.notification_cb = NULL; + tray.notification_icon = NULL; + tray.icon = TRAY_ICON; + tray_update(&tray); + char msg[256]; + snprintf(msg, std::size(msg), "Application %s exited too fast with code %d. Click here to terminate the stream.", app_name.c_str(), exit_code); + #ifdef _WIN32 + strcpy(msg, convertUtf8ToCurrentCodepage(msg).c_str()); + #endif + tray.icon = TRAY_ICON; + tray.notification_icon = TRAY_ICON; + tray.notification_title = "Launch Error"; + tray.notification_text = msg; + tray.notification_cb = []() { + BOOST_LOG(info) << "Force stop from notification"sv; + proc::proc.terminate(); + }; + tray.tooltip = PROJECT_NAME; + tray_update(&tray); + } + void update_tray_require_pin() { if (!tray_initialized) { diff --git a/src/system_tray.h b/src/system_tray.h index 7c0eb3b2..f3fe9b25 100644 --- a/src/system_tray.h +++ b/src/system_tray.h @@ -76,6 +76,9 @@ namespace system_tray { void update_tray_stopped(std::string app_name); + void + update_tray_launch_error(std::string app_name, int exit_code); + /** * @brief Spawns a notification for PIN Pairing. Clicking it opens the PIN Web UI Page */ diff --git a/src_assets/common/assets/web/pin.html b/src_assets/common/assets/web/pin.html index 56c2f31e..4d046219 100644 --- a/src_assets/common/assets/web/pin.html +++ b/src_assets/common/assets/web/pin.html @@ -18,7 +18,7 @@ -
+