Skip to content

Commit

Permalink
Pass serial within struct server_params
Browse files Browse the repository at this point in the history
This was the only option passed separately.
  • Loading branch information
rom1v committed May 28, 2021
1 parent 6adc971 commit 4c31911
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
3 changes: 2 additions & 1 deletion app/src/scrcpy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
}

Expand Down
9 changes: 4 additions & 5 deletions app/src/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions app/src/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down

0 comments on commit 4c31911

Please sign in to comment.