Factorize --list- options handling

This will limit code duplication as more list options will be added.

PR #4213 <https://github.com/Genymobile/scrcpy/pull/4213>
This commit is contained in:
Romain Vimont
2023-10-24 23:54:56 +02:00
parent a2fb1b40f6
commit f085765e04
8 changed files with 17 additions and 15 deletions

View File

@@ -311,10 +311,10 @@ execute_server(struct sc_server *server,
// By default, power_on is true
ADD_PARAM("power_on=false");
}
if (params->list_encoders) {
if (params->list & SC_OPTION_LIST_ENCODERS) {
ADD_PARAM("list_encoders=true");
}
if (params->list_displays) {
if (params->list & SC_OPTION_LIST_DISPLAYS) {
ADD_PARAM("list_displays=true");
}
@@ -896,7 +896,7 @@ run_server(void *data) {
// If --list-* is passed, then the server just prints the requested data
// then exits.
if (params->list_encoders || params->list_displays) {
if (params->list) {
sc_pid pid = execute_server(server, params);
if (pid == SC_PROCESS_NONE) {
goto error_connection_failed;