changeset 31043:80036ef586ff

Add reinitialization support. Necessary for fullscreen on OSX.
author reimar
date Sun, 25 Apr 2010 10:44:53 +0000
parents 91eb3b0b9b7a
children 4fdb46b8c2c9
files libvo/gl_common.c libvo/sdl_common.c libvo/video_out.h libvo/vo_gl.c
diffstat 4 files changed, 18 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libvo/gl_common.c	Sun Apr 25 10:34:58 2010 +0000
+++ b/libvo/gl_common.c	Sun Apr 25 10:44:53 2010 +0000
@@ -1869,6 +1869,8 @@
   while (SDL_PollEvent(&event)) {
     res |= sdl_default_handle_event(&event);
   }
+  // poll "events" from within MPlayer code
+  res |= sdl_default_handle_event(NULL);
   if (res & VO_EVENT_RESIZE)
     sdl_set_mode(0, SDL_OPENGL | SDL_RESIZABLE);
   return res;
--- a/libvo/sdl_common.c	Sun Apr 25 10:34:58 2010 +0000
+++ b/libvo/sdl_common.c	Sun Apr 25 10:44:53 2010 +0000
@@ -29,9 +29,12 @@
 static int old_w;
 static int old_h;
 static int mode_flags;
+static int reinit;
 
 int vo_sdl_init(void)
 {
+    reinit = 0;
+
     if (!SDL_WasInit(SDL_INIT_VIDEO) &&
         SDL_Init(SDL_INIT_VIDEO|SDL_INIT_NOPARACHUTE) < 0)
         return 0;
@@ -70,6 +73,9 @@
     }
     vo_fs = !vo_fs;
     sdl_set_mode(0, mode_flags);
+    // on OSX at least we now need to do a full reinit.
+    // TODO: this should only be set if really necessary.
+    reinit = 1;
 }
 
 int sdl_set_mode(int bpp, uint32_t flags)
@@ -111,6 +117,11 @@
 int sdl_default_handle_event(SDL_Event *event)
 {
     int mpkey;
+    if (!event) {
+        int res = reinit ? VO_EVENT_REINIT : 0;
+        reinit = 0;
+        return res;
+    }
     switch (event->type) {
     case SDL_VIDEORESIZE:
         vo_dwidth  = event->resize.w;
--- a/libvo/video_out.h	Sun Apr 25 10:34:58 2010 +0000
+++ b/libvo/video_out.h	Sun Apr 25 10:44:53 2010 +0000
@@ -33,6 +33,7 @@
 #define VO_EVENT_EXPOSE 1
 #define VO_EVENT_RESIZE 2
 #define VO_EVENT_KEYPRESS 4
+#define VO_EVENT_REINIT 8
 
 /* Obsolete: VOCTRL_QUERY_VAA 1 */
 /* does the device support the required format */
--- a/libvo/vo_gl.c	Sun Apr 25 10:34:58 2010 +0000
+++ b/libvo/vo_gl.c	Sun Apr 25 10:44:53 2010 +0000
@@ -650,6 +650,10 @@
 static void check_events(void)
 {
     int e=glctx.check_events();
+    if(e&VO_EVENT_REINIT) {
+        uninitGl();
+        initGl(vo_dwidth, vo_dheight);
+    }
     if(e&VO_EVENT_RESIZE) resize(vo_dwidth,vo_dheight);
     if(e&VO_EVENT_EXPOSE && int_pause) redraw();
 }