Move await_for_server() logs

Print the logs on the caller side. This will allow to call the function
in another context without printing the logs.

PR #3757 <https://github.com/Genymobile/scrcpy/pull/3757>
This commit is contained in:
Romain Vimont 2023-02-22 23:12:21 +01:00
parent f9960e959f
commit b7e5284adf

View file

@ -183,14 +183,11 @@ await_for_server(bool *connected) {
while (SDL_WaitEvent(&event)) { while (SDL_WaitEvent(&event)) {
switch (event.type) { switch (event.type) {
case SDL_QUIT: case SDL_QUIT:
LOGD("User requested to quit");
*connected = false; *connected = false;
return true; return true;
case SC_EVENT_SERVER_CONNECTION_FAILED: case SC_EVENT_SERVER_CONNECTION_FAILED:
LOGE("Server connection failed");
return false; return false;
case SC_EVENT_SERVER_CONNECTED: case SC_EVENT_SERVER_CONNECTED:
LOGD("Server connected");
*connected = true; *connected = true;
return true; return true;
default: default:
@ -374,15 +371,19 @@ scrcpy(struct scrcpy_options *options) {
// Await for server without blocking Ctrl+C handling // Await for server without blocking Ctrl+C handling
bool connected; bool connected;
if (!await_for_server(&connected)) { if (!await_for_server(&connected)) {
LOGE("Server connection failed");
goto end; goto end;
} }
if (!connected) { if (!connected) {
// This is not an error, user requested to quit // This is not an error, user requested to quit
LOGD("User requested to quit");
ret = SCRCPY_EXIT_SUCCESS; ret = SCRCPY_EXIT_SUCCESS;
goto end; goto end;
} }
LOGD("Server connected");
// It is necessarily initialized here, since the device is connected // It is necessarily initialized here, since the device is connected
struct sc_server_info *info = &s->server.info; struct sc_server_info *info = &s->server.info;