diff --git a/app/src/main.c b/app/src/main.c index e1d6782e..dd8df067 100644 --- a/app/src/main.c +++ b/app/src/main.c @@ -319,6 +319,8 @@ int main(int argc, char *argv[]) { avformat_network_deinit(); // ignore failure + SDL_Quit(); + #if defined (__WINDOWS__) && ! defined (WINDOWS_NOCONSOLE) if (res != 0) { fprintf(stderr, "Press any key to continue...\n"); diff --git a/app/src/scrcpy.c b/app/src/scrcpy.c index 54a7f993..6bf0462d 100644 --- a/app/src/scrcpy.c +++ b/app/src/scrcpy.c @@ -157,7 +157,7 @@ SDL_bool scrcpy(const struct scrcpy_options *options) { LOGW("Cannot request to keep default signal handlers"); } - if (!sdl_init_and_configure()) { + if (!sdl_video_init()) { ret = SDL_FALSE; goto finally_destroy_server; } diff --git a/app/src/screen.c b/app/src/screen.c index 5d7a4009..1c2b3710 100644 --- a/app/src/screen.c +++ b/app/src/screen.c @@ -10,14 +10,12 @@ #define DISPLAY_MARGINS 96 -SDL_bool sdl_init_and_configure(void) { - if (SDL_Init(SDL_INIT_VIDEO)) { - LOGC("Could not initialize SDL: %s", SDL_GetError()); +SDL_bool sdl_video_init(void) { + if (SDL_InitSubSystem(SDL_INIT_VIDEO)) { + LOGC("Could not initialize SDL video: %s", SDL_GetError()); return SDL_FALSE; } - atexit(SDL_Quit); - // Use the best available scale quality if (!SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "2")) { LOGW("Could not enable bilinear filtering"); diff --git a/app/src/screen.h b/app/src/screen.h index 13103eaa..453348d7 100644 --- a/app/src/screen.h +++ b/app/src/screen.h @@ -35,7 +35,7 @@ struct screen { } // init SDL and set appropriate hints -SDL_bool sdl_init_and_configure(void); +SDL_bool sdl_video_init(void); // initialize default values void screen_init(struct screen *screen);