From f39de46a3936f14d51f27e4510af7a2d348c466a Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Wed, 7 Feb 2018 15:26:42 +0100 Subject: [PATCH] Add delay before stopping server Let some time to print any exception trace before killing it. --- app/src/scrcpy.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/src/scrcpy.c b/app/src/scrcpy.c index 1b8b2f7e..311273fa 100644 --- a/app/src/scrcpy.c +++ b/app/src/scrcpy.c @@ -685,6 +685,8 @@ screen_finally_destroy_renderer: //SDL_DestroyRenderer(renderer); screen_finally_destroy_window: //SDL_DestroyWindow(window); + // at least we hide it + SDL_HideWindow(window); screen_finally_stop_and_join_controller: controller_stop(&controller); controller_join(&controller); @@ -692,6 +694,14 @@ screen_finally_destroy_controller: controller_destroy(&controller); screen_finally_stop_decoder: SDLNet_TCP_Close(device_socket); + + // let the server some time to print any exception trace before killing it + struct timespec timespec = { + .tv_sec = 0, + .tv_nsec = 100000000, // 100ms + }; + nanosleep(×pec, NULL); // ignore error + // kill the server before decoder_join() to wake up the decoder stop_server(server); decoder_join(&decoder);