From b13d25b9f4e4d09c5bb8f1b32be24af8ed511f77 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Wed, 21 Mar 2018 14:04:13 +0100 Subject: [PATCH] Group scrcpy options into a struct The scrcpy() function accepts as many parameters as there are options. To simplify, group all options in a separate struct. --- app/src/main.c | 8 +++++++- app/src/scrcpy.c | 5 +++-- app/src/scrcpy.h | 9 ++++++++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/app/src/main.c b/app/src/main.c index 573ef96f..dcb1a841 100644 --- a/app/src/main.c +++ b/app/src/main.c @@ -271,7 +271,13 @@ int main(int argc, char *argv[]) { SDL_LogSetAllPriority(SDL_LOG_PRIORITY_DEBUG); #endif - int res = scrcpy(args.serial, args.port, args.max_size, args.bit_rate) ? 0 : 1; + struct scrcpy_options options = { + .serial = args.serial, + .port = args.port, + .max_size = args.max_size, + .bit_rate = args.bit_rate, + }; + int res = scrcpy(&options) ? 0 : 1; avformat_network_deinit(); // ignore failure diff --git a/app/src/scrcpy.c b/app/src/scrcpy.c index 204cad4f..7df07906 100644 --- a/app/src/scrcpy.c +++ b/app/src/scrcpy.c @@ -106,8 +106,9 @@ static void event_loop(void) { } } -SDL_bool scrcpy(const char *serial, Uint16 local_port, Uint16 max_size, Uint32 bit_rate) { - if (!server_start(&server, serial, local_port, max_size, bit_rate)) { +SDL_bool scrcpy(const struct scrcpy_options *options) { + if (!server_start(&server, options->serial, options->port, + options->max_size, options->bit_rate)) { return SDL_FALSE; } diff --git a/app/src/scrcpy.h b/app/src/scrcpy.h index f46feb51..f4b4cc90 100644 --- a/app/src/scrcpy.h +++ b/app/src/scrcpy.h @@ -3,6 +3,13 @@ #include -SDL_bool scrcpy(const char *serial, Uint16 local_port, Uint16 max_size, Uint32 bit_rate); +struct scrcpy_options { + const char *serial; + Uint16 port; + Uint16 max_size; + Uint32 bit_rate; +}; + +SDL_bool scrcpy(const struct scrcpy_options *options); #endif