Commit 0e8b68b5 authored by Sam Hocevar's avatar Sam Hocevar

  * ./src/input/input.c: fixed a few segfaults caused by the dummy plugin.
  * ./plugins/mpeg_adec/mpeg_adec.c: fixed a segfault due to misuse of
    DecoderError.
  * ./plugins/x11/xcommon.c: replaced XFlush with XSync. This must be the
    fourth time someone has to commit this, so I added a reminder :-)
parent 5467d33a
......@@ -2,7 +2,7 @@
* input_dummy.c: dummy input plugin, to manage "vlc:***" special options
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: input_dummy.c,v 1.13 2002/01/09 02:01:14 sam Exp $
* $Id: input_dummy.c,v 1.14 2002/01/10 04:11:25 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -47,8 +47,29 @@
* Local prototypes
*****************************************************************************/
static int DummyProbe ( probedata_t * );
static void DummyInit ( struct input_thread_s * );
static void DummyOpen ( struct input_thread_s * );
static void DummyClose ( struct input_thread_s * );
static void DummyEnd ( struct input_thread_s * );
static int DummyRead ( struct input_thread_s *, data_packet_t ** );
/*****************************************************************************
* dummy_data_t: private input data
*****************************************************************************/
typedef struct dummy_data_s
{
/* The real command */
int i_command;
/* Used for the pause command */
mtime_t expiration;
} dummy_data_t;
#define COMMAND_NOP 0
#define COMMAND_QUIT 1
#define COMMAND_LOOP 2
#define COMMAND_PAUSE 3
/*****************************************************************************
* Functions exported as capabilities. They are declared as static so that
......@@ -58,12 +79,12 @@ void _M( input_getfunctions )( function_list_t * p_function_list )
{
#define input p_function_list->functions.input
p_function_list->pf_probe = DummyProbe;
input.pf_init = NULL; /* Not needed, open is called first */
input.pf_init = DummyInit;
input.pf_open = DummyOpen;
input.pf_close = DummyClose;
input.pf_end = NULL;
input.pf_end = DummyEnd;
input.pf_set_area = NULL;
input.pf_read = NULL;
input.pf_read = DummyRead;
input.pf_demux = NULL;
input.pf_new_packet = NULL;
input.pf_new_pes = NULL;
......@@ -74,10 +95,6 @@ void _M( input_getfunctions )( function_list_t * p_function_list )
#undef input
}
/*
* Data reading functions
*/
/*****************************************************************************
* DummyProbe: verifies that the input is a vlc command
*****************************************************************************/
......@@ -96,21 +113,37 @@ static int DummyProbe( probedata_t *p_data )
}
/*****************************************************************************
* DummyOpen: open the target, ie. do what the command says
* DummyOpen: open the target, ie. do nothing
*****************************************************************************/
static void DummyOpen( input_thread_t * p_input )
{
p_input->stream.i_method = INPUT_METHOD_NONE;
}
/*****************************************************************************
* DummyClose: close the target, ie. do nothing
*****************************************************************************/
static void DummyClose( input_thread_t * p_input )
{
;
}
/*****************************************************************************
* DummyOpen: initialize the target, ie. parse the command
*****************************************************************************/
static void DummyInit( struct input_thread_s *p_input )
{
dummy_data_t* p_method;
char *psz_name = p_input->p_source;
int i_len = strlen( psz_name );
int i_arg;
/* XXX: Tell the input layer to quit immediately, there must
* be a nicer way to do this. */
p_input->b_error = 1;
p_input->stream.b_seekable = 0;
if( ( i_len <= 4 ) || strncasecmp( psz_name, "vlc:", 4 ) )
{
/* If the command doesn't start with "vlc:" then it's not for us */
p_input->b_error = 1;
return;
}
......@@ -118,10 +151,22 @@ static void DummyOpen( input_thread_t * p_input )
psz_name += 4;
i_len -= 4;
p_method = malloc( sizeof( dummy_data_t ) );
if( p_method == NULL )
{
intf_ErrMsg( "input: out of memory" );
p_input->b_error = 1;
return;
}
p_input->p_plugin_data = (void *)p_method;
p_input->stream.p_demux_data = NULL;
/* Check for a "vlc:nop" command */
if( i_len == 3 && !strncasecmp( psz_name, "nop", 3 ) )
{
intf_WarnMsg( 2, "input: command `nop'" );
p_method->i_command = COMMAND_NOP;
return;
}
......@@ -129,7 +174,7 @@ static void DummyOpen( input_thread_t * p_input )
if( i_len == 4 && !strncasecmp( psz_name, "quit", 4 ) )
{
intf_WarnMsg( 2, "input: command `quit'" );
p_main->p_intf->b_die = 1;
p_method->i_command = COMMAND_QUIT;
return;
}
......@@ -137,7 +182,7 @@ static void DummyOpen( input_thread_t * p_input )
if( i_len == 4 && !strncasecmp( psz_name, "loop", 4 ) )
{
intf_WarnMsg( 2, "input: command `loop'" );
intf_PlaylistJumpto( p_main->p_playlist, -1 );
p_method->i_command = COMMAND_LOOP;
return;
}
......@@ -145,21 +190,64 @@ static void DummyOpen( input_thread_t * p_input )
if( i_len > 6 && !strncasecmp( psz_name, "pause:", 6 ) )
{
i_arg = atoi( psz_name + 6 );
intf_WarnMsgImm( 2, "input: command `pause %i'", i_arg );
msleep( i_arg * 1000000 );
intf_WarnMsg( 2, "input: command `pause %i'", i_arg );
p_method->i_command = COMMAND_PAUSE;
p_method->expiration = mdate() + (mtime_t)i_arg * (mtime_t)1000000;
return;
}
intf_ErrMsg( "input error: unknown command `%s'", psz_name );
free( p_input->p_plugin_data );
p_input->b_error = 1;
return;
}
/*****************************************************************************
* DummyClose: close the target, ie. do nothing
* DummyEnd: end the target, ie. do nothing
*****************************************************************************/
static void DummyClose( input_thread_t * p_input )
static void DummyEnd( struct input_thread_s *p_input )
{
return;
free( p_input->p_plugin_data );
}
/*****************************************************************************
* DummyRead: do what the command says
*****************************************************************************/
static int DummyRead( struct input_thread_s *p_input, data_packet_t **pp_data )
{
dummy_data_t* p_method = (dummy_data_t *)p_input->p_plugin_data;
switch( p_method->i_command )
{
case COMMAND_QUIT:
p_input->b_die = 1;
break;
case COMMAND_LOOP:
intf_PlaylistJumpto( p_main->p_playlist, -1 );
p_input->b_eof = 1;
break;
case COMMAND_PAUSE:
if( mdate() < p_method->expiration )
{
msleep( 10000 );
}
else
{
p_input->b_eof = 1;
}
break;
case COMMAND_NOP:
default:
p_input->b_eof = 1;
break;
}
*pp_data = NULL;
return 0;
}
......@@ -9,7 +9,7 @@
* -dvd_udf to find files
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
* $Id: input_dvd.c,v 1.117 2001/12/31 01:13:12 massiot Exp $
* $Id: input_dvd.c,v 1.118 2002/01/10 04:11:25 sam Exp $
*
* Author: Stphane Borel <stef@via.ecp.fr>
*
......@@ -304,6 +304,8 @@ static void DVDOpen( struct input_thread_s *p_input )
vlc_mutex_lock( &p_input->stream.stream_lock );
p_input->stream.i_method = INPUT_METHOD_DVD;
/* If we are here we can control the pace... */
p_input->stream.b_pace_control = 1;
......
......@@ -6,7 +6,7 @@
* It depends on: libdvdread for ifo files and block reading.
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: input_dvdread.c,v 1.17 2002/01/08 23:34:06 stef Exp $
* $Id: input_dvdread.c,v 1.18 2002/01/10 04:11:25 sam Exp $
*
* Author: Stphane Borel <stef@via.ecp.fr>
*
......@@ -281,6 +281,8 @@ static void DvdReadOpen( struct input_thread_s *p_input )
vlc_mutex_lock( &p_input->stream.stream_lock );
p_input->stream.i_method = INPUT_METHOD_DVD;
/* If we are here we can control the pace... */
p_input->stream.b_pace_control = 1;
......
......@@ -2,7 +2,7 @@
* gtk_display.c: Gtk+ tools for main interface
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: gtk_display.c,v 1.12 2002/01/09 02:01:14 sam Exp $
* $Id: gtk_display.c,v 1.13 2002/01/10 04:11:25 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
* Stphane Borel <stef@via.ecp.fr>
......@@ -159,7 +159,13 @@ gint GtkModeManage( intf_thread_t * p_intf )
break;
default:
intf_ErrMsg( "intf error: can't determine input method" );
intf_WarnMsg( 3, "intf: can't determine input method" );
gtk_widget_show( GTK_WIDGET( p_file_box ) );
p_label = gtk_object_get_data( GTK_OBJECT(
p_intf->p_sys->p_window ),
"label_status" );
gtk_label_set_text( GTK_LABEL( p_label ),
p_input_bank->pp_input[0]->p_source );
break;
}
......
......@@ -2,7 +2,7 @@
* xmga.c : X11 MGA plugin for vlc
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
* $Id: xmga.c,v 1.1 2002/01/09 02:01:14 sam Exp $
* $Id: xmga.c,v 1.2 2002/01/10 04:11:25 sam Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
......@@ -971,118 +971,118 @@ static void FreePicture( vout_thread_t *p_vout, picture_t *p_pic )
*****************************************************************************/
static void ToggleFullScreen ( vout_thread_t *p_vout )
{
Atom prop;
mwmhints_t mwmhints;
int i_xpos, i_ypos, i_width, i_height;
p_vout->b_fullscreen = !p_vout->b_fullscreen;
if( p_vout->b_fullscreen )
{
Window next_parent, parent, *p_dummy, dummy1;
unsigned int dummy2, dummy3;
intf_WarnMsg( 3, "vout: entering fullscreen mode" );
/* Save current window coordinates so they can be restored when
* we exit from fullscreen mode */
/* find the real parent, which means the which is a direct child of
* the root window */
next_parent = parent = p_vout->p_sys->window;
while( next_parent != DefaultRootWindow( p_vout->p_sys->p_display ) )
{
parent = next_parent;
XQueryTree( p_vout->p_sys->p_display,
parent,
Atom prop;
mwmhints_t mwmhints;
int i_xpos, i_ypos, i_width, i_height;
p_vout->b_fullscreen = !p_vout->b_fullscreen;
if( p_vout->b_fullscreen )
{
Window next_parent, parent, *p_dummy, dummy1;
unsigned int dummy2, dummy3;
intf_WarnMsg( 3, "vout: entering fullscreen mode" );
/* Save current window coordinates so they can be restored when
* we exit from fullscreen mode */
/* find the real parent, which means the which is a direct child of
* the root window */
next_parent = parent = p_vout->p_sys->window;
while( next_parent != DefaultRootWindow( p_vout->p_sys->p_display ) )
{
parent = next_parent;
XQueryTree( p_vout->p_sys->p_display,
parent,
&dummy1,
&next_parent,
&p_dummy,
&dummy2 );
XFree((void *)p_dummy);
}
XGetGeometry( p_vout->p_sys->p_display,
p_vout->p_sys->window,
&dummy1,
&next_parent,
&p_dummy,
&dummy2 );
XFree((void *)p_dummy);
}
XGetGeometry( p_vout->p_sys->p_display,
p_vout->p_sys->window,
&dummy1,
&dummy2,
&dummy3,
&p_vout->p_sys->i_width_backup,
&p_vout->p_sys->i_height_backup,
&dummy2, &dummy3 );
XTranslateCoordinates( p_vout->p_sys->p_display,
parent,
DefaultRootWindow( p_vout->p_sys->p_display ),
0,
0,
&p_vout->p_sys->i_xpos_backup,
&p_vout->p_sys->i_ypos_backup,
&dummy1 );
mwmhints.flags = MWM_HINTS_DECORATIONS;
mwmhints.decorations = 0;
i_xpos = 0;
i_ypos = 0;
i_width = DisplayWidth( p_vout->p_sys->p_display,
p_vout->p_sys->i_screen );
i_height = DisplayHeight( p_vout->p_sys->p_display,
&dummy2,
&dummy3,
&p_vout->p_sys->i_width_backup,
&p_vout->p_sys->i_height_backup,
&dummy2, &dummy3 );
XTranslateCoordinates( p_vout->p_sys->p_display,
parent,
DefaultRootWindow( p_vout->p_sys->p_display ),
0,
0,
&p_vout->p_sys->i_xpos_backup,
&p_vout->p_sys->i_ypos_backup,
&dummy1 );
mwmhints.flags = MWM_HINTS_DECORATIONS;
mwmhints.decorations = 0;
i_xpos = 0;
i_ypos = 0;
i_width = DisplayWidth( p_vout->p_sys->p_display,
p_vout->p_sys->i_screen );
i_height = DisplayHeight( p_vout->p_sys->p_display,
p_vout->p_sys->i_screen );
#if 0
/* Being a transient window allows us to really be fullscreen (display
* over the taskbar for instance) but then we end-up with the same
* result as with the brute force method */
XSetTransientForHint( p_vout->p_sys->p_display,
p_vout->p_sys->window, None );
/* Being a transient window allows us to really be fullscreen (display
* over the taskbar for instance) but then we end-up with the same
* result as with the brute force method */
XSetTransientForHint( p_vout->p_sys->p_display,
p_vout->p_sys->window, None );
#endif
}
else
{
intf_WarnMsg( 3, "vout: leaving fullscreen mode" );
mwmhints.flags = MWM_HINTS_DECORATIONS;
mwmhints.decorations = 1;
i_xpos = p_vout->p_sys->i_xpos_backup;
i_ypos = p_vout->p_sys->i_ypos_backup;
i_width = p_vout->p_sys->i_width_backup;
i_height = p_vout->p_sys->i_height_backup;
}
/* To my knowledge there are two ways to create a borderless window.
* There's the generic way which is to tell x to bypass the window manager,
* but this creates problems with the focus of other applications.
* The other way is to use the motif property "_MOTIF_WM_HINTS" which
* luckily seems to be supported by most window managers.
*/
prop = XInternAtom( p_vout->p_sys->p_display, "_MOTIF_WM_HINTS",
False );
XChangeProperty( p_vout->p_sys->p_display, p_vout->p_sys->window,
prop, prop, 32, PropModeReplace,
(unsigned char *)&mwmhints,
PROP_MWM_HINTS_ELEMENTS );
}
else
{
intf_WarnMsg( 3, "vout: leaving fullscreen mode" );
mwmhints.flags = MWM_HINTS_DECORATIONS;
mwmhints.decorations = 1;
i_xpos = p_vout->p_sys->i_xpos_backup;
i_ypos = p_vout->p_sys->i_ypos_backup;
i_width = p_vout->p_sys->i_width_backup;
i_height = p_vout->p_sys->i_height_backup;
}
/* To my knowledge there are two ways to create a borderless window.
* There's the generic way which is to tell x to bypass the window manager,
* but this creates problems with the focus of other applications.
* The other way is to use the motif property "_MOTIF_WM_HINTS" which
* luckily seems to be supported by most window managers.
*/
prop = XInternAtom( p_vout->p_sys->p_display, "_MOTIF_WM_HINTS",
False );
XChangeProperty( p_vout->p_sys->p_display, p_vout->p_sys->window,
prop, prop, 32, PropModeReplace,
(unsigned char *)&mwmhints,
PROP_MWM_HINTS_ELEMENTS );
#if 0 /* brute force way to remove decorations */
XSetWindowAttributes attributes;
attributes.override_redirect = True;
XChangeWindowAttributes( p_vout->p_sys->p_display,
p_vout->p_sys->window,
CWOverrideRedirect,
&attributes);
XSetWindowAttributes attributes;
attributes.override_redirect = True;
XChangeWindowAttributes( p_vout->p_sys->p_display,
p_vout->p_sys->window,
CWOverrideRedirect,
&attributes);
#endif
/* We need to unmap and remap the window if we want the window
* manager to take our changes into effect */
XUnmapWindow( p_vout->p_sys->p_display, p_vout->p_sys->window);
XMapRaised( p_vout->p_sys->p_display, p_vout->p_sys->window);
XMoveResizeWindow( p_vout->p_sys->p_display,
p_vout->p_sys->window,
i_xpos,
i_ypos,
i_width,
i_height );
XFlush( p_vout->p_sys->p_display );
/* We need to unmap and remap the window if we want the window
* manager to take our changes into effect */
XUnmapWindow( p_vout->p_sys->p_display, p_vout->p_sys->window);
XMapRaised( p_vout->p_sys->p_display, p_vout->p_sys->window);
XMoveResizeWindow( p_vout->p_sys->p_display,
p_vout->p_sys->window,
i_xpos,
i_ypos,
i_width,
i_height );
XSync( p_vout->p_sys->p_display, False );
}
/*****************************************************************************
......
......@@ -2,7 +2,7 @@
* mpeg_adec.c: MPEG audio decoder thread
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: mpeg_adec.c,v 1.11 2002/01/09 00:33:37 asmax Exp $
* $Id: mpeg_adec.c,v 1.12 2002/01/10 04:11:25 sam Exp $
*
* Authors: Michel Kaempf <maxx@via.ecp.fr>
* Michel Lespinasse <walken@via.ecp.fr>
......@@ -191,7 +191,8 @@ static void DecodeThread( adec_thread_t * p_adec )
{
intf_ErrMsg( "adec error: failed to create Audio Output "
"Fifo." );
DecoderError( p_adec->p_fifo );
p_adec->p_fifo->b_error = 1;
return;
}
}
......
......@@ -2,7 +2,7 @@
* xcommon.c: Functions common to the X11 and XVideo plugins
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
* $Id: xcommon.c,v 1.9 2002/01/07 02:12:29 sam Exp $
* $Id: xcommon.c,v 1.10 2002/01/10 04:11:25 sam Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
......@@ -580,8 +580,8 @@ static void vout_Display( vout_thread_t *p_vout, picture_t *p_pic )
#endif
}
/* Make sure the command is sent now */
XFlush( p_vout->p_sys->p_display );
/* Make sure the command is sent now - do NOT use XFlush !*/
XSync( p_vout->p_sys->p_display, False );
}
/*****************************************************************************
......@@ -1132,6 +1132,7 @@ static int CreateWindow( vout_thread_t *p_vout )
ToggleCursor( p_vout );
}
/* Do NOT use XFlush here ! */
XSync( p_vout->p_sys->p_display, False );
/* At this stage, the window is open, displayed, and ready to
......@@ -1147,6 +1148,7 @@ static int CreateWindow( vout_thread_t *p_vout )
*****************************************************************************/
static void DestroyWindow( vout_thread_t *p_vout )
{
/* Do NOT use XFlush here ! */
XSync( p_vout->p_sys->p_display, False );
#ifdef MODULE_NAME_IS_xvideo
......@@ -1395,6 +1397,7 @@ static void FreePicture( vout_thread_t *p_vout, picture_t *p_pic )
IMAGE_FREE( p_pic->p_sys->p_image );
}
/* Do NOT use XFlush here ! */
XSync( p_vout->p_sys->p_display, False );
free( p_pic->p_sys );
......@@ -1408,118 +1411,120 @@ static void FreePicture( vout_thread_t *p_vout, picture_t *p_pic )
*****************************************************************************/
static void ToggleFullScreen ( vout_thread_t *p_vout )
{
Atom prop;
mwmhints_t mwmhints;
int i_xpos, i_ypos, i_width, i_height;
Atom prop;
mwmhints_t mwmhints;
int i_xpos, i_ypos, i_width, i_height;
p_vout->b_fullscreen = !p_vout->b_fullscreen;
p_vout->b_fullscreen = !p_vout->b_fullscreen;
if( p_vout->b_fullscreen )
{
Window next_parent, parent, *p_dummy, dummy1;
unsigned int dummy2, dummy3;
if( p_vout->b_fullscreen )
{
Window next_parent, parent, *p_dummy, dummy1;
unsigned int dummy2, dummy3;
intf_WarnMsg( 3, "vout: entering fullscreen mode" );
/* Save current window coordinates so they can be restored when
* we exit from fullscreen mode */
/* find the real parent, which means the which is a direct child of
* the root window */
next_parent = parent = p_vout->p_sys->window;
while( next_parent != DefaultRootWindow( p_vout->p_sys->p_display ) )
{
parent = next_parent;
XQueryTree( p_vout->p_sys->p_display,
parent,
intf_WarnMsg( 3, "vout: entering fullscreen mode" );
/* Save current window coordinates so they can be restored when
* we exit from fullscreen mode */
/* find the real parent, which means the which is a direct child of
* the root window */
next_parent = parent = p_vout->p_sys->window;
while( next_parent != DefaultRootWindow( p_vout->p_sys->p_display ) )
{
parent = next_parent;
XQueryTree( p_vout->p_sys->p_display,
parent,
&dummy1,
&next_parent,
&p_dummy,
&dummy2 );
XFree((void *)p_dummy);
}
XGetGeometry( p_vout->p_sys->p_display,
p_vout->p_sys->window,
&dummy1,
&next_parent,
&p_dummy,
&dummy2 );
XFree((void *)p_dummy);
}
XGetGeometry( p_vout->p_sys->p_display,
p_vout->p_sys->window,
&dummy1,
&dummy2,
&dummy3,
&p_vout->p_sys->i_width_backup,
&p_vout->p_sys->i_height_backup,
&dummy2, &dummy3 );
XTranslateCoordinates( p_vout->p_sys->p_display,
parent,
DefaultRootWindow( p_vout->p_sys->p_display ),
0,
0,
&p_vout->p_sys->i_xpos_backup,