Skip to content

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.c
index 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, &params)) {
+ if (!server_start(&server, &params)) {
goto end;
}
diff --git a/app/src/server.c b/app/src/server.c
index 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.h
index 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 server
bool
-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