Skip to content

Display and control your Android device

Do not initialize SDL video when not necessary

Romain Vimontbf056b1fee90
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.
- // <https://github.com/Genymobile/scrcpy/issues/4418>
- 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.
+ // <https://github.com/Genymobile/scrcpy/issues/4418>
+ if (SDL_Init(SDL_INIT_VIDEO)) {
+ LOGE("Could not initialize SDL video: %s", SDL_GetError());
+ goto end;
+ }
}
if (options->audio_playback) {