Pass serial within struct server_params

This was the only option passed separately.
This commit is contained in:
Romain Vimont 2021-05-17 09:41:22 +02:00
parent 6adc97198b
commit 4c31911df2
3 changed files with 8 additions and 8 deletions

View file

@ -256,6 +256,7 @@ scrcpy(const struct scrcpy_options *options) {
bool record = !!options->record_filename; bool record = !!options->record_filename;
struct server_params params = { struct server_params params = {
.serial = options->serial,
.log_level = options->log_level, .log_level = options->log_level,
.crop = options->crop, .crop = options->crop,
.port_range = options->port_range, .port_range = options->port_range,
@ -272,7 +273,7 @@ scrcpy(const struct scrcpy_options *options) {
.force_adb_forward = options->force_adb_forward, .force_adb_forward = options->force_adb_forward,
.power_off_on_close = options->power_off_on_close, .power_off_on_close = options->power_off_on_close,
}; };
if (!server_start(&server, options->serial, &params)) { if (!server_start(&server, &params)) {
goto end; goto end;
} }

View file

@ -407,16 +407,15 @@ run_wait_server(void *data) {
} }
bool bool
server_start(struct server *server, const char *serial, server_start(struct server *server, const struct server_params *params) {
const struct server_params *params) { if (params->serial) {
if (serial) { server->serial = strdup(params->serial);
server->serial = strdup(serial);
if (!server->serial) { if (!server->serial) {
return false; return false;
} }
} }
if (!push_server(serial)) { if (!push_server(params->serial)) {
/* server->serial will be freed on server_destroy() */ /* server->serial will be freed on server_destroy() */
return false; return false;
} }

View file

@ -33,6 +33,7 @@ struct server {
}; };
struct server_params { struct server_params {
const char *serial;
enum sc_log_level log_level; enum sc_log_level log_level;
const char *crop; const char *crop;
const char *codec_options; const char *codec_options;
@ -56,8 +57,7 @@ server_init(struct server *server);
// push, enable tunnel et start the server // push, enable tunnel et start the server
bool bool
server_start(struct server *server, const char *serial, server_start(struct server *server, const struct server_params *params);
const struct server_params *params);
#define DEVICE_NAME_FIELD_LENGTH 64 #define DEVICE_NAME_FIELD_LENGTH 64
// block until the communication with the server is established // block until the communication with the server is established