- fixed colors' bug (TODO: write a function in vout that recalculate colors

    from RGB masks);
  - cleaning of the fullscreen switch, still sucks but the surface is not
    reallocated and that's good (thanks to the magic function
    SDL_WM_ToggleFullScreen provided by sdl library :).
parent 3ce24ee9
......@@ -2,7 +2,7 @@
* intf_sdl.c: SDL interface plugin
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: intf_sdl.c,v 1.20 2001/01/08 01:07:21 bozo Exp $
* $Id: intf_sdl.c,v 1.21 2001/01/08 22:42:50 bozo Exp $
*
* Authors:
*
......@@ -50,16 +50,6 @@
#include "main.h"
/*****************************************************************************
* intf_sys_t: description and status of SDL interface
*****************************************************************************/
typedef struct intf_sys_s
{
/* SDL system information */
SDL_Surface * p_display;
boolean_t b_Fullscreen;
} intf_sys_t;
typedef struct vout_sys_s
{
int i_width;
......@@ -68,6 +58,7 @@ typedef struct vout_sys_s
SDL_Overlay * p_overlay;
boolean_t b_fullscreen;
boolean_t b_reopen_display;
boolean_t b_toggle_fullscreen;
Uint8 * p_buffer[2];
/* Buffers informations */
} vout_sys_t;
......@@ -92,14 +83,6 @@ int intf_SDLCreate( intf_thread_t *p_intf )
return( 1 );
}
/* Allocate instance and initialize some members */
p_intf->p_sys = malloc( sizeof( intf_sys_t ) );
if( p_intf->p_sys == NULL )
{
intf_ErrMsg("error: %s", strerror(ENOMEM) );
return( 1 );
}
/* Spawn video output thread */
p_intf->p_vout = vout_CreateThread( main_GetPszVariable( VOUT_DISPLAY_VAR,
NULL), 0,
......@@ -107,8 +90,7 @@ int intf_SDLCreate( intf_thread_t *p_intf )
VOUT_WIDTH_DEFAULT ),
main_GetIntVariable( VOUT_HEIGHT_VAR,
VOUT_HEIGHT_DEFAULT ),
NULL, 0,
(void *)&p_intf->p_sys->p_display );
NULL, 0, NULL );
if( p_intf->p_vout == NULL ) /* error */
{
......@@ -136,12 +118,6 @@ void intf_SDLDestroy( intf_thread_t *p_intf )
{
vout_DestroyThread( p_intf->p_vout, NULL );
}
/* Destroy structure */
SDL_FreeSurface( p_intf->p_sys->p_display ); /* destroy the "screen" */
SDL_Quit();
free( p_intf->p_sys );
}
......@@ -201,7 +177,6 @@ void intf_SDL_Resize( intf_thread_t * p_intf, int width, int height )
void intf_SDL_YUVSwitch(intf_thread_t * p_intf)
{
vlc_mutex_lock( &p_intf->p_vout->change_lock );
// p_intf->p_vout->p_sys->b_must_acquire = 0;
p_intf->p_vout->b_need_render = 1 - p_intf->p_vout->b_need_render;
intf_DbgMsg( "need render now : '%d'",p_intf->p_vout->b_need_render);
p_intf->p_vout->p_sys->b_reopen_display = 1;
......@@ -211,7 +186,7 @@ void intf_SDL_Fullscreen(intf_thread_t * p_intf)
{
vlc_mutex_lock( &p_intf->p_vout->change_lock );
p_intf->p_vout->p_sys->b_fullscreen = 1-p_intf->p_vout->p_sys->b_fullscreen;
p_intf->p_vout->p_sys->b_reopen_display = 1;
p_intf->p_vout->p_sys->b_toggle_fullscreen = 1;
vlc_mutex_unlock( &p_intf->p_vout->change_lock );
}
......
......@@ -56,6 +56,7 @@ typedef struct vout_sys_s
SDL_Overlay * p_overlay; /* overlay device */
boolean_t b_fullscreen;
boolean_t b_reopen_display;
boolean_t b_toggle_fullscreen;
Uint8 * p_buffer[2];
/* Buffers informations */
} vout_sys_t;
......@@ -65,6 +66,7 @@ typedef struct vout_sys_s
*****************************************************************************/
static int SDLOpenDisplay ( vout_thread_t *p_vout );
static void SDLCloseDisplay ( vout_thread_t *p_vout );
static void SDLToggleFullScreen ( vout_thread_t *p_vout );
/*****************************************************************************
* vout_SDLCreate: allocate SDL video thread output method
......@@ -113,7 +115,14 @@ int vout_SDLCreate( vout_thread_t *p_vout, char *psz_display,
p_vout->p_sys->i_width = VOUT_WIDTH_DEFAULT;
p_vout->p_sys->i_height = VOUT_HEIGHT_DEFAULT;
p_vout->p_sys->b_reopen_display = 1;
if( SDLOpenDisplay(p_vout) )
{
intf_ErrMsg( "error: can't initialize SDL library: %s",
SDL_GetError() );
return( 1 );
}
p_vout->p_sys->b_toggle_fullscreen = 0;
return( 0 );
}
......@@ -125,13 +134,6 @@ int vout_SDLCreate( vout_thread_t *p_vout, char *psz_display,
*****************************************************************************/
int vout_SDLInit( vout_thread_t *p_vout )
{
if( SDLOpenDisplay(p_vout) )
{
intf_ErrMsg( "error: can't initialize SDL library: %s",
SDL_GetError() );
return( 1 );
}
return( 0 );
}
......@@ -175,6 +177,13 @@ int vout_SDLManage( vout_thread_t *p_vout )
return( 1 );
}
}
/* if fullscreen has to be toggled we do so */
if( p_vout->p_sys->b_toggle_fullscreen )
{
SDLToggleFullScreen(p_vout);
}
return( 0 );
}
......@@ -187,7 +196,7 @@ int vout_SDLManage( vout_thread_t *p_vout )
void vout_SDLDisplay( vout_thread_t *p_vout )
{
SDL_Rect disp;
if(p_vout->p_sys->p_display && !p_vout->p_sys->b_reopen_display)
if((p_vout->p_sys->p_display != NULL) && !p_vout->p_sys->b_reopen_display)
{
if(p_vout->b_need_render)
{
......@@ -368,14 +377,31 @@ static void SDLCloseDisplay( vout_thread_t *p_vout )
{
if( p_vout->p_sys->p_display != NULL )
{
SDL_UnlockSurface ( p_vout->p_sys->p_display );
if( p_vout->p_sys->p_overlay != NULL )
{
SDL_FreeYUVOverlay(p_vout->p_sys->p_overlay);
p_vout->p_sys->p_overlay = NULL;
}
SDL_UnlockSurface ( p_vout->p_sys->p_display );
SDL_FreeSurface( p_vout->p_sys->p_display );
p_vout->p_sys->p_display = NULL;
}
}
/*****************************************************************************
* SDLToggleFullScreen: toggle fullscreen
*****************************************************************************
* This function toggles the fullscreen state of the surface.
*****************************************************************************/
static void SDLToggleFullScreen( vout_thread_t *p_vout )
{
SDL_WM_ToggleFullScreen(p_vout->p_sys->p_display);
if( p_vout->p_sys->b_fullscreen )
SDL_ShowCursor( 0 );
else
SDL_ShowCursor( 1 );
p_vout->p_sys->b_toggle_fullscreen = 0;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment