Move SDL initialization
Inline SDL initialization in scrcpy(). This will allow to split minimal initialization and video initialization.
This commit is contained in:
parent
ac539e1312
commit
688477ff65
1 changed files with 14 additions and 21 deletions
|
@ -111,22 +111,8 @@ sdl_set_hints(const char *render_driver) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// init SDL and set appropriate hints
|
static void
|
||||||
static bool
|
sdl_configure(bool display, bool disable_screensaver) {
|
||||||
sdl_init_and_configure(bool display, const char *render_driver,
|
|
||||||
bool disable_screensaver) {
|
|
||||||
if (display) {
|
|
||||||
sdl_set_hints(render_driver);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t flags = display ? SDL_INIT_VIDEO : SDL_INIT_EVENTS;
|
|
||||||
if (SDL_Init(flags)) {
|
|
||||||
LOGC("Could not initialize SDL: %s", SDL_GetError());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
atexit(SDL_Quit);
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// Clean up properly on Ctrl+C on Windows
|
// Clean up properly on Ctrl+C on Windows
|
||||||
bool ok = SetConsoleCtrlHandler(windows_ctrl_handler, TRUE);
|
bool ok = SetConsoleCtrlHandler(windows_ctrl_handler, TRUE);
|
||||||
|
@ -136,7 +122,7 @@ sdl_init_and_configure(bool display, const char *render_driver,
|
||||||
#endif // _WIN32
|
#endif // _WIN32
|
||||||
|
|
||||||
if (!display) {
|
if (!display) {
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (disable_screensaver) {
|
if (disable_screensaver) {
|
||||||
|
@ -146,8 +132,6 @@ sdl_init_and_configure(bool display, const char *render_driver,
|
||||||
LOGD("Screensaver enabled");
|
LOGD("Screensaver enabled");
|
||||||
SDL_EnableScreenSaver();
|
SDL_EnableScreenSaver();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
|
@ -319,11 +303,20 @@ scrcpy(struct scrcpy_options *options) {
|
||||||
|
|
||||||
server_started = true;
|
server_started = true;
|
||||||
|
|
||||||
if (!sdl_init_and_configure(options->display, options->render_driver,
|
if (options->display) {
|
||||||
options->disable_screensaver)) {
|
sdl_set_hints(options->render_driver);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t flags = options->display ? SDL_INIT_VIDEO : SDL_INIT_EVENTS;
|
||||||
|
if (SDL_Init(flags)) {
|
||||||
|
LOGC("Could not initialize SDL: %s", SDL_GetError());
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
atexit(SDL_Quit);
|
||||||
|
|
||||||
|
sdl_configure(options->display, options->disable_screensaver);
|
||||||
|
|
||||||
char device_name[DEVICE_NAME_FIELD_LENGTH];
|
char device_name[DEVICE_NAME_FIELD_LENGTH];
|
||||||
struct sc_size frame_size;
|
struct sc_size frame_size;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue