mirror of
https://github.com/mpv-player/mpv
synced 2025-04-11 04:01:31 +00:00
DOCS/client_api_examples/sdl: don't load file before GL init
Could lead to failure because it's essentially a race condition.
This commit is contained in:
parent
533e151feb
commit
b103a8e113
@ -72,10 +72,6 @@ int main(int argc, char *argv[])
|
|||||||
if (mpv_set_option_string(mpv, "vo", "opengl-cb") < 0)
|
if (mpv_set_option_string(mpv, "vo", "opengl-cb") < 0)
|
||||||
die("failed to set VO");
|
die("failed to set VO");
|
||||||
|
|
||||||
// Play this file. Note that this asynchronously starts playback.
|
|
||||||
const char *cmd[] = {"loadfile", argv[1], NULL};
|
|
||||||
mpv_command(mpv, cmd);
|
|
||||||
|
|
||||||
// We use events for thread-safe notification of the SDL main loop.
|
// We use events for thread-safe notification of the SDL main loop.
|
||||||
wakeup_on_mpv_redraw = SDL_RegisterEvents(1);
|
wakeup_on_mpv_redraw = SDL_RegisterEvents(1);
|
||||||
wakeup_on_mpv_events = SDL_RegisterEvents(1);
|
wakeup_on_mpv_events = SDL_RegisterEvents(1);
|
||||||
@ -90,6 +86,10 @@ int main(int argc, char *argv[])
|
|||||||
// users which run OpenGL on a different thread.)
|
// users which run OpenGL on a different thread.)
|
||||||
mpv_opengl_cb_set_update_callback(mpv_gl, on_mpv_redraw, NULL);
|
mpv_opengl_cb_set_update_callback(mpv_gl, on_mpv_redraw, NULL);
|
||||||
|
|
||||||
|
// Play this file. Note that this asynchronously starts playback.
|
||||||
|
const char *cmd[] = {"loadfile", argv[1], NULL};
|
||||||
|
mpv_command(mpv, cmd);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
if (SDL_WaitEvent(&event) != 1)
|
if (SDL_WaitEvent(&event) != 1)
|
||||||
|
Loading…
Reference in New Issue
Block a user