[MPlayer-cvslog] r31079 - in trunk/libvo: gl_common.c sdl_common.c sdl_common.h vo_sdl.c

reimar subversion at mplayerhq.hu
Sun Apr 25 11:52:01 CEST 2010


Author: reimar
Date: Sun Apr 25 11:52:01 2010
New Revision: 31079

Log:
Share SDL initialization code.

Modified:
   trunk/libvo/gl_common.c
   trunk/libvo/sdl_common.c
   trunk/libvo/sdl_common.h
   trunk/libvo/vo_sdl.c

Modified: trunk/libvo/gl_common.c
==============================================================================
--- trunk/libvo/gl_common.c	Sun Apr 25 11:25:23 2010	(r31078)
+++ trunk/libvo/gl_common.c	Sun Apr 25 11:52:01 2010	(r31079)
@@ -1937,7 +1937,7 @@ int init_mpglcontext(MPGLContext *ctx, e
     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 @@ void uninit_mpglcontext(MPGLContext *ctx
 #endif
 #ifdef CONFIG_GL_SDL
   case GLTYPE_SDL:
-    SDL_QuitSubSystem(SDL_INIT_VIDEO);
+    vo_sdl_uninit();
     break;
 #endif
   }

Modified: trunk/libvo/sdl_common.c
==============================================================================
--- trunk/libvo/sdl_common.c	Sun Apr 25 11:25:23 2010	(r31078)
+++ trunk/libvo/sdl_common.c	Sun Apr 25 11:52:01 2010	(r31079)
@@ -30,6 +30,30 @@ static int old_w;
 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) {

Modified: trunk/libvo/sdl_common.h
==============================================================================
--- trunk/libvo/sdl_common.h	Sun Apr 25 11:25:23 2010	(r31078)
+++ trunk/libvo/sdl_common.h	Sun Apr 25 11:52:01 2010	(r31079)
@@ -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);

Modified: trunk/libvo/vo_sdl.c
==============================================================================
--- trunk/libvo/vo_sdl.c	Sun Apr 25 11:25:23 2010	(r31078)
+++ trunk/libvo/vo_sdl.c	Sun Apr 25 11:52:01 2010	(r31079)
@@ -397,9 +397,6 @@ static int sdl_open (void *plugin, void 
 	    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 @@ static int sdl_open (void *plugin, void 
 		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 @@ uninit(void)
 	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 @@ static int preinit(const char *arg)
     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);


More information about the MPlayer-cvslog mailing list