* intf_sdl.c: SDL interface plugin
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
- * $Id: intf_sdl.c,v 1.19 2001/01/05 18:46:43 massiot Exp $
+ * $Id: intf_sdl.c,v 1.20 2001/01/08 01:07:21 bozo Exp $
*
* Authors:
*
boolean_t b_reopen_display;
Uint8 * p_buffer[2];
/* Buffers informations */
- boolean_t b_must_acquire; /* must be acquired before writing */
} vout_sys_t;
switch (event.type) {
case SDL_VIDEORESIZE: /* Resizing of window */
intf_SDL_Resize( p_intf, event.resize.w, event.resize.h );
+ break;
case SDL_KEYDOWN: /* if a key is pressed */
switch(i_key) {
/* switch to fullscreen */
break;
}
break;
-
case SDL_QUIT:
intf_ProcessKey( p_intf, INTF_KEY_QUIT );
break;
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->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;
boolean_t b_reopen_display;
Uint8 * p_buffer[2];
/* Buffers informations */
- boolean_t b_must_acquire; /* must be acquired before writing */
} vout_sys_t;
/*****************************************************************************
p_vout->p_sys->p_display = NULL;
p_vout->p_sys->p_overlay = NULL;
- p_vout->p_sys->b_must_acquire = 0;
/* Initialize library */
if( SDL_Init(SDL_INIT_VIDEO) < 0 )
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 = 0;
-
- if( SDLOpenDisplay(p_vout) )
- {
- intf_ErrMsg( "error: can't initialize SDL library: %s",
- SDL_GetError() );
- free( p_vout->p_sys );
- return( 1 );
- }
+ p_vout->p_sys->b_reopen_display = 1;
return( 0 );
}
*****************************************************************************/
int vout_SDLInit( vout_thread_t *p_vout )
{
- /* Acquire first buffer */
- if( p_vout->p_sys->b_must_acquire )
+ if( SDLOpenDisplay(p_vout) )
{
- SDL_LockSurface(p_vout->p_sys->p_display);
+ intf_ErrMsg( "error: can't initialize SDL library: %s",
+ SDL_GetError() );
+ return( 1 );
}
return( 0 );
*****************************************************************************/
void vout_SDLEnd( vout_thread_t *p_vout )
{
- /* Release buffer */
- if( p_vout->p_sys->b_must_acquire )
- {
- SDL_UnlockSurface ( p_vout->p_sys->p_display );
- }
- free( p_vout->p_sys );
+ SDLCloseDisplay( p_vout );
+ SDL_Quit();
}
/*****************************************************************************
*****************************************************************************/
void vout_SDLDestroy( vout_thread_t *p_vout )
{
- SDLCloseDisplay( p_vout );
free( p_vout->p_sys );
}
/* If the display has to be reopened we do so */
if( p_vout->p_sys->b_reopen_display )
{
- p_vout->p_sys->b_must_acquire = 0;
- if( p_vout->p_sys->p_display )
- {
- if( p_vout->p_sys->p_overlay )
- {
- SDL_FreeYUVOverlay(p_vout->p_sys->p_overlay);
- p_vout->p_sys->p_overlay = NULL;
- }
- SDL_FreeSurface( p_vout->p_sys->p_display );
- p_vout->p_sys->p_display = NULL;
- }
+ SDLCloseDisplay(p_vout);
if( SDLOpenDisplay(p_vout) )
{
intf_ErrMsg( "error: can't open DISPLAY default display" );
return( 1 );
}
- p_vout->p_sys->b_reopen_display = 0;
}
return( 0 );
}
void vout_SDLDisplay( vout_thread_t *p_vout )
{
SDL_Rect disp;
- if(p_vout->b_need_render)
- {
- /* Change display frame */
- if( p_vout->p_sys->b_must_acquire )
- {
-
+ if(p_vout->p_sys->p_display && !p_vout->p_sys->b_reopen_display)
+ {
+ if(p_vout->b_need_render)
+ {
+ /* Change display frame */
SDL_Flip( p_vout->p_sys->p_display );
-
- /* Swap buffers and change write frame */
- //SDL_LockSurface ( p_vout->p_sys->p_display );
}
- }
- else
- {
-
- /*
- * p_vout->p_rendered_pic->p_y/u/v contains the YUV buffers to render
- */
- if( p_vout->p_sys->b_must_acquire )
+ else
{
+
+ /*
+ * p_vout->p_rendered_pic->p_y/u/v contains the YUV buffers to
+ * render
+ */
/* TODO: support for streams other than 4:2:0 */
/* create the overlay if necessary */
if( p_vout->p_sys->p_overlay == NULL )
return( 1 );
}
+ SDL_LockSurface(p_vout->p_sys->p_display);
+
if( p_vout->p_sys->b_fullscreen )
SDL_ShowCursor( 0 );
else
p_vout->i_changes |= VOUT_YUV_CHANGE;
- /* Check buffers properties */
- p_vout->p_sys->b_must_acquire = 1; /* always acquire */
+ p_vout->p_sys->b_reopen_display = 0;
return( 0 );
}
*****************************************************************************/
static void SDLCloseDisplay( vout_thread_t *p_vout )
{
- /*
if( p_vout->p_sys->p_display != NULL )
{
- p_vout->p_sys->b_must_acquire = 0;
+ SDL_UnlockSurface ( p_vout->p_sys->p_display );
if( p_vout->p_sys->p_overlay != NULL )
{
SDL_FreeYUVOverlay(p_vout->p_sys->p_overlay);
SDL_FreeSurface( p_vout->p_sys->p_display );
p_vout->p_sys->p_display = NULL;
}
- */
- SDL_Quit();
-
- /* Prevents from cleaning, but prevents from SEGfaulting */
}