Split SDL initialization
Initialize SDL_INIT_EVENTS first (very quick) and SDL_INIT_VIDEO after the server (quite long).
This commit is contained in:
parent
688477ff65
commit
caf594c90e
1 changed files with 10 additions and 4 deletions
|
@ -258,6 +258,14 @@ scrcpy(struct scrcpy_options *options) {
|
||||||
static struct scrcpy scrcpy;
|
static struct scrcpy scrcpy;
|
||||||
struct scrcpy *s = &scrcpy;
|
struct scrcpy *s = &scrcpy;
|
||||||
|
|
||||||
|
// Minimal SDL initialization
|
||||||
|
if (SDL_Init(SDL_INIT_EVENTS)) {
|
||||||
|
LOGC("Could not initialize SDL: %s", SDL_GetError());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
atexit(SDL_Quit);
|
||||||
|
|
||||||
if (!server_init(&s->server)) {
|
if (!server_init(&s->server)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -307,14 +315,12 @@ scrcpy(struct scrcpy_options *options) {
|
||||||
sdl_set_hints(options->render_driver);
|
sdl_set_hints(options->render_driver);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t flags = options->display ? SDL_INIT_VIDEO : SDL_INIT_EVENTS;
|
// Initialize SDL video in addition if display is enabled
|
||||||
if (SDL_Init(flags)) {
|
if (options->display && SDL_Init(SDL_INIT_VIDEO)) {
|
||||||
LOGC("Could not initialize SDL: %s", SDL_GetError());
|
LOGC("Could not initialize SDL: %s", SDL_GetError());
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
atexit(SDL_Quit);
|
|
||||||
|
|
||||||
sdl_configure(options->display, options->disable_screensaver);
|
sdl_configure(options->display, options->disable_screensaver);
|
||||||
|
|
||||||
char device_name[DEVICE_NAME_FIELD_LENGTH];
|
char device_name[DEVICE_NAME_FIELD_LENGTH];
|
||||||
|
|
Loading…
Reference in a new issue