From 4c0554d225c25529bc17ab6ef44eea7f6f88a267 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 a671c5e4..f3bfecfb 100644 --- a/app/src/scrcpy.c +++ b/app/src/scrcpy.c @@ -366,13 +366,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)) { @@ -415,6 +408,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);