From bf056b1fee904391bc932381c01052fb975ac62e Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Wed, 29 Nov 2023 12:14:07 +0100 Subject: [PATCH] Do not initialize SDL video when not necessary The SDL video subsystem is required for video playback and clipboard synchronization. If neither is used, it is not necessary to initialize it. Refs 5e59ed31352251791679e5931d7e5abf0c2d18f6 Refs 110b3a16f6d02124a4567d2ab79fcb74d78f949f Refs #4418 Refs #4477 --- app/src/scrcpy.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/app/src/scrcpy.c b/app/src/scrcpy.c index d62a5f52..0b0b8bad 100644 --- a/app/src/scrcpy.c +++ b/app/src/scrcpy.c @@ -419,12 +419,16 @@ scrcpy(struct scrcpy_options *options) { sdl_set_hints(options->render_driver); } - // Initialize the video subsystem even if --no-video or --no-video-playback - // is passed so that clipboard synchronization still works. - // - if (SDL_Init(SDL_INIT_VIDEO)) { - LOGE("Could not initialize SDL video: %s", SDL_GetError()); - goto end; + if (options->video_playback || + (options->control && options->clipboard_autosync)) { + // Initialize the video subsystem even if --no-video or + // --no-video-playback is passed so that clipboard synchronization + // still works. + // + if (SDL_Init(SDL_INIT_VIDEO)) { + LOGE("Could not initialize SDL video: %s", SDL_GetError()); + goto end; + } } if (options->audio_playback) {