From e71f5358b3ebf44569b1f3798c13ed65554b69b9 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Wed, 24 May 2023 20:25:01 +0200 Subject: [PATCH] Reorder command line options checks Perform checks that impact the options first. --- app/src/cli.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/app/src/cli.c b/app/src/cli.c index dbf774a8..60a007e9 100644 --- a/app/src/cli.c +++ b/app/src/cli.c @@ -1922,6 +1922,21 @@ parse_args_with_getopt(struct scrcpy_cli_args *args, int argc, char *argv[], return false; } +#ifdef HAVE_USB + if (!(opts->playback && opts->video) && !opts->otg) { +#else + if (!(opts->playback && opts->video)) { +#endif + // If video playback is disabled and OTG are disabled, then there is + // no way to control the device. + opts->control = false; + } + + if (!opts->video) { + // If video is disabled, then scrcpy must exit on audio failure. + opts->require_audio = true; + } + #ifdef HAVE_V4L2 if (!opts->playback && !opts->record_filename && !opts->v4l2_device) { LOGE("-N/--no-playback requires either screen recording (-r/--record)" @@ -2087,21 +2102,6 @@ parse_args_with_getopt(struct scrcpy_cli_args *args, int argc, char *argv[], } #endif -#ifdef HAVE_USB - if (!(opts->playback && opts->video) && !opts->otg) { -#else - if (!(opts->playback && opts->video)) { -#endif - // If video playback is disabled and OTG are disabled, then there is - // no way to control the device. - opts->control = false; - } - - if (!opts->video) { - // If video is disabled, then scrcpy must exit on audio failure. - opts->require_audio = true; - } - return true; }