Mercurial > mplayer.hg
changeset 31037:4f273572e445
Share SDL initialization code.
author | reimar |
---|---|
date | Sun, 25 Apr 2010 09:52:01 +0000 |
parents | 272b88ce570e |
children | 3e67417271d7 |
files | libvo/gl_common.c libvo/sdl_common.c libvo/sdl_common.h libvo/vo_sdl.c |
diffstat | 4 files changed, 30 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/libvo/gl_common.c Sun Apr 25 09:25:23 2010 +0000 +++ b/libvo/gl_common.c Sun Apr 25 09:52:01 2010 +0000 @@ -1937,7 +1937,7 @@ ctx->swapGlBuffers = swapGlBuffers_sdl; ctx->check_events = sdl_check_events; ctx->fullscreen = vo_sdl_fullscreen; - return 1; + return vo_sdl_init(); #endif default: return 0; @@ -1959,7 +1959,7 @@ #endif #ifdef CONFIG_GL_SDL case GLTYPE_SDL: - SDL_QuitSubSystem(SDL_INIT_VIDEO); + vo_sdl_uninit(); break; #endif }
--- a/libvo/sdl_common.c Sun Apr 25 09:25:23 2010 +0000 +++ b/libvo/sdl_common.c Sun Apr 25 09:52:01 2010 +0000 @@ -30,6 +30,30 @@ static int old_h; static int mode_flags; +int vo_sdl_init(void) +{ + if (!SDL_WasInit(SDL_INIT_VIDEO) && + SDL_Init(SDL_INIT_VIDEO|SDL_INIT_NOPARACHUTE) < 0) + return 0; + + // Setup Keyrepeats (500/30 are defaults) + SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, 100 /*SDL_DEFAULT_REPEAT_INTERVAL*/); + + // We don't want those in our event queue. + SDL_EventState(SDL_ACTIVEEVENT, SDL_IGNORE); + SDL_EventState(SDL_MOUSEMOTION, SDL_IGNORE); + SDL_EventState(SDL_SYSWMEVENT, SDL_IGNORE); + SDL_EventState(SDL_USEREVENT, SDL_IGNORE); + + return 1; +} + +void vo_sdl_uninit(void) +{ + if (SDL_WasInit(SDL_INIT_VIDEO)) + SDL_QuitSubSystem(SDL_INIT_VIDEO); +} + void vo_sdl_fullscreen(void) { if (vo_fs) {
--- a/libvo/sdl_common.h Sun Apr 25 09:25:23 2010 +0000 +++ b/libvo/sdl_common.h Sun Apr 25 09:52:01 2010 +0000 @@ -28,6 +28,8 @@ #include <SDL.h> #endif +int vo_sdl_init(void); +void vo_sdl_uninit(void); void vo_sdl_fullscreen(void); int sdl_set_mode(int bpp, uint32_t flags); int sdl_default_handle_event(SDL_Event *event);
--- a/libvo/vo_sdl.c Sun Apr 25 09:25:23 2010 +0000 +++ b/libvo/vo_sdl.c Sun Apr 25 09:52:01 2010 +0000 @@ -397,9 +397,6 @@ priv->sdlflags |= SDL_DOUBLEBUF; #endif - /* Setup Keyrepeats (500/30 are defaults) */ - SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, 100 /*SDL_DEFAULT_REPEAT_INTERVAL*/); - /* get information about the graphics adapter */ vidInfo = SDL_GetVideoInfo (); @@ -444,16 +441,6 @@ priv->bpp = 16; } - /* We don't want those in our event queue. - * We use SDL_KEYUP cause SDL_KEYDOWN seems to cause problems - * with keys need to be pressed twice, to be recognized. - */ - SDL_EventState(SDL_ACTIVEEVENT, SDL_IGNORE); - SDL_EventState(SDL_MOUSEMOTION, SDL_IGNORE); -// SDL_EventState(SDL_QUIT, SDL_IGNORE); - SDL_EventState(SDL_SYSWMEVENT, SDL_IGNORE); - SDL_EventState(SDL_USEREVENT, SDL_IGNORE); - /* Success! */ return 0; } @@ -1407,8 +1394,7 @@ sdl_close(); /* Cleanup SDL */ - if(SDL_WasInit(SDL_INIT_VIDEO)) - SDL_QuitSubSystem(SDL_INIT_VIDEO); + vo_sdl_uninit(); mp_msg(MSGT_VO,MSGL_DBG3, "SDL: Closed Plugin\n"); @@ -1458,12 +1444,10 @@ priv->bpp = 0; /* initialize the SDL Video system */ - if (!SDL_WasInit(SDL_INIT_VIDEO)) { - if (SDL_Init (SDL_INIT_VIDEO|SDL_INIT_NOPARACHUTE)) { + if (!vo_sdl_init()) { mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SDL_InitializationFailed, SDL_GetError()); return -1; - } } SDL_VideoDriverName(priv->driver, 8);