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;
}
}
......
This diff is collapsed.
......@@ -4,7 +4,7 @@
* decoders.
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
* $Id: input.c,v 1.169 2002/01/09 02:01:14 sam Exp $
* $Id: input.c,v 1.170 2002/01/10 04:11:25 sam Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -167,12 +167,18 @@ input_thread_t *input_CreateThread ( playlist_item_t *p_item, int *pi_status )
p_input->stream.b_new_mute = MUTE_NO_CHANGE;
p_input->stream.i_mux_rate = 0;
/* no stream, no area */
/* no stream, no program, no area, no es */
p_input->stream.p_new_program = NULL;
p_input->stream.i_area_nb = 0;
p_input->stream.pp_areas = NULL;
p_input->stream.p_selected_area = NULL;
p_input->stream.p_new_area = NULL;
p_input->stream.pp_selected_es = NULL;
p_input->stream.p_removed_es = NULL;
p_input->stream.p_newly_selected_es = NULL;
/* By default there is one area in a stream */
input_AddArea( p_input );
p_input->stream.p_selected_area = p_input->stream.pp_areas[0];
......@@ -473,7 +479,6 @@ static int InitThread( input_thread_t * p_input )
if( f.pf_open != NULL )
{
f.pf_open( p_input );
p_input->stream.i_method = INPUT_METHOD_DVD;
}
#if !defined( SYS_BEOS ) && !defined( SYS_NTO )
/* FIXME : this is waaaay too kludgy */
......
......@@ -2,7 +2,7 @@
* input_ext-intf.c: services to the interface
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
* $Id: input_ext-intf.c,v 1.32 2001/12/30 07:09:56 sam Exp $
* $Id: input_ext-intf.c,v 1.33 2002/01/10 04:11:25 sam Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -46,19 +46,19 @@ void input_SetStatus( input_thread_t * p_input, int i_mode )
case INPUT_STATUS_END:
p_input->stream.i_new_status = PLAYING_S;
p_input->b_eof = 1;
intf_Msg( "input: end of stream" );
intf_WarnMsg( 1, "input: end of stream" );
break;
case INPUT_STATUS_PLAY:
p_input->stream.i_new_status = PLAYING_S;
intf_Msg( "input: playing at normal rate" );
intf_WarnMsg( 1, "input: playing at normal rate" );
break;
case INPUT_STATUS_PAUSE:
/* XXX: we don't need to check i_status, because input_clock.c
* does it for us */
p_input->stream.i_new_status = PAUSE_S;
intf_Msg( "input: toggling pause" );
intf_WarnMsg( 1, "input: toggling pause" );
break;
case INPUT_STATUS_FASTER:
......@@ -66,7 +66,7 @@ void input_SetStatus( input_thread_t * p_input, int i_mode )
if( p_input->stream.control.i_rate * 8 <= DEFAULT_RATE )
{
p_input->stream.i_new_status = PLAYING_S;
intf_Msg( "input: playing at normal rate" );
intf_WarnMsg( 1, "input: playing at normal rate" );
}
else
{
......@@ -82,8 +82,8 @@ void input_SetStatus( input_thread_t * p_input, int i_mode )
{
p_input->stream.i_new_rate = DEFAULT_RATE / 2;
}
intf_Msg( "input: playing at %i:1 fast forward",
DEFAULT_RATE / p_input->stream.i_new_rate );
intf_WarnMsg( 1, "input: playing at %i:1 fast forward",
DEFAULT_RATE / p_input->stream.i_new_rate );
}
break;
......@@ -92,7 +92,7 @@ void input_SetStatus( input_thread_t * p_input, int i_mode )
if( p_input->stream.control.i_rate >= 8 * DEFAULT_RATE )
{
p_input->stream.i_new_status = PLAYING_S;
intf_Msg( "input: playing at normal rate" );
intf_WarnMsg( 1, "input: playing at normal rate" );
}
else
{
......@@ -108,8 +108,8 @@ void input_SetStatus( input_thread_t * p_input, int i_mode )
{
p_input->stream.i_new_rate = DEFAULT_RATE * 2;
}
intf_Msg( "input: playing at 1:%i slow motion",
p_input->stream.i_new_rate / DEFAULT_RATE );
intf_WarnMsg( 1, "input: playing at 1:%i slow motion",
p_input->stream.i_new_rate / DEFAULT_RATE );
}
break;
......
......@@ -2,7 +2,7 @@
* intf_playlist.c : Playlist management functions
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: intf_playlist.c,v 1.12 2001/12/30 07:09:56 sam Exp $
* $Id: intf_playlist.c,v 1.13 2002/01/10 04:11:25 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -245,21 +245,24 @@ void intf_PlaylistJumpto( playlist_t * p_playlist , int i_pos)
{
vlc_mutex_lock( &p_playlist->change_lock );
p_playlist->i_index = i_pos;
if( i_pos < -1 )
{
i_pos = -1;
}
if( p_playlist->i_index != -1 )
if( i_pos != -1 )
{
if( p_playlist->current.psz_name != NULL )
{
free( p_playlist->current.psz_name );
}
p_playlist->current = p_playlist->p_item[ p_playlist->i_index ];
p_playlist->current.psz_name
= strdup( p_playlist->current.psz_name );
p_playlist->current = p_playlist->p_item[ i_pos ];
p_playlist->current.psz_name = strdup( p_playlist->current.psz_name );
}
p_main->p_playlist->b_stopped = 0;
p_playlist->i_index = i_pos;
p_playlist->b_stopped = 0;
vlc_mutex_unlock( &p_playlist->change_lock );
}
......
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