Skip to content

Display and control your Android device

Reorder initialization to simplify

Romain Vimonta4f8c0250279
diff --git a/app/src/scrcpy.c b/app/src/scrcpy.c
index 5e78dbf3..84f7c571 100644
--- a/app/src/scrcpy.c
+++ b/app/src/scrcpy.c
@@ -730,23 +730,20 @@ scrcpy(struct scrcpy_options *options) {
.start_fps_counter = options->start_fps_counter,
};
- struct sc_frame_source *src;
+ if (!sc_screen_init(&s->screen, &screen_params)) {
+ goto end;
+ }
+ screen_initialized = true;
+
if (options->video_playback) {
- src = &s->video_decoder.frame_source;
+ struct sc_frame_source *src = &s->video_decoder.frame_source;
if (options->display_buffer) {
sc_delay_buffer_init(&s->display_buffer,
options->display_buffer, true);
sc_frame_source_add_sink(src, &s->display_buffer.frame_sink);
src = &s->display_buffer.frame_source;
}
- }
- if (!sc_screen_init(&s->screen, &screen_params)) {
- goto end;
- }
- screen_initialized = true;
-
- if (options->video_playback) {
sc_frame_source_add_sink(src, &s->screen.frame_sink);
}
}