Display and control your Android device
Pass serial within struct server_params
Romain Vimont4c31911df2cf
diff --git a/app/src/scrcpy.c b/app/src/scrcpy.cindex 8418353d..29ebe129 100644--- a/app/src/scrcpy.c+++ b/app/src/scrcpy.c@@ -256,6 +256,7 @@ scrcpy(const struct scrcpy_options *options) {bool record = !!options->record_filename;struct server_params params = {+ .serial = options->serial,.log_level = options->log_level,.crop = options->crop,.port_range = options->port_range,@@ -272,7 +273,7 @@ scrcpy(const struct scrcpy_options *options) {.force_adb_forward = options->force_adb_forward,.power_off_on_close = options->power_off_on_close,};- if (!server_start(&server, options->serial, ¶ms)) {+ if (!server_start(&server, ¶ms)) {goto end;}diff --git a/app/src/server.c b/app/src/server.cindex 646006d6..41e8166c 100644--- a/app/src/server.c+++ b/app/src/server.c@@ -407,16 +407,15 @@ run_wait_server(void *data) {}bool-server_start(struct server *server, const char *serial,- const struct server_params *params) {- if (serial) {- server->serial = strdup(serial);+server_start(struct server *server, const struct server_params *params) {+ if (params->serial) {+ server->serial = strdup(params->serial);if (!server->serial) {return false;}}- if (!push_server(serial)) {+ if (!push_server(params->serial)) {/* server->serial will be freed on server_destroy() */return false;}diff --git a/app/src/server.h b/app/src/server.hindex ad49a982..c249b374 100644--- a/app/src/server.h+++ b/app/src/server.h@@ -33,6 +33,7 @@ struct server {};struct server_params {+ const char *serial;enum sc_log_level log_level;const char *crop;const char *codec_options;@@ -56,8 +57,7 @@ server_init(struct server *server);// push, enable tunnel et start the serverbool-server_start(struct server *server, const char *serial,- const struct server_params *params);+server_start(struct server *server, const struct server_params *params);#define DEVICE_NAME_FIELD_LENGTH 64// block until the communication with the server is established