From 14112d8b119c625442db15bf7ab759b2cbf2eb88 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Wed, 21 Mar 2018 11:27:52 +0100 Subject: [PATCH] Initialize only video subsystem in screen.c SDL may initialize several subsystems (e.g. video and audio). Initialize only video in screen.c, and call SQL_Quit in any case. --- app/src/main.c | 2 ++ app/src/scrcpy.c | 2 +- app/src/screen.c | 8 +++----- app/src/screen.h | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/src/main.c b/app/src/main.c index 4bad1f3b..df8b7f91 100644 --- a/app/src/main.c +++ b/app/src/main.c @@ -292,5 +292,7 @@ int main(int argc, char *argv[]) { avformat_network_deinit(); // ignore failure + SDL_Quit(); + return res; } diff --git a/app/src/scrcpy.c b/app/src/scrcpy.c index fc97e3b2..208d3057 100644 --- a/app/src/scrcpy.c +++ b/app/src/scrcpy.c @@ -139,7 +139,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 5b4f0634..d303aca1 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);