Commit 5f6c5900 authored by Damien Lucas's avatar Damien Lucas
Browse files

. Fixed a FIXME in SDL: p_vout->p_sys is no more used in intf_sdl.c

. Used instead p_vout->i_changes like in x11
parent d04b152b
......@@ -219,9 +219,11 @@ typedef struct vout_thread_s
#define VOUT_GRAYSCALE_CHANGE 0x0002 /* b_grayscale changed */
#define VOUT_INTF_CHANGE 0x0004 /* b_interface changed */
#define VOUT_SCALE_CHANGE 0x0008 /* b_scale changed */
#define VOUT_GAMMA_CHANGE 0x0010 /* gamma changed */
#define VOUT_CURSOR_CHANGE 0x0020 /* b_cursor changed */
#define VOUT_FULLSCREEN_CHANGE 0x0040 /* b_fullscreen changed */
#define VOUT_SIZE_CHANGE 0x0200 /* size changed */
#define VOUT_DEPTH_CHANGE 0x0400 /* depth changed */
#define VOUT_GAMMA_CHANGE 0x0010 /* gamma changed */
#define VOUT_YUV_CHANGE 0x0800 /* change yuv tables */
/* Disabled for thread deadlocks issues --Meuuh */
......
......@@ -2,7 +2,7 @@
* intf_sdl.c: SDL interface plugin
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: intf_sdl.c,v 1.25 2001/02/05 15:50:57 nitrox Exp $
* $Id: intf_sdl.c,v 1.26 2001/02/06 00:56:55 nitrox Exp $
*
* Authors:
*
......@@ -50,30 +50,8 @@
#include "main.h"
/* FIXME: SOME CLUELESS MORON DEFINED THIS STRUCTURE IN VOUT_SDL.C AS WELL */
typedef struct vout_sys_s
{
int i_width;
int i_height;
SDL_Surface * p_display; /* display device */
SDL_Overlay * p_overlay;
boolean_t b_fullscreen;
boolean_t b_overlay;
boolean_t b_cursor; /* 1 if hide 0 else */
boolean_t b_reopen_display;
boolean_t b_toggle_fullscreen;
boolean_t b_hide_cursor;
Uint8 * p_buffer[2];
/* Buffers informations */
} vout_sys_t;
/* local prototype */
void intf_SDL_Keymap( intf_thread_t * p_intf );
void intf_SDL_Resize( intf_thread_t * p_intf, int width, int height );
void intf_SDL_Fullscreen(intf_thread_t * p_intf);
void intf_SDL_YUVSwitch(intf_thread_t * p_intf);
void intf_SDL_Hidecursor(intf_thread_t * p_intf);
/*****************************************************************************
* intf_SDLCreate: initialize and create SDL interface
......@@ -133,87 +111,65 @@ void intf_SDLManage( intf_thread_t *p_intf )
SDL_Event event; /* SDL event */
Uint8 i_key;
if( p_intf->p_vout->p_sys->b_overlay )
{
intf_SDL_YUVSwitch(p_intf);
p_intf->p_vout->p_sys->b_overlay = 0;
}
while ( SDL_PollEvent(&event) )
{
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 */
i_key = event.key.keysym.sym; /* forward it */
switch(i_key) {
/* switch to fullscreen */
case SDLK_f:
intf_SDL_Fullscreen(p_intf);
break;
case SDLK_y:
intf_SDL_YUVSwitch(p_intf);
break;
default :
if( intf_ProcessKey( p_intf, (char ) i_key ) )
{
intf_DbgMsg( "unhandled key '%c' (%i)",
(char) i_key, i_key );
}
break;
}
break;
switch (event.type)
{
case SDL_VIDEORESIZE: /* Resizing of window */
intf_Msg( "intf: video display resized (%dx%d)", event.resize.w
, event.resize.h );
vlc_mutex_lock( &p_intf->p_vout->change_lock );
p_intf->p_vout->i_width = event.resize.w;
p_intf->p_vout->i_height = event.resize.h;
p_intf->p_vout->i_changes |= VOUT_SIZE_CHANGE;
vlc_mutex_unlock( &p_intf->p_vout->change_lock );
break;
case SDL_MOUSEBUTTONDOWN:
if(event.button.button==SDL_BUTTON_MIDDLE)
{
intf_SDL_Hidecursor(p_intf);
}
case SDL_KEYDOWN: /* if a key is pressed */
i_key = event.key.keysym.sym;
switch(i_key)
{
case SDLK_f: /* switch to fullscreen */
vlc_mutex_lock( &p_intf->p_vout->change_lock );
p_intf->p_vout->i_changes |= VOUT_FULLSCREEN_CHANGE;
vlc_mutex_unlock( &p_intf->p_vout->change_lock );
break;
case SDL_QUIT:
intf_ProcessKey( p_intf, SDLK_q );
break;
default:
case SDLK_y: /* switch to hard YUV */
vlc_mutex_lock( &p_intf->p_vout->change_lock );
p_intf->p_vout->i_changes |= VOUT_YUV_CHANGE;
vlc_mutex_unlock( &p_intf->p_vout->change_lock );
break;
default:
if( intf_ProcessKey( p_intf, (char )i_key ) )
{
intf_DbgMsg( "unhandled key '%c' (%i)", (char)i_key, i_key );
}
break;
}
break;
case SDL_MOUSEBUTTONDOWN:
if( event.button.button == SDL_BUTTON_MIDDLE )
{
vlc_mutex_lock( &p_intf->p_vout->change_lock );
p_intf->p_vout->i_changes |= VOUT_CURSOR_CHANGE;
vlc_mutex_unlock( &p_intf->p_vout->change_lock );
}
break;
case SDL_QUIT:
intf_ProcessKey( p_intf, SDLK_q );
break;
default:
break;
}
}
}
void intf_SDL_Resize( intf_thread_t * p_intf, int width, int height )
{
intf_Msg( "intf: video display resized (%dx%d)", width, height );
vlc_mutex_lock( &p_intf->p_vout->change_lock );
p_intf->p_vout->p_sys->i_width = width;
p_intf->p_vout->p_sys->i_height = height;
p_intf->p_vout->p_sys->b_reopen_display = 1;
vlc_mutex_unlock( &p_intf->p_vout->change_lock );
}
void intf_SDL_YUVSwitch(intf_thread_t * p_intf)
{
vlc_mutex_lock( &p_intf->p_vout->change_lock );
p_intf->p_vout->b_need_render = 1 - p_intf->p_vout->b_need_render;
p_intf->p_vout->p_sys->b_reopen_display = 1;
vlc_mutex_unlock( &p_intf->p_vout->change_lock );
}
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_toggle_fullscreen = 1;
vlc_mutex_unlock( &p_intf->p_vout->change_lock );
}
void intf_SDL_Hidecursor(intf_thread_t * p_intf)
{
vlc_mutex_lock(&p_intf->p_vout->change_lock);
p_intf->p_vout->p_sys->b_cursor = 1 - p_intf->p_vout->p_sys->b_cursor;
p_intf->p_vout->p_sys->b_hide_cursor=1;
vlc_mutex_unlock(&p_intf->p_vout->change_lock);
}
void intf_SDL_Keymap(intf_thread_t * p_intf )
{
/* p_intf->p_intf_getKey = intf_getKey; */
......@@ -242,4 +198,3 @@ void intf_SDL_Keymap(intf_thread_t * p_intf )
intf_AssignKey(p_intf, SDLK_s, INTF_KEY_TOGGLE_SCALING, 0);
}
......@@ -49,7 +49,7 @@
* This structure is part of the video output thread descriptor.
* It describes the SDL specific properties of an output thread.
*****************************************************************************/
/* FIXME: SOME CLUELESS MORON DEFINED THIS STRUCTURE IN INTF_SDL.C AS WELL */
/* FIXME: SOME CLUELESS MORON DEFINED THIS STRUCTURE IN INTF_SDL.C AS WELL */
typedef struct vout_sys_s
{
int i_width;
......@@ -60,8 +60,6 @@ typedef struct vout_sys_s
boolean_t b_overlay;
boolean_t b_cursor;
boolean_t b_reopen_display;
boolean_t b_toggle_fullscreen;
boolean_t b_hide_cursor;
Uint8 * p_buffer[2];
/* Buffers informations */
} vout_sys_t;
......@@ -72,7 +70,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 );
static void SDLHideCursor ( vout_thread_t *p_vout );
static void SDLTogglePointer ( vout_thread_t *p_vout );
/*****************************************************************************
* vout_SDLCreate: allocate SDL video thread output method
*****************************************************************************
......@@ -124,11 +122,10 @@ int vout_SDLCreate( vout_thread_t *p_vout, char *psz_display,
{
intf_ErrMsg( "error: can't initialize SDL library: %s",
SDL_GetError() );
free( p_vout->p_sys );
return( 1 );
}
p_vout->p_sys->b_toggle_fullscreen = 0;
p_vout->p_sys->b_hide_cursor = 0;
return( 0 );
}
......@@ -171,28 +168,61 @@ void vout_SDLDestroy( vout_thread_t *p_vout )
*****************************************************************************/
int vout_SDLManage( vout_thread_t *p_vout )
{
/* If the display has to be reopened we do so */
if( p_vout->p_sys->b_reopen_display )
/*
* Size Change
*/
if ( p_vout->i_changes & VOUT_SIZE_CHANGE )
{
SDLCloseDisplay(p_vout);
p_vout->p_sys->i_width = p_vout->i_width;
p_vout->p_sys->i_height = p_vout->i_height;
if( SDLOpenDisplay(p_vout) )
/* Need to reopen display */
SDLCloseDisplay( p_vout );
if ( SDLOpenDisplay( p_vout ) )
{
intf_ErrMsg( "error: can't open DISPLAY default display" );
return( 1 );
intf_ErrMsg( "error: can't open DISPLAY default display" );
return( 1 );
}
p_vout->i_changes &= ~VOUT_SIZE_CHANGE;
}
/* if fullscreen has to be toggled we do so */
if( p_vout->p_sys->b_toggle_fullscreen )
/*
* YUV Change
*/
if ( p_vout->i_changes & VOUT_YUV_CHANGE )
{
p_vout->b_need_render = 1 - p_vout->b_need_render;
/* Need to reopen display */
SDLCloseDisplay( p_vout );
if ( SDLOpenDisplay( p_vout ) )
{
intf_ErrMsg( "error: can't open DISPLAY default display" );
return( 1 );
}
p_vout->i_changes &= ~VOUT_YUV_CHANGE;
}
/*
* Fullscreen change
*/
if ( p_vout->i_changes & VOUT_FULLSCREEN_CHANGE )
{
SDLToggleFullScreen(p_vout);
p_vout->p_sys->b_fullscreen = 1 - p_vout->p_sys->b_fullscreen;
SDLToggleFullScreen( p_vout );
p_vout->i_changes &= ~VOUT_FULLSCREEN_CHANGE;
}
/* if pointer has to be hidden/shown we do so */
if( p_vout->p_sys->b_hide_cursor )
/*
* Pointer change
*/
if ( p_vout->i_changes & VOUT_CURSOR_CHANGE )
{
SDLHideCursor(p_vout);
p_vout->p_sys->b_cursor = 1 - p_vout->p_sys->b_cursor;
SDLTogglePointer( p_vout );
}
return( 0 );
......@@ -205,7 +235,8 @@ int vout_SDLManage( vout_thread_t *p_vout )
* anything, but could later send information on which colors it was unable
* to set.
*****************************************************************************/
void vout_SDLSetPalette( p_vout_thread_t p_vout, u16 *red, u16 *green, u16 *blue, u16 *transp)
void vout_SDLSetPalette( p_vout_thread_t p_vout, u16 *red, u16 *green,
u16 *blue, u16 *transp)
{
/* Create a display surface with a grayscale palette */
SDL_Color colors[256];
......@@ -401,8 +432,6 @@ static int SDLOpenDisplay( vout_thread_t *p_vout )
p_vout->p_sys->p_buffer[ 1 ] );
}
p_vout->i_changes |= VOUT_YUV_CHANGE;
p_vout->p_sys->b_reopen_display = 0;
return( 0 );
......@@ -449,16 +478,15 @@ static void SDLToggleFullScreen( vout_thread_t *p_vout )
p_vout->p_sys->b_cursor=0;
}
p_vout->p_sys->b_toggle_fullscreen = 0;
SDLHideCursor(p_vout);
SDLTogglePointer( p_vout );
}
/*****************************************************************************
* SDLHideCursor: Hide/Show mouse pointer
* SDLTogglePointer: Hide/Show mouse pointer
*****************************************************************************
* This function hides/shows the mouse pointer inside the main window.
*****************************************************************************/
static void SDLHideCursor( vout_thread_t *p_vout )
static void SDLTogglePointer( vout_thread_t *p_vout )
{
if( p_vout->p_sys->b_cursor==1 )
{
......@@ -468,5 +496,4 @@ static void SDLHideCursor( vout_thread_t *p_vout )
{
SDL_ShowCursor( 1 );
}
p_vout->p_sys->b_hide_cursor = 0;
}
......@@ -2068,9 +2068,10 @@ static int Manage( vout_thread_t *p_vout )
/* Clear changes flags which does not need management or have been
* handled */
p_vout->i_changes &= ~(VOUT_GAMMA_CHANGE | VOUT_GRAYSCALE_CHANGE |
VOUT_YUV_CHANGE | VOUT_INFO_CHANGE |
VOUT_INTF_CHANGE | VOUT_SCALE_CHANGE );
p_vout->i_changes &= ~(VOUT_GAMMA_CHANGE | VOUT_GRAYSCALE_CHANGE |
VOUT_YUV_CHANGE | VOUT_INFO_CHANGE |
VOUT_INTF_CHANGE | VOUT_SCALE_CHANGE |
VOUT_CURSOR_CHANGE | VOUT_FULLSCREEN_CHANGE );
/* Detect unauthorized changes */
if( p_vout->i_changes )
......
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