]> git.sesse.net Git - vlc/blobdiff - plugins/sdl/vout_sdl.c
* Ported Glide and MGA plugins to the new module API. MGA never worked,
[vlc] / plugins / sdl / vout_sdl.c
index b68504b419b1e60d3b3ad01060ca98250c8cce6e..73a8a24137383c4201a7810f59a8f287ca9177c9 100644 (file)
@@ -22,6 +22,9 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
+#define MODULE_NAME sdl
+#include "modules_inner.h"
+
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
@@ -90,6 +93,8 @@ static void vout_End       ( struct vout_thread_s * );
 static void vout_Destroy   ( struct vout_thread_s * );
 static int  vout_Manage    ( struct vout_thread_s * );
 static void vout_Display   ( struct vout_thread_s * );
+static void vout_SetPalette( p_vout_thread_t p_vout, u16 *red, u16 *green,
+                             u16 *blue, u16 *transp );
 
 static int  SDLOpenDisplay      ( vout_thread_t *p_vout );
 static void SDLCloseDisplay     ( vout_thread_t *p_vout );
@@ -98,7 +103,7 @@ static void SDLCloseDisplay     ( vout_thread_t *p_vout );
  * Functions exported as capabilities. They are declared as static so that
  * we don't pollute the namespace too much.
  *****************************************************************************/
-void vout_getfunctions( function_list_t * p_function_list )
+void _M( vout_getfunctions )( function_list_t * p_function_list )
 {
     p_function_list->pf_probe = vout_Probe;
     p_function_list->functions.vout.pf_create     = vout_Create;
@@ -107,7 +112,7 @@ void vout_getfunctions( function_list_t * p_function_list )
     p_function_list->functions.vout.pf_destroy    = vout_Destroy;
     p_function_list->functions.vout.pf_manage     = vout_Manage;
     p_function_list->functions.vout.pf_display    = vout_Display;
-    p_function_list->functions.vout.pf_setpalette = NULL;
+    p_function_list->functions.vout.pf_setpalette = vout_SetPalette;
 }
 
 /*****************************************************************************
@@ -133,7 +138,7 @@ static int vout_Probe( probedata_t *p_data )
  * vout properties to choose the correct mode, and change them according to the
  * mode actually used.
  *****************************************************************************/
-int vout_Create( vout_thread_t *p_vout )
+static int vout_Create( vout_thread_t *p_vout )
 {
     /* Allocate structure */
     p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
@@ -152,12 +157,6 @@ int vout_Create( vout_thread_t *p_vout )
         return( 1 );
     }
 
-    /* Force the software yuv even if it is not used */
-    /* If we don't do this, p_vout is not correctly initialized
-       and it's impossible to switch between soft/hard yuv */
-    /* FIXME: this is a broken way to do !! fix this !! */
-    p_vout->b_need_render = 1;
-
     p_vout->p_sys->b_cursor = 1; /* TODO should be done with a main_GetInt.. */
     p_vout->p_sys->b_fullscreen = main_GetIntVariable( VOUT_FULLSCREEN_VAR,
                                 VOUT_FULLSCREEN_DEFAULT );
@@ -173,7 +172,7 @@ int vout_Create( vout_thread_t *p_vout )
 
     if( SDLOpenDisplay(p_vout) )
     {
-        intf_ErrMsg( "vout error: can't initialize SDL (%s)", SDL_GetError() );
+        intf_ErrMsg( "vout error: can't set up SDL (%s)", SDL_GetError() );
         free( p_vout->p_sys );
         return( 1 );
     }
@@ -212,8 +211,21 @@ int vout_Create( vout_thread_t *p_vout )
  *****************************************************************************
  * This function initialize the SDL display device.
  *****************************************************************************/
-int vout_Init( vout_thread_t *p_vout )
+static int vout_Init( vout_thread_t *p_vout )
 {
+    /* This hack is hugly, but hey, you are, too. */
+
+    SDL_Overlay *   p_overlay;
+
+    p_overlay = SDL_CreateYUVOverlay( VOUT_WIDTH_DEFAULT, VOUT_HEIGHT_DEFAULT,
+                                      SDL_YV12_OVERLAY, 
+                                      p_vout->p_sys->p_display );
+    intf_Msg( "vout: YUV acceleration %s",
+              p_overlay->hw_overlay ? "activated" : "unavailable !" ); 
+    p_vout->b_need_render = !p_overlay->hw_overlay;
+
+    SDL_FreeYUVOverlay( p_overlay );
+
     return( 0 );
 }
 
@@ -222,7 +234,7 @@ int vout_Init( vout_thread_t *p_vout )
  *****************************************************************************
  * Terminate an output method created by vout_SDLCreate
  *****************************************************************************/
-void vout_End( vout_thread_t *p_vout )
+static void vout_End( vout_thread_t *p_vout )
 {
     SDLCloseDisplay( p_vout );
     SDL_Quit();
@@ -233,7 +245,7 @@ void vout_End( vout_thread_t *p_vout )
  *****************************************************************************
  * Terminate an output method created by vout_SDLCreate
  *****************************************************************************/
-void vout_Destroy( vout_thread_t *p_vout )
+static void vout_Destroy( vout_thread_t *p_vout )
 {
     free( p_vout->p_sys );
 }
@@ -244,7 +256,7 @@ void vout_Destroy( vout_thread_t *p_vout )
  * This function should be called regularly by video output thread. It returns
  * a non null value if an error occured.
  *****************************************************************************/
-int vout_Manage( vout_thread_t *p_vout )
+static int vout_Manage( vout_thread_t *p_vout )
 {
     SDL_Event event;                                            /* SDL event */
     Uint8   i_key;
@@ -260,16 +272,21 @@ int vout_Manage( vout_thread_t *p_vout )
             p_vout->i_changes |= VOUT_SIZE_CHANGE;
             break;
 
+        case SDL_MOUSEBUTTONUP:
+            switch( event.button.button )
+            {
+            case SDL_BUTTON_RIGHT:
+                p_main->p_intf->b_menu_change = 1;
+                break;
+            }
+            break;
+
         case SDL_MOUSEBUTTONDOWN:
             switch( event.button.button )
             {
             case SDL_BUTTON_MIDDLE:
                 p_vout->i_changes |= VOUT_CURSOR_CHANGE;
                 break;
-
-            case SDL_BUTTON_RIGHT:
-                p_main->p_intf->b_menu_change = 1;
-                break;
             }
             break;
 
@@ -335,7 +352,7 @@ int vout_Manage( vout_thread_t *p_vout )
         SDLCloseDisplay( p_vout );
         if( SDLOpenDisplay( p_vout ) )
         {
-          intf_ErrMsg( "error: can't open DISPLAY default display" );
+          intf_ErrMsg( "vout error: can't reopen display after resize" );
           return( 1 );
         }
         p_vout->i_changes &= ~VOUT_SIZE_CHANGE;
@@ -352,7 +369,7 @@ int vout_Manage( vout_thread_t *p_vout )
         SDLCloseDisplay( p_vout );
         if( SDLOpenDisplay( p_vout ) )
         {
-          intf_ErrMsg( "error: can't open DISPLAY default display" );
+          intf_ErrMsg( "error: can't reopen display after YUV change" );
           return( 1 );
         }
         p_vout->i_changes &= ~VOUT_YUV_CHANGE;
@@ -411,7 +428,7 @@ int vout_Manage( vout_thread_t *p_vout )
  * anything, but could later send information on which colors it was unable
  * to set.
  *****************************************************************************/
-void vout_SetPalette( p_vout_thread_t p_vout, u16 *red, u16 *green,
+static void vout_SetPalette( p_vout_thread_t p_vout, u16 *red, u16 *green,
                          u16 *blue, u16 *transp)
 {
      /* Create a display surface with a grayscale palette */
@@ -440,7 +457,7 @@ void vout_SetPalette( p_vout_thread_t p_vout, u16 *red, u16 *green,
  * This function send the currently rendered image to the display, wait until
  * it is displayed and switch the two rendering buffer, preparing next frame.
  *****************************************************************************/
-void vout_Display( vout_thread_t *p_vout )
+static void vout_Display( vout_thread_t *p_vout )
 {
     SDL_Rect    disp;
     if((p_vout->p_sys->p_display != NULL) && !p_vout->p_sys->b_reopen_display)
@@ -531,13 +548,13 @@ static int SDLOpenDisplay( vout_thread_t *p_vout )
     else
         flags |= SDL_SWSURFACE; /* save video memory */
 
-    bpp = SDL_VideoModeOK(p_vout->p_sys->i_width,
-                          p_vout->p_sys->i_height,
-                          p_vout->i_screen_depth, flags);
+    bpp = SDL_VideoModeOK( p_vout->p_sys->i_width,
+                           p_vout->p_sys->i_height,
+                           p_vout->i_screen_depth, flags );
 
     if(bpp == 0)
     {
-        intf_ErrMsg( "error: can't open DISPLAY default display" );
+        intf_ErrMsg( "vout error: no video mode available" );
         return( 1 );
     }
 
@@ -547,7 +564,7 @@ static int SDLOpenDisplay( vout_thread_t *p_vout )
 
     if( p_vout->p_sys->p_display == NULL )
     {
-        intf_ErrMsg( "error: can't open DISPLAY default display" );
+        intf_ErrMsg( "vout error: cannot set video mode" );
         return( 1 );
     }
 
@@ -558,9 +575,9 @@ static int SDLOpenDisplay( vout_thread_t *p_vout )
     else
         SDL_ShowCursor( 1 );
 
-    SDL_WM_SetCaption( VOUT_TITLE , VOUT_TITLE );
+    SDL_WM_SetCaption( VOUT_TITLE " (SDL output)",
+                       VOUT_TITLE " (SDL output)" );
     SDL_EventState(SDL_KEYUP , SDL_IGNORE);                /* ignore keys up */
-    SDL_EventState(SDL_MOUSEBUTTONUP, SDL_IGNORE);          
 
     if( p_vout->b_need_render )
     {