From d0f5f90dea8c703db9e1c899746f1d49dc1cac7e Mon Sep 17 00:00:00 2001 From: Hugo Hromic Date: Tue, 22 Jan 2019 22:02:30 +0000 Subject: [PATCH] Add option for sending quit app request after quitting streaming session * By default this option is set to `false` and can be enabled using the new `-quitappafter`/`quitappafter` command-line/config options. --- docs/README.pod | 4 ++++ moonlight.conf | 3 +++ src/config.c | 9 +++++++++ src/config.h | 1 + src/main.c | 8 ++++++++ 5 files changed, 25 insertions(+) diff --git a/docs/README.pod b/docs/README.pod index 7aeb5f2..c9c976f 100644 --- a/docs/README.pod +++ b/docs/README.pod @@ -145,6 +145,10 @@ Select platform for audio and video output and input. Try streaming if GFE version or options are unsupported +=item B<-quitappafter> + +Send quit app request to remote after quitting session + =item B<-verbose> Enable verbose output diff --git a/moonlight.conf b/moonlight.conf index 0af1607..01836d7 100644 --- a/moonlight.conf +++ b/moonlight.conf @@ -40,6 +40,9 @@ ## Play audio on host instead of streaming to client #localaudio = false +## Send quit app request to remote after quitting session +#quitappafter = false + ## Select audio device to play sound on #audio = sysdefault diff --git a/src/config.c b/src/config.c index 3697ffc..6ef0d7b 100644 --- a/src/config.c +++ b/src/config.c @@ -65,6 +65,7 @@ static struct option long_options[] = { {"fps", required_argument, NULL, 'v'}, {"codec", required_argument, NULL, 'x'}, {"unsupported", no_argument, NULL, 'y'}, + {"quitappafter", no_argument, NULL, '1'}, {"verbose", no_argument, NULL, 'z'}, {"debug", no_argument, NULL, 'Z'}, {0, 0, 0, 0}, @@ -212,6 +213,9 @@ static void parse_argument(int c, char* value, PCONFIGURATION config) { case 'y': config->unsupported = true; break; + case '1': + config->quitappafter = true; + break; case 'z': config->debug_level = 1; break; @@ -249,6 +253,8 @@ bool config_file_parse(char* filename, PCONFIGURATION config) { config->sops = strcmp("true", value) == 0; } else if (strcmp(key, "localaudio") == 0) { config->localaudio = strcmp("true", value) == 0; + } else if (strcmp(key, "quitappafter") == 0) { + config->quitappafter = strcmp("true", value) == 0; } else { for (int i=0;long_options[i].name != NULL;i++) { if (strcmp(long_options[i].name, key) == 0) { @@ -285,6 +291,8 @@ void config_save(char* filename, PCONFIGURATION config) { write_config_bool(fd, "sops", config->sops); if (config->localaudio) write_config_bool(fd, "localaudio", config->localaudio); + if (config->quitappafter) + write_config_bool(fd, "quitappafter", config->quitappafter); if (strcmp(config->app, "Steam") != 0) write_config_string(fd, "app", config->app); @@ -315,6 +323,7 @@ void config_parse(int argc, char* argv[], PCONFIGURATION config) { config->localaudio = false; config->fullscreen = true; config->unsupported = false; + config->quitappafter = false; config->codec = CODEC_UNSPECIFIED; config->inputsCount = 0; diff --git a/src/config.h b/src/config.h index 2e90b4e..3f2ddf7 100644 --- a/src/config.h +++ b/src/config.h @@ -40,6 +40,7 @@ typedef struct _CONFIGURATION { bool localaudio; bool fullscreen; bool unsupported; + bool quitappafter; char* inputs[MAX_INPUTS]; int inputsCount; enum codecs codec; diff --git a/src/main.c b/src/main.c index 1c6d5bc..e4aa9c1 100644 --- a/src/main.c +++ b/src/main.c @@ -135,6 +135,13 @@ static void stream(PSERVER_DATA server, PCONFIGURATION config, enum platform sys #endif LiStopConnection(); + + if (config->quitappafter) { + if (config->debug_level > 0) + printf("Sending app quit request ...\n"); + gs_quit_app(server); + } + platform_stop(system); } @@ -174,6 +181,7 @@ static void help() { printf("\t-mapping \t\tUse as gamepad mappings configuration file\n"); printf("\t-platform \tSpecify system used for audio, video and input: pi/imx/aml/rk/x11/x11_vdpau/sdl/fake (default auto)\n"); printf("\t-unsupported\t\tTry streaming if GFE version or options are unsupported\n"); + printf("\t-quitappafter\t\tSend quit app request to remote after quitting session\n"); #if defined(HAVE_SDL) || defined(HAVE_X11) printf("\n WM options (SDL and X11 only)\n\n"); printf("\t-windowed\t\tDisplay screen in a window\n");