Notify user about app quit too fast instead of exiting the stream directly when auto_detach is enabled
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
<body id="app" v-cloak>
|
||||
<Navbar></Navbar>
|
||||
<div id="content" class="container content-container">
|
||||
<div id="content" class="container content-container d-flex flex-column align-items-center">
|
||||
<ul class="nav nav-pills pin-tab-bar justify-content-center">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" :class="{active: currentTab === 'OTP'}" href="#" @click.prevent="switchTab('OTP')">{{ $t('pin.otp_pairing') }}</a>
|
||||
|
||||
Reference in New Issue
Block a user