Ticket #2213: beastd-mplayer-vo-gl-sdl2-hack.diff
| File beastd-mplayer-vo-gl-sdl2-hack.diff, 10.8 KB (added by , 11 years ago) |
|---|
-
Makefile
diff --git a/Makefile b/Makefile index 027c0bc..ff3ee34 100644
a b SRCS_MPLAYER-$(PULSE) += libao2/ao_pulse.c 545 545 SRCS_MPLAYER-$(QUARTZ) += libvo/vo_quartz.c libvo/osx_common.c 546 546 SRCS_MPLAYER-$(S3FB) += libvo/vo_s3fb.c 547 547 SRCS_MPLAYER-$(SDL) += libao2/ao_sdl.c \ 548 libvo/vo_sdl.c \549 548 libvo/sdl_common.c 550 549 SRCS_MPLAYER-$(SGIAUDIO) += libao2/ao_sgi.c 551 550 SRCS_MPLAYER-$(SNDIO) += libao2/ao_sndio.c -
configure
diff --git a/configure b/configure index b6b7d7c..5d1ebcc 100755
a b ld_tmp="" 5374 5374 def_sdl_sdl_h="#undef CONFIG_SDL_SDL_H" 5375 5375 if test -z "$_sdlconfig" ; then 5376 5376 if ( sdl-config --version ) >>"$TMPLOG" 2>&1 ; then 5377 _sdlconfig=" sdl-config"5377 _sdlconfig="pkg-config sdl2" 5378 5378 else 5379 5379 _sdlconfig=false 5380 5380 fi … … if test "$_sdl" = auto || test "$_sdl" = yes ; then 5391 5391 #undef main 5392 5392 #endif 5393 5393 int main(int argc, char *argv[]) { 5394 SDL_Init(SDL_INIT_VIDEO |SDL_INIT_NOPARACHUTE);5395 return 0;5394 SDL_Init(SDL_INIT_VIDEO); 5395 return SDLK_KP_0; // will only be defined in SDL2 5396 5396 } 5397 5397 EOF 5398 5398 _sdl=no … … EOF 5403 5403 break 5404 5404 fi 5405 5405 done 5406 if test "$_sdl" = no && "$_sdlconfig"--version >>"$TMPLOG" 2>&1 ; then5406 if test "$_sdl" = no && $_sdlconfig --version >>"$TMPLOG" 2>&1 ; then 5407 5407 res_comment="using $_sdlconfig" 5408 5408 if cygwin ; then 5409 5409 inc_tmp="$($_sdlconfig --cflags | cut -d " " -f 1,5,6 | sed s/no-cygwin/cygwin/)" … … int main(int argc, char *argv[]) { 5483 5483 HDC dc; 5484 5484 wglCreateContext(dc); 5485 5485 #elif defined(GL_SDL) 5486 SDL_GL_Swap Buffers();5486 SDL_GL_SwapWindow(NULL); 5487 5487 #elif defined(GL_EGL_X11) || defined(GL_EGL_ANDROID) 5488 5488 EGLDisplay eglDisplay = EGL_NO_DISPLAY; 5489 5489 eglInitialize(eglDisplay, NULL, NULL); -
libvo/gl_common.c
diff --git a/libvo/gl_common.c b/libvo/gl_common.c index ecf12cb..7c3f8b6 100644
a b static int x11_check_events(void) { 2384 2384 #ifdef CONFIG_GL_SDL 2385 2385 #include "sdl_common.h" 2386 2386 2387 extern SDL_Window *sdl_wnd; 2387 2388 static void swapGlBuffers_sdl(MPGLContext *ctx) { 2388 SDL_GL_Swap Buffers();2389 SDL_GL_SwapWindow(sdl_wnd); 2389 2390 } 2390 2391 2391 2392 static void *sdlgpa(const GLubyte *name) { 2392 2393 return SDL_GL_GetProcAddress(name); 2393 2394 } 2394 2395 2396 extern SDL_GLContext *sdl_glctx; 2395 2397 static int setGlWindow_sdl(MPGLContext *ctx) { 2396 if (!sdl_set_mode(0, SDL_ OPENGL | SDL_RESIZABLE))2398 if (!sdl_set_mode(0, SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE)) 2397 2399 return SET_WINDOW_FAILED; 2398 SDL_GL_LoadLibrary(NULL); 2400 if (!SDL_GL_CreateContext(sdl_wnd)) { 2401 return SET_WINDOW_FAILED; 2402 } 2399 2403 getFunctions(sdlgpa, NULL); 2400 2404 gpu_def_sl_program = 0; 2401 2405 gpu_yuv_sl_program = 0; … … static int sdl_check_events(void) { 2408 2412 while (SDL_PollEvent(&event)) { 2409 2413 res |= sdl_default_handle_event(&event); 2410 2414 } 2411 // poll "events" from within MPlayer code2412 res |= sdl_default_handle_event(NULL);2413 2415 if (res & VO_EVENT_RESIZE) 2414 sdl_set_mode(0, SDL_ OPENGL | SDL_RESIZABLE);2416 sdl_set_mode(0, SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE); 2415 2417 return res; 2416 2418 } 2417 2419 … … static void dummy_update_xinerama_info(void) { 2655 2657 aspect_save_screenres(vo_screenwidth, vo_screenheight); 2656 2658 } 2657 2659 2660 //XXX: There seems to a bug if this function returns -1 2658 2661 int init_mpglcontext(MPGLContext *ctx, enum MPGLType type) { 2659 2662 if (type == GLTYPE_AUTO) { 2660 2663 int res = init_mpglcontext(ctx, GLTYPE_W32); -
libvo/sdl_common.c
diff --git a/libvo/sdl_common.c b/libvo/sdl_common.c index 5cf3a0a..b708d8a 100644
a b 31 31 static int old_w; 32 32 static int old_h; 33 33 static int mode_flags; 34 static int reinit; 34 SDL_Window *sdl_wnd; //XXX: should rather be private 35 35 36 36 /** 37 37 * Update vo_screenwidth and vo_screenheight. … … static int reinit; 43 43 * update_xinerama_info function. 44 44 */ 45 45 static void get_screensize(void) { 46 const SDL_VideoInfo *vi; 47 // TODO: better to use a check that gets the runtime version instead? 48 #if SDL_VERSION_ATLEAST(1, 2, 10) 49 // Keep user-provided settings 46 SDL_DisplayMode mode; 47 int num_displays; 48 50 49 if (vo_screenwidth > 0 || vo_screenheight > 0) return; 51 vi = SDL_GetVideoInfo(); 52 vo_screenwidth = vi->current_w; 53 vo_screenheight = vi->current_h; 54 #endif 50 51 num_displays = SDL_GetNumVideoDisplays(); 52 mp_msg(MSGT_VO, MSGL_INFO, "[sdl] Number of displays: %d\n", num_displays); 53 if (num_displays <= 0) return; 54 55 if (SDL_GetDesktopDisplayMode(0, &mode) < 0) { 56 mp_msg(MSGT_VO, MSGL_ERR, "[sdl] Could not get display mode: %s\n", SDL_GetError()); 57 } 58 mp_msg(MSGT_VO, MSGL_INFO, "[sdl] Size of display #0: %dx%d\n", mode.w, mode.h); 59 vo_screenwidth = mode.w; 60 vo_screenheight = mode.h; 55 61 } 56 62 57 63 int vo_sdl_init(void) 58 64 { 59 reinit = 0;60 61 65 if (!SDL_WasInit(SDL_INIT_VIDEO)) { 62 // Unfortunately SDL_WINDOWID must be set at SDL_Init63 // and is ignored afterwards, thus it cannot work per-file.64 // Also, a value of 0 does not work for selecting the root window.65 if (WinID > 0) {66 char envstr[20];67 snprintf(envstr, sizeof(envstr), "0x%"PRIx64, WinID);68 setenv("SDL_WINDOWID", envstr, 1);69 }70 66 if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_NOPARACHUTE) < 0) 71 67 return 0; 72 68 } 73 69 74 // Setup Keyrepeats (500/30 are defaults)75 SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, 100 /*SDL_DEFAULT_REPEAT_INTERVAL*/);76 77 // Easiest way to get uppercase characters78 SDL_EnableUNICODE(1);79 80 70 // We don't want those in our event queue. 81 SDL_EventState(SDL_ACTIVEEVENT, SDL_IGNORE);82 71 SDL_EventState(SDL_SYSWMEVENT, SDL_IGNORE); 83 72 SDL_EventState(SDL_USEREVENT, SDL_IGNORE); 84 73 … … void vo_sdl_uninit(void) 96 85 97 86 int vo_sdl_config(int w, int h, int flags, const char *title) 98 87 { 99 SDL_ WM_SetCaption(title, NULL);88 SDL_SetWindowTitle(sdl_wnd, title); 100 89 vo_dwidth = old_w = w; 101 90 vo_dheight = old_h = h; 102 91 vo_fs = !!(flags & VOFLAG_FULLSCREEN); … … int vo_sdl_config(int w, int h, int flags, const char *title) 110 99 111 100 void vo_sdl_fullscreen(void) 112 101 { 102 SDL_SetWindowFullscreen(sdl_wnd, vo_fs ? 0 : SDL_WINDOW_FULLSCREEN_DESKTOP); 103 SDL_ShowCursor(vo_fs ? SDL_ENABLE : SDL_DISABLE); 113 104 if (vo_fs) { 114 105 vo_dwidth = old_w; 115 106 vo_dheight = old_h; 116 107 } else { 108 SDL_DisplayMode mode; 109 SDL_GetWindowDisplayMode(sdl_wnd, &mode); 110 vo_screenwidth = mode.w; 111 vo_screenheight = mode.h; 117 112 old_w = vo_dwidth; 118 113 old_h = vo_dheight; 119 114 vo_dwidth = vo_screenwidth; 120 115 vo_dheight = vo_screenheight; 121 116 } 122 117 vo_fs = !vo_fs; 123 sdl_set_mode(0, mode_flags);124 // on OSX at least we now need to do a full reinit.125 // TODO: this should only be set if really necessary.126 reinit = 1;127 118 } 128 119 129 120 SDL_Surface *sdl_set_mode(int bpp, uint32_t flags) 130 121 { 131 SDL_Surface *s;132 122 mode_flags = flags; 133 if (vo_fs) flags |= SDL_FULLSCREEN;134 // doublebuf with opengl creates flickering135 #if !defined( __AMIGAOS4__ ) && !defined( __APPLE__ )136 if (vo_doublebuffering && !(flags & SDL_OPENGL))137 flags |= SDL_DOUBLEBUF;138 #endif139 123 if (!vo_border) 140 flags |= SDL_ NOFRAME;124 flags |= SDL_WINDOW_BORDERLESS; 141 125 if (geometry_xy_changed) { 142 126 char envstr[20]; 143 127 snprintf(envstr, sizeof(envstr), "%i,%i", vo_dx, vo_dy); 144 128 setenv("SDL_VIDEO_WINDOW_POS", envstr, 1); 145 129 } 146 s = SDL_SetVideoMode(vo_dwidth, vo_dheight, bpp, flags); 147 if (!s) { 130 if (sdl_wnd) 131 SDL_DestroyWindow(sdl_wnd); 132 sdl_wnd = SDL_CreateWindow( 133 "SDL2", 134 SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 135 vo_dwidth, vo_dheight, 136 flags 137 ); 138 if (!sdl_wnd) { 148 139 mp_msg(MSGT_VO, MSGL_FATAL, "SDL SetVideoMode failed: %s\n", SDL_GetError()); 149 140 return NULL; 150 141 } 151 vo_dwidth = s->w; 152 vo_dheight = s->h; 153 return s; 142 SDL_GetWindowSize(sdl_wnd, &vo_dwidth, &vo_dheight); 143 return (SDL_Surface *)sdl_wnd; // XXX/FIXME: actually plain wrong, but we won't end up in an endless loop initing vo gl 154 144 } 155 145 156 146 static const struct mp_keymap keysym_map[] = { … … static const struct mp_keymap keysym_map[] = { 164 154 {SDLK_UP, KEY_UP}, {SDLK_DOWN, KEY_DOWN}, 165 155 {SDLK_LEFT, KEY_LEFT}, {SDLK_RIGHT, KEY_RIGHT}, 166 156 {SDLK_KP_MULTIPLY, '*'}, {SDLK_KP_DIVIDE, '/'}, 167 {SDLK_KP 0, KEY_KP0}, {SDLK_KP1, KEY_KP1}, {SDLK_KP2, KEY_KP2},168 {SDLK_KP 3, KEY_KP3}, {SDLK_KP4, KEY_KP4}, {SDLK_KP5, KEY_KP5},169 {SDLK_KP 6, KEY_KP6}, {SDLK_KP7, KEY_KP7}, {SDLK_KP8, KEY_KP8},170 {SDLK_KP 9, KEY_KP9},157 {SDLK_KP_0, KEY_KP0}, {SDLK_KP_1, KEY_KP1}, {SDLK_KP_2, KEY_KP2}, 158 {SDLK_KP_3, KEY_KP3}, {SDLK_KP_4, KEY_KP4}, {SDLK_KP_5, KEY_KP5}, 159 {SDLK_KP_6, KEY_KP6}, {SDLK_KP_7, KEY_KP7}, {SDLK_KP_8, KEY_KP8}, 160 {SDLK_KP_9, KEY_KP9}, 171 161 {SDLK_KP_PERIOD, KEY_KPDEC}, {SDLK_KP_ENTER, KEY_KPENTER}, 172 162 {0, 0} 173 163 }; … … static const struct mp_keymap keysym_map[] = { 175 165 int sdl_default_handle_event(SDL_Event *event) 176 166 { 177 167 int mpkey; 178 if (!event) {179 int res = reinit ? VO_EVENT_REINIT : 0;180 reinit = 0;181 return res;182 }183 168 switch (event->type) { 184 case SDL_ VIDEORESIZE:185 vo_dwidth = event-> resize.w;186 vo_dheight = event-> resize.h;169 case SDL_WINDOWEVENT_RESIZED: 170 vo_dwidth = event->window.data1; 171 vo_dheight = event->window.data2; 187 172 return VO_EVENT_RESIZE; 188 173 189 case SDL_ VIDEOEXPOSE:174 case SDL_WINDOWEVENT_EXPOSED: 190 175 return VO_EVENT_EXPOSE; 191 176 192 177 case SDL_MOUSEMOTION: … … int sdl_default_handle_event(SDL_Event *event) 206 191 case SDL_KEYDOWN: 207 192 mpkey = lookup_keymap_table(keysym_map, event->key.keysym.sym); 208 193 if (!mpkey && 209 event->key.keysym.unicode > 0 && 210 event->key.keysym.unicode < 128) 211 mpkey = event->key.keysym.unicode; 194 event->key.keysym.sym > 0 && 195 event->key.keysym.sym < 128) 196 mpkey = (char)event->key.keysym.sym; 197 if (mpkey >= 'a' && mpkey <= 'z' && 198 event->key.keysym.mod & KMOD_SHIFT) { 199 mpkey -= 32; 200 } 212 201 if (mpkey) 213 202 mplayer_put_key(mpkey); 214 203 break; -
libvo/sdl_common.h
diff --git a/libvo/sdl_common.h b/libvo/sdl_common.h index d7f81da..bfa8ad9 100644
a b 24 24 #include "config.h" 25 25 #include <stdint.h> 26 26 #ifdef CONFIG_SDL_SDL_H 27 #include <SDL /SDL.h>27 #include <SDL2/SDL.h> 28 28 #else 29 29 #include <SDL.h> 30 30 #endif -
libvo/video_out.c
diff --git a/libvo/video_out.c b/libvo/video_out.c index bcf5174..f167293 100644
a b const vo_functions_t* const video_out_drivers[] = 208 208 &video_out_x11, 209 209 &video_out_xover, 210 210 #endif 211 #ifdef CONFIG_SDL212 &video_out_sdl,213 #endif214 211 #ifdef CONFIG_GL 215 212 &video_out_gl, 216 213 #endif
