Skip to content

Display and control your Android device

Set SDL hints before creating any thread

Romain Vimont4dca08cfe3ea
diff --git a/app/src/scrcpy.c b/app/src/scrcpy.c
index eb9cd201..961f6202 100644
--- a/app/src/scrcpy.c
+++ b/app/src/scrcpy.c
@@ -409,6 +409,12 @@ scrcpy(struct scrcpy_options *options) {
return SCRCPY_EXIT_FAILURE;
}
+ if (options->video_playback) {
+ // Set hints before starting the server thread to avoid race conditions
+ // in SDL
+ sdl_set_hints(options->render_driver);
+ }
+
if (!sc_server_start(&s->server)) {
goto end;
}
@@ -425,10 +431,6 @@ scrcpy(struct scrcpy_options *options) {
assert(!options->video_playback || options->video);
assert(!options->audio_playback || options->audio);
- if (options->video_playback) {
- sdl_set_hints(options->render_driver);
- }
-
if (options->video_playback ||
(options->control && options->clipboard_autosync)) {
// Initialize the video subsystem even if --no-video or