From 6cb357943a4681d824bf43d09e5af10a2337fa22 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Fri, 19 Feb 2021 22:40:12 +0100 Subject: [PATCH] Initialize screen before starting the stream As soon as the stream is started, the video buffer could notify a new frame available. In order to pass this event to the screen without race condition, the screen must be initialized before the screen is started. --- app/src/scrcpy.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/src/scrcpy.c b/app/src/scrcpy.c index 567b17e7..0fabf0ac 100644 --- a/app/src/scrcpy.c +++ b/app/src/scrcpy.c @@ -384,13 +384,6 @@ scrcpy(const struct scrcpy_options *options) { stream_init(&stream, server.video_socket, dec, rec); - // now we consumed the header values, the socket receives the video stream - // start the stream - if (!stream_start(&stream)) { - goto end; - } - stream_started = true; - if (options->display) { if (options->control) { if (!controller_init(&controller, server.control_socket)) { @@ -433,6 +426,13 @@ scrcpy(const struct scrcpy_options *options) { } } + // now we consumed the header values, the socket receives the video stream + // start the stream + if (!stream_start(&stream)) { + goto end; + } + stream_started = true; + input_manager_init(&input_manager, options); ret = event_loop(options);