From 98f4f4e68a21dd072d83b1e474d71e6f28d9eb91 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Sun, 7 May 2023 12:22:01 +0200 Subject: [PATCH] Refactor command line checks Several checks are performed when opts->record_filename is not NULL. Group them in a single block. PR #3978 --- app/src/cli.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/app/src/cli.c b/app/src/cli.c index 619f372e..4b895cd2 100644 --- a/app/src/cli.c +++ b/app/src/cli.c @@ -1959,21 +1959,23 @@ parse_args_with_getopt(struct scrcpy_cli_args *args, int argc, char *argv[], return false; } - if (opts->record_filename && !opts->record_format) { - opts->record_format = guess_record_format(opts->record_filename); + if (opts->record_filename) { if (!opts->record_format) { - LOGE("No format specified for \"%s\" " - "(try with --record-format=mkv)", - opts->record_filename); + opts->record_format = guess_record_format(opts->record_filename); + if (!opts->record_format) { + LOGE("No format specified for \"%s\" " + "(try with --record-format=mkv)", + opts->record_filename); + return false; + } + } + + if (opts->audio_codec == SC_CODEC_RAW) { + LOGW("Recording does not support RAW audio codec"); return false; } } - if (opts->record_filename && opts->audio_codec == SC_CODEC_RAW) { - LOGW("Recording does not support RAW audio codec"); - return false; - } - if (opts->audio_codec == SC_CODEC_RAW) { if (opts->audio_bit_rate) { LOGW("--audio-bit-rate is ignored for raw audio codec");