Skip to content

Commit

Permalink
Do not initialize SDL video when not necessary
Browse files Browse the repository at this point in the history
The SDL video subsystem is required for video playback and clipboard
synchronization.

If neither is used, it is not necessary to initialize it.

Refs 5e59ed3
Refs 110b3a1
Refs #4418 <#4418>
Refs #4477 <#4477>
  • Loading branch information
rom1v committed Nov 29, 2023
1 parent 140a49b commit bf056b1
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions app/src/scrcpy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit bf056b1

Please sign in to comment.