From b7e5284adf1074d6d851a0a7d164461325ccaa58 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Wed, 22 Feb 2023 23:12:21 +0100 Subject: [PATCH] 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 --- app/src/scrcpy.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/src/scrcpy.c b/app/src/scrcpy.c index 6bfed295..81affe47 100644 --- a/app/src/scrcpy.c +++ b/app/src/scrcpy.c @@ -183,14 +183,11 @@ await_for_server(bool *connected) { while (SDL_WaitEvent(&event)) { switch (event.type) { case SDL_QUIT: - LOGD("User requested to quit"); *connected = false; return true; case SC_EVENT_SERVER_CONNECTION_FAILED: - LOGE("Server connection failed"); return false; case SC_EVENT_SERVER_CONNECTED: - LOGD("Server connected"); *connected = true; return true; default: @@ -374,15 +371,19 @@ scrcpy(struct scrcpy_options *options) { // Await for server without blocking Ctrl+C handling bool connected; if (!await_for_server(&connected)) { + LOGE("Server connection failed"); goto end; } if (!connected) { // This is not an error, user requested to quit + LOGD("User requested to quit"); ret = SCRCPY_EXIT_SUCCESS; goto end; } + LOGD("Server connected"); + // It is necessarily initialized here, since the device is connected struct sc_server_info *info = &s->server.info;