Commit 2737d4c1 authored by Gildas Bazin's avatar Gildas Bazin

* Fixed a segfault in yuv_End() in video_yuvmmx.c
* Fixed the "Gdk-ERROR **: BadCursor" bug in the x11 and xvideo plugins
* Fixed a segfault in SetBufferPicture() in video_output.c. This segfault
    only happened with the xvideo plugin because this one is not using
    SetBuffers().

PS: The last fix broke the overlay output of SDL (black screen) I will
  investigate this later on.
parent dbfcf9f6
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* vout_x11.c: X11 video output display method * vout_x11.c: X11 video output display method
***************************************************************************** *****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN * Copyright (C) 1998, 1999, 2000 VideoLAN
* $Id: vout_x11.c,v 1.29 2001/07/07 17:45:28 sam Exp $ * $Id: vout_x11.c,v 1.30 2001/08/03 16:04:17 gbazin Exp $
* *
* Authors: Vincent Seguin <seguin@via.ecp.fr> * Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org> * Samuel Hocevar <sam@zoy.org>
...@@ -109,11 +109,11 @@ typedef struct vout_sys_s ...@@ -109,11 +109,11 @@ typedef struct vout_sys_s
int i_ss_blanking; /* blanking mode */ int i_ss_blanking; /* blanking mode */
int i_ss_exposure; /* exposure mode */ int i_ss_exposure; /* exposure mode */
/* Auto-hide cursor */
mtime_t i_lastmoved;
/* Mouse pointer properties */ /* Mouse pointer properties */
boolean_t b_mouse; /* is the mouse pointer displayed ? */ mtime_t i_lastmoved; /* Auto-hide cursor */
boolean_t b_mouse_pointer_visible;
Cursor blank_cursor; /* the hidden cursor */
Pixmap cursor_pixmap;
} vout_sys_t; } vout_sys_t;
...@@ -151,7 +151,7 @@ static int X11CreateShmImage ( vout_thread_t *p_vout, XImage **pp_ximage, ...@@ -151,7 +151,7 @@ static int X11CreateShmImage ( vout_thread_t *p_vout, XImage **pp_ximage,
static void X11DestroyShmImage ( vout_thread_t *p_vout, XImage *p_ximage, static void X11DestroyShmImage ( vout_thread_t *p_vout, XImage *p_ximage,
XShmSegmentInfo *p_shm_info ); XShmSegmentInfo *p_shm_info );
static void X11TogglePointer ( vout_thread_t *p_vout ); static void X11ToggleMousePointer ( vout_thread_t *p_vout );
static void X11EnableScreenSaver ( vout_thread_t *p_vout ); static void X11EnableScreenSaver ( vout_thread_t *p_vout );
static void X11DisableScreenSaver ( vout_thread_t *p_vout ); static void X11DisableScreenSaver ( vout_thread_t *p_vout );
...@@ -197,6 +197,7 @@ static int vout_Probe( probedata_t *p_data ) ...@@ -197,6 +197,7 @@ static int vout_Probe( probedata_t *p_data )
static int vout_Create( vout_thread_t *p_vout ) static int vout_Create( vout_thread_t *p_vout )
{ {
char *psz_display; char *psz_display;
XColor cursor_color;
/* Allocate structure */ /* Allocate structure */
p_vout->p_sys = malloc( sizeof( vout_sys_t ) ); p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
...@@ -244,7 +245,29 @@ static int vout_Create( vout_thread_t *p_vout ) ...@@ -244,7 +245,29 @@ static int vout_Create( vout_thread_t *p_vout )
return( 1 ); return( 1 );
} }
p_vout->p_sys->b_mouse = 1; /* Create blank cursor (for mouse cursor autohiding) */
p_vout->p_sys->b_mouse_pointer_visible = 1;
p_vout->p_sys->cursor_pixmap = XCreatePixmap( p_vout->p_sys->p_display,
DefaultRootWindow(
p_vout->p_sys->p_display),
1, 1, 1 );
XParseColor( p_vout->p_sys->p_display,
XCreateColormap( p_vout->p_sys->p_display,
DefaultRootWindow(
p_vout->p_sys->p_display ),
DefaultVisual(
p_vout->p_sys->p_display,
p_vout->p_sys->i_screen ),
AllocNone ),
"black", &cursor_color );
p_vout->p_sys->blank_cursor = XCreatePixmapCursor(
p_vout->p_sys->p_display,
p_vout->p_sys->cursor_pixmap,
p_vout->p_sys->cursor_pixmap,
&cursor_color,
&cursor_color, 1, 1 );
/* Disable screen saver and return */ /* Disable screen saver and return */
X11DisableScreenSaver( p_vout ); X11DisableScreenSaver( p_vout );
...@@ -355,6 +378,13 @@ static void vout_Destroy( vout_thread_t *p_vout ) ...@@ -355,6 +378,13 @@ static void vout_Destroy( vout_thread_t *p_vout )
/* Enable screen saver */ /* Enable screen saver */
X11EnableScreenSaver( p_vout ); X11EnableScreenSaver( p_vout );
/* Restore cursor if it was blanked */
if( !p_vout->p_sys->b_mouse_pointer_visible )
X11ToggleMousePointer( p_vout );
/* Destroy blank cursor pixmap */
XFreePixmap( p_vout->p_sys->p_display, p_vout->p_sys->cursor_pixmap );
/* Destroy colormap */ /* Destroy colormap */
if( p_vout->i_screen_depth == 8 ) if( p_vout->i_screen_depth == 8 )
{ {
...@@ -528,9 +558,9 @@ static int vout_Manage( vout_thread_t *p_vout ) ...@@ -528,9 +558,9 @@ static int vout_Manage( vout_thread_t *p_vout )
else if( xevent.type == MotionNotify ) else if( xevent.type == MotionNotify )
{ {
p_vout->p_sys->i_lastmoved = mdate(); p_vout->p_sys->i_lastmoved = mdate();
if( ! p_vout->p_sys->b_mouse ) if( ! p_vout->p_sys->b_mouse_pointer_visible )
{ {
X11TogglePointer( p_vout ); X11ToggleMousePointer( p_vout );
} }
} }
/* Other event */ /* Other event */
...@@ -658,9 +688,9 @@ static int vout_Manage( vout_thread_t *p_vout ) ...@@ -658,9 +688,9 @@ static int vout_Manage( vout_thread_t *p_vout )
if( mdate() - p_vout->p_sys->i_lastmoved > 2000000 ) if( mdate() - p_vout->p_sys->i_lastmoved > 2000000 )
{ {
/* Hide the mouse automatically */ /* Hide the mouse automatically */
if( p_vout->p_sys->b_mouse ) if( p_vout->p_sys->b_mouse_pointer_visible )
{ {
X11TogglePointer( p_vout ); X11ToggleMousePointer( p_vout );
} }
} }
...@@ -918,7 +948,6 @@ static int X11InitDisplay( vout_thread_t *p_vout, char *psz_display ) ...@@ -918,7 +948,6 @@ static int X11InitDisplay( vout_thread_t *p_vout, char *psz_display )
int i_count; /* array size */ int i_count; /* array size */
/* Initialize structure */ /* Initialize structure */
p_vout->p_sys->i_screen = DefaultScreen( p_vout->p_sys->p_display ); p_vout->p_sys->i_screen = DefaultScreen( p_vout->p_sys->p_display );
p_vout->p_sys->b_shm = ( XShmQueryExtension( p_vout->p_sys->p_display ) p_vout->p_sys->b_shm = ( XShmQueryExtension( p_vout->p_sys->p_display )
...@@ -1206,49 +1235,24 @@ void X11DisableScreenSaver( vout_thread_t *p_vout ) ...@@ -1206,49 +1235,24 @@ void X11DisableScreenSaver( vout_thread_t *p_vout )
} }
/***************************************************************************** /*****************************************************************************
* X11TogglePointer: hide or show the mouse pointer * X11ToggleMousePointer: hide or show the mouse pointer
***************************************************************************** *****************************************************************************
* This function hides the X pointer if it is visible by putting it at * This function hides the X pointer if it is visible by putting it at
* coordinates (32,32) and setting the pointer sprite to a blank one. To * coordinates (32,32) and setting the pointer sprite to a blank one. To
* show it again, we disable the sprite and restore the original coordinates. * show it again, we disable the sprite and restore the original coordinates.
*****************************************************************************/ *****************************************************************************/
void X11TogglePointer( vout_thread_t *p_vout ) void X11ToggleMousePointer( vout_thread_t *p_vout )
{ {
static Cursor cursor; if( p_vout->p_sys->b_mouse_pointer_visible )
static boolean_t b_cursor = 0;
if( p_vout->p_sys->b_mouse )
{ {
p_vout->p_sys->b_mouse = 0; p_vout->p_sys->b_mouse_pointer_visible = 0;
if( !b_cursor )
{
XColor color;
Pixmap blank = XCreatePixmap( p_vout->p_sys->p_display,
DefaultRootWindow(p_vout->p_sys->p_display),
1, 1, 1 );
XParseColor( p_vout->p_sys->p_display,
XCreateColormap( p_vout->p_sys->p_display,
DefaultRootWindow(
p_vout->p_sys->p_display ),
DefaultVisual(
p_vout->p_sys->p_display,
p_vout->p_sys->i_screen ),
AllocNone ),
"black", &color );
cursor = XCreatePixmapCursor( p_vout->p_sys->p_display,
blank, blank, &color, &color, 1, 1 );
b_cursor = 1;
}
XDefineCursor( p_vout->p_sys->p_display, XDefineCursor( p_vout->p_sys->p_display,
p_vout->p_sys->window, cursor ); p_vout->p_sys->window, p_vout->p_sys->blank_cursor );
} }
else else
{ {
p_vout->p_sys->b_mouse = 1; p_vout->p_sys->b_mouse_pointer_visible = 1;
XUndefineCursor( p_vout->p_sys->p_display, p_vout->p_sys->window ); XUndefineCursor( p_vout->p_sys->p_display, p_vout->p_sys->window );
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* vout_xvideo.c: Xvideo video output display method * vout_xvideo.c: Xvideo video output display method
***************************************************************************** *****************************************************************************
* Copyright (C) 1998, 1999, 2000, 2001 VideoLAN * Copyright (C) 1998, 1999, 2000, 2001 VideoLAN
* $Id: vout_xvideo.c,v 1.23 2001/07/30 18:56:36 gbazin Exp $ * $Id: vout_xvideo.c,v 1.24 2001/08/03 16:04:17 gbazin Exp $
* *
* Authors: Shane Harper <shanegh@optusnet.com.au> * Authors: Shane Harper <shanegh@optusnet.com.au>
* Vincent Seguin <seguin@via.ecp.fr> * Vincent Seguin <seguin@via.ecp.fr>
...@@ -132,6 +132,8 @@ typedef struct vout_sys_s ...@@ -132,6 +132,8 @@ typedef struct vout_sys_s
/* Mouse pointer properties */ /* Mouse pointer properties */
boolean_t b_mouse_pointer_visible; boolean_t b_mouse_pointer_visible;
mtime_t i_time_mouse_last_moved; /* used to auto-hide pointer*/ mtime_t i_time_mouse_last_moved; /* used to auto-hide pointer*/
Cursor blank_cursor; /* the hidden cursor */
Pixmap cursor_pixmap;
} vout_sys_t; } vout_sys_t;
...@@ -168,7 +170,7 @@ static int XVideoCreateShmImage ( Display* dpy, int xv_port, ...@@ -168,7 +170,7 @@ static int XVideoCreateShmImage ( Display* dpy, int xv_port,
int i_width, int i_height ); int i_width, int i_height );
static void XVideoDestroyShmImage ( vout_thread_t *, XvImage *, static void XVideoDestroyShmImage ( vout_thread_t *, XvImage *,
XShmSegmentInfo * ); XShmSegmentInfo * );
static void XVideoSetMousePointer ( const vout_thread_t * ); static void X11ToggleMousePointer ( vout_thread_t * );
static void XVideoEnableScreenSaver ( vout_thread_t * ); static void XVideoEnableScreenSaver ( vout_thread_t * );
static void XVideoDisableScreenSaver ( vout_thread_t * ); static void XVideoDisableScreenSaver ( vout_thread_t * );
/*static void XVideoSetAttribute ( vout_thread_t *, char *, float );*/ /*static void XVideoSetAttribute ( vout_thread_t *, char *, float );*/
...@@ -252,6 +254,7 @@ static int vout_Probe( probedata_t *p_data ) ...@@ -252,6 +254,7 @@ static int vout_Probe( probedata_t *p_data )
static int vout_Create( vout_thread_t *p_vout ) static int vout_Create( vout_thread_t *p_vout )
{ {
char *psz_display; char *psz_display;
XColor cursor_color;
/* Allocate structure */ /* Allocate structure */
p_vout->p_sys = malloc( sizeof( vout_sys_t ) ); p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
...@@ -304,6 +307,8 @@ static int vout_Create( vout_thread_t *p_vout ) ...@@ -304,6 +307,8 @@ static int vout_Create( vout_thread_t *p_vout )
} }
intf_DbgMsg( "Using xv port %d" , p_vout->p_sys->xv_port ); intf_DbgMsg( "Using xv port %d" , p_vout->p_sys->xv_port );
/* p_vout->pf_setbuffers( p_vout, NULL, NULL ); */
#if 0 #if 0
/* XXX The brightness and contrast values should be read from environment /* XXX The brightness and contrast values should be read from environment
* XXX variables... */ * XXX variables... */
...@@ -311,7 +316,30 @@ static int vout_Create( vout_thread_t *p_vout ) ...@@ -311,7 +316,30 @@ static int vout_Create( vout_thread_t *p_vout )
XVideoSetAttribute( p_vout, "XV_CONTRAST", 0.5 ); XVideoSetAttribute( p_vout, "XV_CONTRAST", 0.5 );
#endif #endif
/* Create blank cursor (for mouse cursor autohiding) */
p_vout->p_sys->b_mouse_pointer_visible = 1; p_vout->p_sys->b_mouse_pointer_visible = 1;
p_vout->p_sys->cursor_pixmap = XCreatePixmap( p_vout->p_sys->p_display,
DefaultRootWindow(
p_vout->p_sys->p_display),
1, 1, 1 );
XParseColor( p_vout->p_sys->p_display,
XCreateColormap( p_vout->p_sys->p_display,
DefaultRootWindow(
p_vout->p_sys->p_display ),
DefaultVisual(
p_vout->p_sys->p_display,
p_vout->p_sys->i_screen ),
AllocNone ),
"black", &cursor_color );
p_vout->p_sys->blank_cursor = XCreatePixmapCursor(
p_vout->p_sys->p_display,
p_vout->p_sys->cursor_pixmap,
p_vout->p_sys->cursor_pixmap,
&cursor_color,
&cursor_color, 1, 1 );
/* Disable screen saver and return */ /* Disable screen saver and return */
XVideoDisableScreenSaver( p_vout ); XVideoDisableScreenSaver( p_vout );
...@@ -353,6 +381,13 @@ static void vout_End( vout_thread_t *p_vout ) ...@@ -353,6 +381,13 @@ static void vout_End( vout_thread_t *p_vout )
*****************************************************************************/ *****************************************************************************/
static void vout_Destroy( vout_thread_t *p_vout ) static void vout_Destroy( vout_thread_t *p_vout )
{ {
/* Restore cursor if it was blanked */
if( !p_vout->p_sys->b_mouse_pointer_visible )
X11ToggleMousePointer( p_vout );
/* Destroy blank cursor pixmap */
XFreePixmap( p_vout->p_sys->p_display, p_vout->p_sys->cursor_pixmap );
XVideoEnableScreenSaver( p_vout ); XVideoEnableScreenSaver( p_vout );
XVideoDestroyWindow( p_vout ); XVideoDestroyWindow( p_vout );
XCloseDisplay( p_vout->p_sys->p_display ); XCloseDisplay( p_vout->p_sys->p_display );
...@@ -515,8 +550,8 @@ static int vout_Manage( vout_thread_t *p_vout ) ...@@ -515,8 +550,8 @@ static int vout_Manage( vout_thread_t *p_vout )
else if( xevent.type == MotionNotify ) else if( xevent.type == MotionNotify )
{ {
p_vout->p_sys->i_time_mouse_last_moved = mdate(); p_vout->p_sys->i_time_mouse_last_moved = mdate();
p_vout->p_sys->b_mouse_pointer_visible = 1; if( !p_vout->p_sys->b_mouse_pointer_visible )
XVideoSetMousePointer( p_vout ); X11ToggleMousePointer( p_vout );
} }
/* Other event */ /* Other event */
else else
...@@ -604,8 +639,7 @@ static int vout_Manage( vout_thread_t *p_vout ) ...@@ -604,8 +639,7 @@ static int vout_Manage( vout_thread_t *p_vout )
if( p_vout->p_sys->b_mouse_pointer_visible && if( p_vout->p_sys->b_mouse_pointer_visible &&
mdate() - p_vout->p_sys->i_time_mouse_last_moved > 2000000 ) mdate() - p_vout->p_sys->i_time_mouse_last_moved > 2000000 )
{ {
p_vout->p_sys->b_mouse_pointer_visible = 0; X11ToggleMousePointer( p_vout );
XVideoSetMousePointer( p_vout );
} }
return 0; return 0;
...@@ -708,7 +742,6 @@ static int XVideoUpdateImgSizeIfRequired( vout_thread_t *p_vout ) ...@@ -708,7 +742,6 @@ static int XVideoUpdateImgSizeIfRequired( vout_thread_t *p_vout )
(p_vout->p_sys->p_xvimage->data_size) / (p_vout->p_sys->p_xvimage->data_size) /
(p_vout->p_sys->p_xvimage->height); (p_vout->p_sys->p_xvimage->height);
/* p_vout->pf_setbuffers( p_vout, p_vout->p_sys->p_xvimage->data ); */
} }
return( 0 ); return( 0 );
...@@ -905,9 +938,6 @@ static int XVideoCreateWindow( vout_thread_t *p_vout ) ...@@ -905,9 +938,6 @@ static int XVideoCreateWindow( vout_thread_t *p_vout )
XSelectInput( p_vout->p_sys->p_display, p_vout->p_sys->yuv_window, XSelectInput( p_vout->p_sys->p_display, p_vout->p_sys->yuv_window,
ExposureMask ); ExposureMask );
XVideoSetMousePointer( p_vout );
return( 0 ); return( 0 );
} }
...@@ -1048,45 +1078,24 @@ void XVideoDisableScreenSaver( vout_thread_t *p_vout ) ...@@ -1048,45 +1078,24 @@ void XVideoDisableScreenSaver( vout_thread_t *p_vout )
} }
/***************************************************************************** /*****************************************************************************
* XVideoSetMousePointer: hide or show the mouse pointer * X11ToggleMousePointer: hide or show the mouse pointer
***************************************************************************** *****************************************************************************
* This function hides the X pointer if requested. * This function hides the X pointer if requested.
*****************************************************************************/ *****************************************************************************/
void XVideoSetMousePointer( const vout_thread_t *p_vout ) void X11ToggleMousePointer( vout_thread_t *p_vout )
{ {
static Cursor blank_cursor;
static boolean_t b_created_blank_cursor = 0;
if( !p_vout->p_sys->b_mouse_pointer_visible ) if( p_vout->p_sys->b_mouse_pointer_visible )
{ {
if( !b_created_blank_cursor )
{
XColor color;
Pixmap blank = XCreatePixmap( p_vout->p_sys->p_display,
DefaultRootWindow(p_vout->p_sys->p_display),
1, 1, 1 );
XParseColor( p_vout->p_sys->p_display,
XCreateColormap( p_vout->p_sys->p_display,
DefaultRootWindow(
p_vout->p_sys->p_display ),
DefaultVisual(
p_vout->p_sys->p_display,
p_vout->p_sys->i_screen ),
AllocNone ),
"black", &color );
blank_cursor = XCreatePixmapCursor( p_vout->p_sys->p_display,
blank, blank, &color, &color, 1, 1 );
b_created_blank_cursor = 1;
}
XDefineCursor( p_vout->p_sys->p_display, XDefineCursor( p_vout->p_sys->p_display,
p_vout->p_sys->window, blank_cursor ); p_vout->p_sys->window,
p_vout->p_sys->blank_cursor );
p_vout->p_sys->b_mouse_pointer_visible = 0;
} }
else else
{ {
XUndefineCursor( p_vout->p_sys->p_display, p_vout->p_sys->window ); XUndefineCursor( p_vout->p_sys->p_display, p_vout->p_sys->window );
p_vout->p_sys->b_mouse_pointer_visible = 1;
} }
} }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* Provides functions to perform the YUV conversion. * Provides functions to perform the YUV conversion.
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * Copyright (C) 1999, 2000 VideoLAN
* $Id: video_yuvmmx.c,v 1.11 2001/07/11 02:01:05 sam Exp $ * $Id: video_yuvmmx.c,v 1.12 2001/08/03 16:04:17 gbazin Exp $
* *
* Authors: Samuel Hocevar <sam@zoy.org> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -128,14 +128,16 @@ static int yuv_Init( vout_thread_t *p_vout ) ...@@ -128,14 +128,16 @@ static int yuv_Init( vout_thread_t *p_vout )
if( p_vout->yuv.p_buffer == NULL ) if( p_vout->yuv.p_buffer == NULL )
{ {
intf_ErrMsg("error: %s", strerror(ENOMEM)); intf_ErrMsg("error: %s", strerror(ENOMEM));
free( p_vout->yuv.p_base ); if( p_vout->yuv.p_base )
free( p_vout->yuv.p_base );
return( 1 ); return( 1 );
} }
p_vout->yuv.p_offset = malloc( p_vout->i_width * sizeof( int ) ); p_vout->yuv.p_offset = malloc( p_vout->i_width * sizeof( int ) );
if( p_vout->yuv.p_offset == NULL ) if( p_vout->yuv.p_offset == NULL )
{ {
intf_ErrMsg("error: %s", strerror(ENOMEM)); intf_ErrMsg("error: %s", strerror(ENOMEM));
free( p_vout->yuv.p_base ); if( p_vout->yuv.p_base )
free( p_vout->yuv.p_base );
free( p_vout->yuv.p_buffer ); free( p_vout->yuv.p_buffer );
return( 1 ); return( 1 );
} }
...@@ -152,7 +154,8 @@ static int yuv_Init( vout_thread_t *p_vout ) ...@@ -152,7 +154,8 @@ static int yuv_Init( vout_thread_t *p_vout )
*****************************************************************************/ *****************************************************************************/
static void yuv_End( vout_thread_t *p_vout ) static void yuv_End( vout_thread_t *p_vout )
{ {
free( p_vout->yuv.p_base ); if( p_vout->yuv.p_base )
free( p_vout->yuv.p_base );
free( p_vout->yuv.p_buffer ); free( p_vout->yuv.p_buffer );
free( p_vout->yuv.p_offset ); free( p_vout->yuv.p_offset );
} }
......
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