include/beos_specific.h \
include/configuration.h \
include/darwin_specific.h \
+ include/error.h \
include/input_ext-dec.h \
include/input_ext-intf.h \
include/input_ext-plugins.h \
src/misc/messages.c \
src/misc/objects.c \
src/misc/variables.c \
+ src/misc/error.c \
src/misc/extras.c \
$(SOURCES_libvlc_win32) \
$(SOURCES_libvlc_beos) \
[ --enable-testsuite build test modules (default disabled)])
if test "x${enable_testsuite}" = "xyes"
then
- TESTS="test1 test2 test3"
+ TESTS="test1 test2 test3 test4"
+
dnl we define those so that bootstrap sets the right linker
CXXFLAGS_test2="${CXXFLAGS_test2}"
OBJCFLAGS_test3="${OBJCFLAGS_test3}"
dnl this one is needed until automake knows what to do
LDFLAGS_test3="${LDFLAGS_test3} -lobjc"
+
PLUGINS="${PLUGINS} ${TESTS}"
#BUILTINS="${BUILTINS} ${TESTS}"
fi
* Declaration and extern access to global program object.
*****************************************************************************
* Copyright (C) 1999, 2000, 2001, 2002 VideoLAN
- * $Id: main.h,v 1.48 2002/10/04 18:07:21 sam Exp $
+ * $Id: main.h,v 1.49 2002/10/14 16:46:55 sam Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
*
{
VLC_COMMON_MEMBERS
- /* The vlc structure status */
- int i_status;
-
/* Global properties */
int i_argc; /* command line arguments count */
char ** ppsz_argv; /* command line arguments */
* variables.h: variables handling
*****************************************************************************
* Copyright (C) 2002 VideoLAN
- * $Id: variables.h,v 1.1 2002/10/11 11:05:52 sam Exp $
+ * $Id: variables.h,v 1.2 2002/10/14 16:46:55 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
#define VLC_VAR_FLOAT 0x0400
#define VLC_VAR_TIME 0x0500
#define VLC_VAR_ADDRESS 0x0600
+#define VLC_VAR_COMMAND 0x0700
/*****************************************************************************
* vlc_value_t is the common union for variable values; variable_t is the
/*****************************************************************************
* Prototypes
*****************************************************************************/
-VLC_EXPORT( void, __var_Create, ( vlc_object_t *, const char *, int ) );
-VLC_EXPORT( void, __var_Destroy, ( vlc_object_t *, const char * ) );
+VLC_EXPORT( int, __var_Create, ( vlc_object_t *, const char *, int ) );
+VLC_EXPORT( int, __var_Destroy, ( vlc_object_t *, const char * ) );
+VLC_EXPORT( int, __var_Type, ( vlc_object_t *, const char * ) );
VLC_EXPORT( int, __var_Set, ( vlc_object_t *, const char *, vlc_value_t ) );
VLC_EXPORT( int, __var_Get, ( vlc_object_t *, const char *, vlc_value_t * ) );
#define var_Destroy(a,b) \
__var_Destroy( VLC_OBJECT(a), b )
+#define var_Type(a,b) \
+ __var_Type( VLC_OBJECT(a), b )
+
#define var_Set(a,b,c) \
__var_Set( VLC_OBJECT(a), b, c )
* vlc.h: global header for vlc
*****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN
- * $Id: vlc.h,v 1.15 2002/10/11 22:32:56 sam Exp $
+ * $Id: vlc.h,v 1.16 2002/10/14 16:46:55 sam Exp $
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
char * psz_string;
void * p_address;
- /* Use this to make sure the structure is at least 64bits */
+ /* Make sure the structure is at least 64bits */
struct { char a, b, c, d, e, f, g, h; } padding;
} vlc_value_t;
*****************************************************************************/
#define VLC_SUCCESS -0 /* No error */
#define VLC_ENOMEM -1 /* Not enough memory */
-#define VLC_EMODULE -2 /* Module not found */
-#define VLC_ESTATUS -3 /* Invalid status */
-#define VLC_ETHREAD -4 /* Could not spawn thread */
-#define VLC_EOBJECT -5 /* Object not found */
-#define VLC_EVAR -6 /* Variable not found */
+#define VLC_ETHREAD -2 /* Thread error */
+
+#define VLC_ENOMOD -10 /* Module not found */
+
+#define VLC_ENOOBJ -20 /* Object not found */
+#define VLC_EBADOBJ -21 /* Bad object type */
+
+#define VLC_ENOVAR -30 /* Variable not found */
+#define VLC_EBADVAR -31 /* Bad variable value */
+
#define VLC_EEXIT -255 /* Program exited */
#define VLC_EGENERIC -666 /* Generic error */
#define VLC_FALSE 0
#define VLC_TRUE 1
-/*****************************************************************************
- * Main structure status
- *****************************************************************************/
-#define VLC_STATUS_NONE 0x00000000
-#define VLC_STATUS_CREATED 0x02020202
-#define VLC_STATUS_STOPPED 0x12121212
-#define VLC_STATUS_RUNNING 0x42424242
-
/*****************************************************************************
* Playlist
*****************************************************************************/
/*****************************************************************************
* Exported libvlc API
*****************************************************************************/
-char * VLC_Version ( void );
-
-int VLC_Create ( void );
-int VLC_Init ( int, int, char *[] );
-int VLC_Die ( int );
-int VLC_Destroy ( int );
-
-int VLC_Set ( int, const char *, vlc_value_t );
-int VLC_Get ( int, const char *, vlc_value_t * );
-int VLC_AddIntf ( int, const char *, vlc_bool_t );
-int VLC_AddTarget ( int, const char *, int, int );
-
-int VLC_Play ( int );
-int VLC_Pause ( int );
-int VLC_Stop ( int );
-int VLC_FullScreen ( int );
+char const * VLC_Version ( void );
+char const * VLC_Error ( int );
+
+int VLC_Create ( void );
+int VLC_Init ( int, int, char *[] );
+int VLC_Die ( int );
+int VLC_Destroy ( int );
+
+int VLC_Set ( int, char const *, vlc_value_t );
+int VLC_Get ( int, char const *, vlc_value_t * );
+int VLC_AddIntf ( int, char const *, vlc_bool_t );
+int VLC_AddTarget ( int, char const *, int, int );
+
+int VLC_Play ( int );
+int VLC_Pause ( int );
+int VLC_Stop ( int );
+int VLC_FullScreen ( int );
# ifdef __cplusplus
}
* vlc_objects.h: vlc_object_t definition.
*****************************************************************************
* Copyright (C) 2002 VideoLAN
- * $Id: vlc_objects.h,v 1.12 2002/10/11 22:32:55 sam Exp $
+ * $Id: vlc_objects.h,v 1.13 2002/10/14 16:46:55 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
VLC_EXPORT( vlc_list_t *, __vlc_list_find, ( vlc_object_t *, int, int ) );
VLC_EXPORT( void, vlc_list_release, ( vlc_list_t * ) );
-VLC_EXPORT( void, __vlc_liststructure, ( vlc_object_t * ) );
-VLC_EXPORT( void, __vlc_dumpstructure, ( vlc_object_t * ) );
-
#define vlc_object_create(a,b) \
__vlc_object_create( VLC_OBJECT(a), b )
#define vlc_list_find(a,b,c) \
__vlc_list_find( VLC_OBJECT(a),b,c)
-#define vlc_liststructure(a) \
- __vlc_liststructure( VLC_OBJECT(a) )
-
-#define vlc_dumpstructure(a) \
- __vlc_dumpstructure( VLC_OBJECT(a) )
-
* rc.c : remote control stdin/stdout plugin for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
- * $Id: rc.c,v 1.8 2002/10/11 22:32:56 sam Exp $
+ * $Id: rc.c,v 1.9 2002/10/14 16:46:55 sam Exp $
*
* Authors: Peter Surda <shurdeek@panorama.sth.ac.at>
*
static int Activate ( vlc_object_t * );
static void Run ( intf_thread_t *p_intf );
+static int Playlist ( vlc_object_t *, char *, char * );
+static int Quit ( vlc_object_t *, char *, char * );
+static int Intf ( vlc_object_t *, char *, char * );
+
/*****************************************************************************
* Module descriptor
*****************************************************************************/
if( !config_GetInt( p_intf, "fake-tty" ) && !isatty( 0 ) )
{
msg_Warn( p_intf, "fd 0 is not a TTY" );
- return 1;
+ return VLC_EGENERIC;
}
#endif
CONSOLE_INTRO_MSG;
printf( "remote control interface initialized, `h' for help\n" );
- return 0;
+ return VLC_SUCCESS;
}
/*****************************************************************************
playlist_t * p_playlist;
char p_buffer[ MAX_LINE_LENGTH + 1 ];
- vlc_bool_t b_complete = 0;
vlc_bool_t b_showpos = config_GetInt( p_intf, "rc-show-pos" );
input_info_category_t * p_category;
input_info_t * p_info;
int i_dummy;
off_t i_oldpos = 0;
off_t i_newpos;
- fd_set fds; /* stdin changed? */
- struct timeval tv; /* how long to wait */
- double f_ratio = 1;
+ double f_ratio = 1.0;
p_input = NULL;
p_playlist = NULL;
- var_Create( p_intf, "foo", VLC_VAR_STRING );
- var_Set( p_intf, "foo", (vlc_value_t)"test" );
+ /* Register commands that will be cleaned up upon object destruction */
+ var_Create( p_intf, "quit", VLC_VAR_COMMAND );
+ var_Set( p_intf, "quit", (vlc_value_t)(void*)Quit );
+ var_Create( p_intf, "intf", VLC_VAR_COMMAND );
+ var_Set( p_intf, "intf", (vlc_value_t)(void*)Intf );
+
+ var_Create( p_intf, "play", VLC_VAR_COMMAND );
+ var_Set( p_intf, "play", (vlc_value_t)(void*)Playlist );
+ var_Create( p_intf, "stop", VLC_VAR_COMMAND );
+ var_Set( p_intf, "stop", (vlc_value_t)(void*)Playlist );
+ var_Create( p_intf, "pause", VLC_VAR_COMMAND );
+ var_Set( p_intf, "pause", (vlc_value_t)(void*)Playlist );
+ var_Create( p_intf, "prev", VLC_VAR_COMMAND );
+ var_Set( p_intf, "prev", (vlc_value_t)(void*)Playlist );
+ var_Create( p_intf, "next", VLC_VAR_COMMAND );
+ var_Set( p_intf, "next", (vlc_value_t)(void*)Playlist );
while( !p_intf->b_die )
{
- b_complete = 0;
+ fd_set fds;
+ struct timeval tv;
+ vlc_bool_t b_complete = VLC_FALSE;
/* Check stdin */
tv.tv_sec = 0;
|| p_buffer[ i_size ] == '\n' )
{
p_buffer[ i_size ] = 0;
- b_complete = 1;
+ b_complete = VLC_TRUE;
}
}
}
/* Is there something to do? */
- if( b_complete == 1 )
+ if( b_complete )
{
- char *p_cmd = p_buffer;
+ char *psz_cmd, *psz_arg;
- if( !strcmp( p_cmd, "quit" ) )
- {
- p_intf->p_vlc->b_die = VLC_TRUE;
- }
- else if( !strcmp( p_cmd, "segfault" ) )
- {
- raise( SIGSEGV );
- }
- else if( !strcmp( p_cmd, "prev" ) )
+ /* Skip heading spaces */
+ psz_cmd = p_buffer;
+ while( *psz_cmd == ' ' )
{
- if( p_playlist ) playlist_Prev( p_playlist );
+ psz_cmd++;
}
- else if( !strcmp( p_cmd, "next" ) )
- {
- if( p_playlist ) playlist_Next( p_playlist );
- }
- else if( !strcmp( p_cmd, "play" ) )
- {
- if( p_playlist ) playlist_Play( p_playlist );
- }
- else if( !strcmp( p_cmd, "stop" ) )
- {
- if( p_playlist ) playlist_Stop( p_playlist );
- }
- else if( !strcmp( p_cmd, "pause" ) )
- {
- if( p_input ) input_SetStatus( p_input, INPUT_STATUS_PAUSE );
- }
- else if( !strcmp( p_cmd, "tree" ) )
- {
- vlc_dumpstructure( p_intf->p_vlc );
- }
- else if( !strcmp( p_cmd, "list" ) )
+
+ /* Split psz_cmd at the first space and make sure that
+ * psz_arg is valid */
+ psz_arg = strchr( psz_cmd, ' ' );
+ if( psz_arg )
{
- vlc_liststructure( p_intf->p_vlc );
+ *psz_arg++ = 0;
+ while( *psz_arg == ' ' )
+ {
+ psz_arg++;
+ }
}
- else if( !strncmp( p_cmd, "setfoo ", 7 ) )
+ else
{
- vlc_value_t value;
- value.psz_string = p_cmd + 7;
- var_Set( p_intf, "foo", value );
+ psz_arg = "";
}
- else if( !strncmp( p_cmd, "getfoo", 6 ) )
+
+ /* If the user typed a registered local command, try it */
+ if( var_Type( p_intf, psz_cmd ) == VLC_VAR_COMMAND )
{
- vlc_value_t value;
- var_Get( p_intf, "foo", &value );
- printf( "current value is '%s'\n", value.psz_string );
+ vlc_value_t val;
+ int i_ret;
+
+ val.psz_string = psz_arg;
+ i_ret = var_Get( p_intf, psz_cmd, &val );
+ printf( "%s: returned %i (%s)\n",
+ psz_cmd, i_ret, vlc_error( i_ret ) );
}
- else if( !strncmp( p_cmd, "intf ", 5 ) )
+ /* Or maybe it's a global command */
+ else if( var_Type( p_intf->p_libvlc, psz_cmd ) == VLC_VAR_COMMAND )
{
- intf_thread_t *p_newintf;
- char *psz_oldmodule = config_GetPsz( p_intf->p_vlc, "intf" );
-
- config_PutPsz( p_intf->p_vlc, "intf", p_cmd + 5 );
- p_newintf = intf_Create( p_intf->p_vlc );
- config_PutPsz( p_intf->p_vlc, "intf", psz_oldmodule );
-
- if( psz_oldmodule )
- {
- free( psz_oldmodule );
- }
-
- if( p_newintf )
- {
- p_newintf->b_block = VLC_FALSE;
- if( intf_RunThread( p_newintf ) )
- {
- vlc_object_detach( p_newintf );
- intf_Destroy( p_newintf );
- }
- }
+ vlc_value_t val;
+ int i_ret;
+
+ val.psz_string = psz_arg;
+ /* FIXME: it's a global command, but we should pass the
+ * local object as an argument, not p_intf->p_libvlc. */
+ i_ret = var_Get( p_intf->p_libvlc, psz_cmd, &val );
+ printf( "%s: returned %i (%s)\n",
+ psz_cmd, i_ret, vlc_error( i_ret ) );
}
- else if( !strcmp( p_cmd, "info" ) )
+ else if( !strcmp( psz_cmd, "info" ) )
{
if ( p_input )
{
printf( "no input\n" );
}
}
- else switch( p_cmd[0] )
+ else switch( psz_cmd[0] )
{
case 'a':
case 'A':
- if( p_cmd[1] == ' ' && p_playlist )
+ if( psz_cmd[1] == ' ' && p_playlist )
{
- playlist_Add( p_playlist, p_cmd + 2,
+ playlist_Add( p_playlist, psz_cmd + 2,
PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
}
break;
if( p_input )
{
for( i_dummy = 1;
- i_dummy < MAX_LINE_LENGTH && p_cmd[ i_dummy ] >= '0'
- && p_cmd[ i_dummy ] <= '9';
+ i_dummy < MAX_LINE_LENGTH && psz_cmd[ i_dummy ] >= '0'
+ && psz_cmd[ i_dummy ] <= '9';
i_dummy++ )
{
;
}
- p_cmd[ i_dummy ] = 0;
- input_Seek( p_input, (off_t)atoi( p_cmd + 1 ),
+ psz_cmd[ i_dummy ] = 0;
+ input_Seek( p_input, (off_t)atoi( psz_cmd + 1 ),
INPUT_SEEK_SECONDS | INPUT_SEEK_SET );
/* rcreseek(f_cpos); */
}
/* Ignore empty lines */
break;
default:
- printf( "unknown command `%s', type `help' for help\n", p_cmd );
+ printf( "unknown command `%s', type `help' for help\n", psz_cmd );
break;
}
}
vlc_object_release( p_playlist );
p_playlist = NULL;
}
+}
+
+static int Playlist( vlc_object_t *p_this, char *psz_cmd, char *psz_arg )
+{
+ input_thread_t * p_input;
+ playlist_t * p_playlist;
+
+ p_input = vlc_object_find( p_this, VLC_OBJECT_INPUT, FIND_ANYWHERE );
+
+ if( !p_input )
+ {
+ return VLC_ENOOBJ;
+ }
+
+ /* Parse commands that only require an input */
+ if( !strcmp( psz_cmd, "pause" ) )
+ {
+ input_SetStatus( p_input, INPUT_STATUS_PAUSE );
+ vlc_object_release( p_input );
+ return VLC_SUCCESS;
+ }
+
+ p_playlist = vlc_object_find( p_input, VLC_OBJECT_PLAYLIST,
+ FIND_PARENT );
+ vlc_object_release( p_input );
+
+ if( !p_playlist )
+ {
+ return VLC_ENOOBJ;
+ }
+
+ /* Parse commands that require a playlist */
+ if( !strcmp( psz_cmd, "prev" ) )
+ {
+ playlist_Prev( p_playlist );
+ }
+ else if( !strcmp( psz_cmd, "next" ) )
+ {
+ playlist_Next( p_playlist );
+ }
+ else if( !strcmp( psz_cmd, "play" ) )
+ {
+ playlist_Play( p_playlist );
+ }
+ else if( !strcmp( psz_cmd, "stop" ) )
+ {
+ playlist_Stop( p_playlist );
+ }
+
+ return VLC_SUCCESS;
+}
+
+static int Quit( vlc_object_t *p_this, char *psz_cmd, char *psz_arg )
+{
+ p_this->p_vlc->b_die = VLC_TRUE;
+ return VLC_SUCCESS;
+}
+
+static int Intf( vlc_object_t *p_this, char *psz_cmd, char *psz_arg )
+{
+ intf_thread_t *p_newintf;
+ char *psz_oldmodule = config_GetPsz( p_this->p_vlc, "intf" );
+
+ config_PutPsz( p_this->p_vlc, "intf", psz_arg );
+ p_newintf = intf_Create( p_this->p_vlc );
+ config_PutPsz( p_this->p_vlc, "intf", psz_oldmodule );
+
+ if( psz_oldmodule )
+ {
+ free( psz_oldmodule );
+ }
- var_Destroy( p_intf, "foo" );
+ if( p_newintf )
+ {
+ p_newintf->b_block = VLC_FALSE;
+ if( intf_RunThread( p_newintf ) )
+ {
+ vlc_object_detach( p_newintf );
+ intf_Destroy( p_newintf );
+ }
+ }
+
+ return VLC_SUCCESS;
}
+static int Signal( vlc_object_t *p_this, char *psz_cmd, char *psz_arg )
+{
+ raise( atoi(psz_arg) );
+ return VLC_SUCCESS;
+}
+
+
* familiar.c : familiar plugin for vlc
*****************************************************************************
* Copyright (C) 2002 VideoLAN
- * $Id: familiar.c,v 1.9 2002/09/15 19:32:02 jpsaman Exp $
+ * $Id: familiar.c,v 1.10 2002/10/14 16:46:55 sam Exp $
*
* Authors: Jean-Paul Saman <jpsaman@wxs.nl>
*
if( p_intf->p_sys->p_gtk_main == NULL )
{
free( p_intf->p_sys );
- return VLC_EMODULE;
+ return VLC_ENOMOD;
}
/* Initialize Gtk+ thread */
* gnome.c : Gnome plugin for vlc
*****************************************************************************
* Copyright (C) 2000 VideoLAN
- * $Id: gnome.c,v 1.3 2002/09/30 11:05:39 sam Exp $
+ * $Id: gnome.c,v 1.4 2002/10/14 16:46:55 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
if( p_intf->p_sys->p_gtk_main == NULL )
{
free( p_intf->p_sys );
- return VLC_EMODULE;
+ return VLC_ENOMOD;
}
p_intf->pf_run = Run;
* gtk.c : Gtk+ plugin for vlc
*****************************************************************************
* Copyright (C) 2000-2001 VideoLAN
- * $Id: gtk.c,v 1.5 2002/10/04 18:07:21 sam Exp $
+ * $Id: gtk.c,v 1.6 2002/10/14 16:46:55 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
if( p_intf->p_sys->p_gtk_main == NULL )
{
free( p_intf->p_sys );
- return VLC_EMODULE;
+ return VLC_ENOMOD;
}
#endif
* libvlc.c: main libvlc source
*****************************************************************************
* Copyright (C) 1998-2002 VideoLAN
- * $Id: libvlc.c,v 1.38 2002/10/11 22:32:56 sam Exp $
+ * $Id: libvlc.c,v 1.39 2002/10/14 16:46:55 sam Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
#include "vlc_cpu.h" /* CPU detection */
#include "os_specific.h"
+#include "error.h"
#include "netutils.h" /* network_ChannelJoin */
#include "stream_control.h"
* Local prototypes
*****************************************************************************/
static int GetFilenames ( vlc_t *, int, char *[] );
-static void Usage ( vlc_t *, const char *psz_module_name );
+static void Usage ( vlc_t *, char const *psz_module_name );
static void ListModules ( vlc_t * );
static void Version ( void );
*****************************************************************************
* This function returns full version string (numeric version and codename).
*****************************************************************************/
-char * VLC_Version( void )
+char const * VLC_Version( void )
{
return VERSION_MESSAGE;
}
+/*****************************************************************************
+ * VLC_Error: strerror() equivalent
+ *****************************************************************************
+ * This function returns full version string (numeric version and codename).
+ *****************************************************************************/
+char const * VLC_Error( int i_err )
+{
+ return vlc_error( i_err );
+}
+
/*****************************************************************************
* VLC_Create: allocate a vlc_t structure, and initialize libvlc if needed.
*****************************************************************************
/* Store data for the non-reentrant API */
p_static_vlc = p_vlc;
- /* Update the handle status */
- p_vlc->i_status = VLC_STATUS_CREATED;
-
return p_vlc->i_object_id;
}
p_vlc = i_object ? vlc_object_get( &libvlc, i_object ) : p_static_vlc;
- /* Check that the handle is valid */
- if( !p_vlc || p_vlc->i_status != VLC_STATUS_CREATED )
+ if( !p_vlc )
{
- fprintf( stderr, "error: invalid status (!CREATED)\n" );
- return VLC_ESTATUS;
+ return VLC_ENOOBJ;
}
/* Support for gettext */
return VLC_EGENERIC;
}
- /* Update the handle status */
- p_vlc->i_status = VLC_STATUS_STOPPED;
-
/*
* Get input filenames given as commandline arguments
*/
* separate thread. If b_block is set to 1, VLC_AddIntf will continue until
* user requests to quit.
*****************************************************************************/
-int VLC_AddIntf( int i_object, const char *psz_module, vlc_bool_t b_block )
+int VLC_AddIntf( int i_object, char const *psz_module, vlc_bool_t b_block )
{
int i_err;
intf_thread_t *p_intf;
p_vlc = i_object ? vlc_object_get( &libvlc, i_object ) : p_static_vlc;
- /* Check that the handle is valid */
- if( !p_vlc || p_vlc->i_status != VLC_STATUS_RUNNING )
+ if( !p_vlc )
{
- fprintf( stderr, "error: invalid status (!RUNNING)\n" );
- return VLC_ESTATUS;
+ return VLC_ENOOBJ;
}
if( psz_module )
p_vlc = i_object ? vlc_object_get( &libvlc, i_object ) : p_static_vlc;
- /* Check that the handle is valid */
- if( !p_vlc || (p_vlc->i_status != VLC_STATUS_STOPPED
- && p_vlc->i_status != VLC_STATUS_CREATED) )
+ if( !p_vlc )
{
- fprintf( stderr, "error: invalid status "
- "(!STOPPED&&!CREATED)\n" );
- return VLC_ESTATUS;
+ return VLC_ENOOBJ;
}
- if( p_vlc->i_status == VLC_STATUS_STOPPED )
+ /*
+ * Go back into channel 0 which is the network
+ */
+ if( config_GetInt( p_vlc, "network-channel" ) && p_vlc->p_channel )
{
- /*
- * Go back into channel 0 which is the network
- */
- if( config_GetInt( p_vlc, "network-channel" ) && p_vlc->p_channel )
- {
- network_ChannelJoin( p_vlc, COMMON_CHANNEL );
- }
-
- /*
- * Free allocated memory
- */
- if( p_vlc->p_memcpy_module != NULL )
- {
- module_Unneed( p_vlc, p_vlc->p_memcpy_module );
- }
-
- free( p_vlc->psz_homedir );
-
- /*
- * XXX: Free module bank !
- */
- //module_EndBank( p_vlc );
-
- /*
- * System specific cleaning code
- */
- system_End( p_vlc );
+ network_ChannelJoin( p_vlc, COMMON_CHANNEL );
+ }
- /* Update the handle status */
- p_vlc->i_status = VLC_STATUS_CREATED;
+ /*
+ * Free allocated memory
+ */
+ if( p_vlc->p_memcpy_module )
+ {
+ module_Unneed( p_vlc, p_vlc->p_memcpy_module );
+ p_vlc->p_memcpy_module = NULL;
}
- /* Update the handle status, just in case */
- p_vlc->i_status = VLC_STATUS_NONE;
+ if( p_vlc->psz_homedir )
+ {
+ free( p_vlc->psz_homedir );
+ p_vlc->psz_homedir = NULL;
+ }
+ /*
+ * XXX: Free module bank !
+ */
+ //module_EndBank( p_vlc );
+
+ /*
+ * System specific cleaning code
+ */
+ system_End( p_vlc );
+
/* Destroy mutexes */
vlc_mutex_destroy( &p_vlc->config_lock );
if( !p_vlc )
{
- fprintf( stderr, "error: invalid status (!EXIST)\n" );
- return VLC_ESTATUS;
+ return VLC_ENOOBJ;
}
p_vlc->b_die = VLC_TRUE;
* This function adds psz_target to the current playlist. If a playlist does
* not exist, it will create one.
*****************************************************************************/
-int VLC_AddTarget( int i_object, const char *psz_target, int i_mode, int i_pos )
+int VLC_AddTarget( int i_object, char const *psz_target, int i_mode, int i_pos )
{
int i_err;
playlist_t *p_playlist;
p_vlc = i_object ? vlc_object_get( &libvlc, i_object ) : p_static_vlc;
- if( !p_vlc || ( p_vlc->i_status != VLC_STATUS_STOPPED
- && p_vlc->i_status != VLC_STATUS_RUNNING ) )
+ if( !p_vlc )
{
- fprintf( stderr, "error: invalid status (!STOPPED&&!RUNNING)\n" );
- return VLC_ESTATUS;
+ return VLC_ENOOBJ;
}
p_playlist = vlc_object_find( p_vlc, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
*****************************************************************************
*
*****************************************************************************/
-int VLC_Set( int i_object, const char *psz_var, vlc_value_t value )
+int VLC_Set( int i_object, char const *psz_var, vlc_value_t value )
{
vlc_t *p_vlc;
if( !p_vlc )
{
- fprintf( stderr, "error: invalid status\n" );
- return VLC_ESTATUS;
+ return VLC_ENOOBJ;
}
/* FIXME: Temporary hack for Mozilla, if variable starts with conf:: then
if( !strncmp( psz_var, "conf::", 6 ) )
{
module_config_t *p_item;
- const char *psz_newvar = psz_var + 6;
+ char const *psz_newvar = psz_var + 6;
p_item = config_FindConfig( VLC_OBJECT(p_vlc), psz_newvar );
*****************************************************************************
*
*****************************************************************************/
-int VLC_Get( int i_object, const char *psz_var, vlc_value_t *p_value )
+int VLC_Get( int i_object, char const *psz_var, vlc_value_t *p_value )
{
vlc_t *p_vlc;
if( !p_vlc )
{
- fprintf( stderr, "error: invalid status\n" );
- return VLC_ESTATUS;
+ return VLC_ENOOBJ;
}
return var_Get( p_vlc, psz_var, p_value );
p_vlc = i_object ? vlc_object_get( &libvlc, i_object ) : p_static_vlc;
/* Check that the handle is valid */
- if( !p_vlc || p_vlc->i_status != VLC_STATUS_STOPPED )
+ if( !p_vlc )
{
- fprintf( stderr, "error: invalid status (!STOPPED)\n" );
- return VLC_ESTATUS;
+ return VLC_ENOOBJ;
}
- /* Update the handle status */
- p_vlc->i_status = VLC_STATUS_RUNNING;
-
p_playlist = vlc_object_find( p_vlc, VLC_OBJECT_PLAYLIST, FIND_CHILD );
if( !p_playlist )
{
- return VLC_EOBJECT;
+ return VLC_ENOOBJ;
}
vlc_mutex_lock( &p_playlist->object_lock );
p_vlc = i_object ? vlc_object_get( &libvlc, i_object ) : p_static_vlc;
/* Check that the handle is valid */
- if( !p_vlc || ( p_vlc->i_status != VLC_STATUS_STOPPED
- && p_vlc->i_status != VLC_STATUS_RUNNING ) )
+ if( !p_vlc )
{
- fprintf( stderr, "error: invalid status (!STOPPED&&!RUNNING)\n" );
- return VLC_ESTATUS;
+ return VLC_ENOOBJ;
}
/*
aout_Delete( p_aout );
}
- /* Update the handle status */
- p_vlc->i_status = VLC_STATUS_STOPPED;
-
return VLC_SUCCESS;
}
if( !p_vlc )
{
- return VLC_ESTATUS;
+ return VLC_ENOOBJ;
}
p_input = vlc_object_find( p_vlc, VLC_OBJECT_INPUT, FIND_CHILD );
if( !p_input )
{
- return VLC_EOBJECT;
+ return VLC_ENOOBJ;
}
input_SetStatus( p_input, INPUT_STATUS_PAUSE );
if( !p_vlc )
{
- return VLC_ESTATUS;
+ return VLC_ENOOBJ;
}
p_vout = vlc_object_find( p_vlc, VLC_OBJECT_VOUT, FIND_CHILD );
if( !p_vout )
{
- return VLC_EOBJECT;
+ return VLC_ENOOBJ;
}
p_vout->i_changes |= VOUT_FULLSCREEN_CHANGE;
*****************************************************************************
* Print a short inline help. Message interface is initialized at this stage.
*****************************************************************************/
-static void Usage( vlc_t *p_this, const char *psz_module_name )
+static void Usage( vlc_t *p_this, char const *psz_module_name )
{
#define FORMAT_STRING " --%s%s%s%s%s%s%s %s%s\n"
/* option name -------------' | | | | | |
* modules, especially intf modules. See config.h for output configuration.
*****************************************************************************
* Copyright (C) 1998-2002 VideoLAN
- * $Id: messages.c,v 1.14 2002/10/10 22:46:20 massiot Exp $
+ * $Id: messages.c,v 1.15 2002/10/14 16:46:56 sam Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
/* Send the message to stderr */
if( p_this->p_libvlc->b_color )
{
- fprintf( stderr, "[" GREEN "%.6x" GRAY "] %s %s%s: %s%s" GRAY "\n",
+ fprintf( stderr, "[" GREEN "%.8i" GRAY "] %s %s%s: %s%s" GRAY "\n",
p_item->i_object_id, p_item->psz_module, psz_object,
ppsz_type[i_type], ppsz_color[i_type],
p_item->psz_msg );
}
else
{
- fprintf( stderr, "[%.6x] %s %s%s: %s\n", p_item->i_object_id,
+ fprintf( stderr, "[%.8i] %s %s%s: %s\n", p_item->i_object_id,
p_item->psz_module, psz_object, ppsz_type[i_type],
p_item->psz_msg );
}
* modules.c : Builtin and plugin modules management functions
*****************************************************************************
* Copyright (C) 2001 VideoLAN
- * $Id: modules.c,v 1.97 2002/10/11 10:08:06 gbazin Exp $
+ * $Id: modules.c,v 1.98 2002/10/14 16:46:56 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
* Ethan C. Baldridge <BaldridgeE@cadmus.com>
# undef HAVE_DYNAMIC_PLUGINS
#endif
-
+#include "error.h"
#include "netutils.h"
#include "interface.h"
* objects.c: vlc_object_t handling
*****************************************************************************
* Copyright (C) 2002 VideoLAN
- * $Id: objects.c,v 1.24 2002/10/11 22:32:56 sam Exp $
+ * $Id: objects.c,v 1.25 2002/10/14 16:46:56 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
/*****************************************************************************
* Local prototypes
*****************************************************************************/
+static int DumpCommand( vlc_object_t *, char *, char * );
+
static vlc_object_t * FindObject ( vlc_object_t *, int, int );
static void DetachObject ( vlc_object_t * );
static void PrintObject ( vlc_object_t *, const char * );
psz_type = "audio output";
break;
default:
- i_size = i_type > sizeof(vlc_object_t)
- ? i_type : sizeof(vlc_object_t);
+ i_size = i_type > 0
+ ? i_type > sizeof(vlc_object_t)
+ ? i_type : sizeof(vlc_object_t)
+ : sizeof(vlc_object_t);
i_type = VLC_OBJECT_GENERIC;
psz_type = "generic";
break;
if( i_type == VLC_OBJECT_ROOT )
{
vlc_mutex_init( p_new, &structure_lock );
+
+ var_Create( p_new, "list", VLC_VAR_COMMAND );
+ var_Set( p_new, "list", (vlc_value_t)(void*)DumpCommand );
+ var_Create( p_new, "tree", VLC_VAR_COMMAND );
+ var_Set( p_new, "tree", (vlc_value_t)(void*)DumpCommand );
}
return p_new;
if( p_this->i_children )
{
msg_Err( p_this, "cannot delete object with children" );
- vlc_dumpstructure( p_this );
return;
}
if( p_this->p_parent )
{
msg_Err( p_this, "cannot delete object with a parent" );
- vlc_dumpstructure( p_this );
return;
}
}
/*****************************************************************************
- * vlc_liststructure: print the current vlc objects
+ * DumpCommand: print the current vlc structure
*****************************************************************************
- * This function prints alist of vlc objects, and additional information such
- * as their refcount, thread ID, etc.
+ * This function prints either an ASCII tree showing the connections between
+ * vlc objects, and additional information such as their refcount, thread ID,
+ * etc. (command "tree"), or the same data as a simple list (command "list").
*****************************************************************************/
-void __vlc_liststructure( vlc_object_t *p_this )
+static int DumpCommand( vlc_object_t *p_this, char *psz_cmd, char *psz_arg )
{
- vlc_object_t **pp_current, **pp_end;
-
vlc_mutex_lock( &structure_lock );
- pp_current = p_this->p_libvlc->pp_objects;
- pp_end = pp_current + p_this->p_libvlc->i_objects;
-
- for( ; pp_current < pp_end ; pp_current++ )
+ if( *psz_cmd == 't' )
{
- if( (*pp_current)->b_attached )
+ char psz_foo[2 * MAX_DUMPSTRUCTURE_DEPTH + 1];
+ vlc_object_t *p_object;
+
+ if( *psz_arg )
{
- PrintObject( *pp_current, "" );
+ p_object = vlc_object_get( p_this, atoi(psz_arg) );
+
+ if( !p_object )
+ {
+ return VLC_ENOOBJ;
+ }
}
else
{
- printf( " o %.6x %s (not attached)\n",
- (*pp_current)->i_object_id,
- (*pp_current)->psz_object_type );
+ p_object = p_this->p_vlc ? VLC_OBJECT(p_this->p_vlc) : p_this;
}
+
+ psz_foo[0] = '|';
+ DumpStructure( p_object, 0, psz_foo );
}
+ else if( *psz_cmd == 'l' )
+ {
+ vlc_object_t **pp_current, **pp_end;
- vlc_mutex_unlock( &structure_lock );
-}
+ pp_current = p_this->p_libvlc->pp_objects;
+ pp_end = pp_current + p_this->p_libvlc->i_objects;
-/*****************************************************************************
- * vlc_dumpstructure: print the current vlc structure
- *****************************************************************************
- * This function prints an ASCII tree showing the connections between vlc
- * objects, and additional information such as their refcount, thread ID, etc.
- *****************************************************************************/
-void __vlc_dumpstructure( vlc_object_t *p_this )
-{
- char psz_foo[2 * MAX_DUMPSTRUCTURE_DEPTH + 1];
+ for( ; pp_current < pp_end ; pp_current++ )
+ {
+ if( (*pp_current)->b_attached )
+ {
+ PrintObject( *pp_current, "" );
+ }
+ else
+ {
+ printf( " o %.8i %s (not attached)\n",
+ (*pp_current)->i_object_id,
+ (*pp_current)->psz_object_type );
+ }
+ }
+ }
- vlc_mutex_lock( &structure_lock );
- psz_foo[0] = '|';
- DumpStructure( p_this, 0, psz_foo );
vlc_mutex_unlock( &structure_lock );
+
+ return VLC_SUCCESS;
}
/*****************************************************************************
psz_thread[19] = '\0';
}
- printf( " %so %.6x %s%s%s%s%s\n", psz_prefix,
+ printf( " %so %.8i %s%s%s%s%s\n", psz_prefix,
p_this->i_object_id, p_this->psz_object_type,
psz_name, psz_thread, psz_refcount, psz_children );
}
* variables.c: routines for object variables handling
*****************************************************************************
* Copyright (C) 2002 VideoLAN
- * $Id: variables.c,v 1.1 2002/10/11 11:05:52 sam Exp $
+ * $Id: variables.c,v 1.2 2002/10/14 16:46:56 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
* may require slow memory copies, but think about what we gain in the log(n)
* lookup phase when setting/getting the variable value!
*****************************************************************************/
-void __var_Create( vlc_object_t *p_this, const char *psz_name, int i_type )
+int __var_Create( vlc_object_t *p_this, const char *psz_name, int i_type )
{
int i_new;
p_this->i_vars++;
vlc_mutex_unlock( &p_this->var_lock );
+
+ return VLC_SUCCESS;
}
/*****************************************************************************
* Look for the variable and destroy it if it is found. As in var_Create we
* do a call to memmove() but we have performance counterparts elsewhere.
*****************************************************************************/
-void __var_Destroy( vlc_object_t *p_this, const char *psz_name )
+int __var_Destroy( vlc_object_t *p_this, const char *psz_name )
{
int i_del;
{
msg_Err( p_this, "variable %s was not found", psz_name );
vlc_mutex_unlock( &p_this->var_lock );
- return;
+ return VLC_ENOVAR;
}
/* Free value if needed */
p_this->i_vars--;
vlc_mutex_unlock( &p_this->var_lock );
+
+ return VLC_SUCCESS;
+}
+
+/*****************************************************************************
+ * var_Type: request a variable's type, 0 if not found
+ *****************************************************************************
+ *
+ *****************************************************************************/
+int __var_Type( vlc_object_t *p_this, const char *psz_name )
+{
+ int i_var, i_type;
+
+ vlc_mutex_lock( &p_this->var_lock );
+
+ i_var = Lookup( p_this->p_vars, p_this->i_vars, psz_name );
+
+ if( i_var < 0 )
+ {
+ vlc_mutex_unlock( &p_this->var_lock );
+ return 0;
+ }
+
+ i_type = p_this->p_vars[i_var].i_type;
+
+ vlc_mutex_unlock( &p_this->var_lock );
+
+ return i_type;
}
/*****************************************************************************
if( i_var < 0 )
{
- msg_Err( p_this, "variable %s was not found", psz_name );
vlc_mutex_unlock( &p_this->var_lock );
- return VLC_EVAR;
+ return VLC_ENOVAR;
}
/* Duplicate value if needed */
*****************************************************************************
*
*****************************************************************************/
-int __var_Get( vlc_object_t *p_this, const char *psz_name,
- vlc_value_t *p_value )
+int __var_Get( vlc_object_t *p_this, const char *psz_name, vlc_value_t *p_val )
{
int i_var;
if( i_var < 0 )
{
- msg_Err( p_this, "variable %s was not found", psz_name );
vlc_mutex_unlock( &p_this->var_lock );
- return VLC_EVAR;
+ return VLC_ENOVAR;
}
if( !p_this->p_vars[i_var].b_set )
{
- msg_Err( p_this, "variable %s is not set", psz_name );
vlc_mutex_unlock( &p_this->var_lock );
- return VLC_EVAR;
+ return VLC_EBADVAR;
+ }
+
+ /* Some variables trigger special behaviour. */
+ switch( p_this->p_vars[i_var].i_type )
+ {
+ case VLC_VAR_COMMAND:
+ if( p_this->p_vars[i_var].b_set )
+ {
+ int i_ret = ((int (*) (vlc_object_t *, char *, char *))
+ p_this->p_vars[i_var].val.p_address) (
+ p_this,
+ p_this->p_vars[i_var].psz_name,
+ p_val->psz_string );
+ vlc_mutex_unlock( &p_this->var_lock );
+ return i_ret;
+ }
+ break;
}
- *p_value = p_this->p_vars[i_var].val;
+ /* Really set the variable */
+ *p_val = p_this->p_vars[i_var].val;
/* Duplicate value if needed */
switch( p_this->p_vars[i_var].i_type )
case VLC_VAR_STRING:
case VLC_VAR_MODULE:
case VLC_VAR_FILE:
- if( p_value->psz_string )
+ if( p_val->psz_string )
{
- p_value->psz_string = strdup( p_value->psz_string );
+ p_val->psz_string = strdup( p_val->psz_string );
}
break;
}
* vlc.c: the vlc player
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
- * $Id: vlc.c,v 1.14 2002/10/11 22:32:56 sam Exp $
+ * $Id: vlc.c,v 1.15 2002/10/14 16:46:55 sam Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
/* Run libvlc, in non-blocking mode */
i_ret = VLC_Play( 0 );
- /* Add background interfaces */
-#if 0
- { int i; for( i=10; i--; ) VLC_AddIntf( 0, "dummy", 0 ); }
- VLC_AddIntf( 0, "dummy", VLC_FALSE );
- VLC_AddIntf( 0, "logger", VLC_FALSE );
- VLC_AddIntf( 0, "xosd", VLC_FALSE );
- VLC_AddIntf( 0, "gtk", VLC_FALSE );
- VLC_AddIntf( 0, "kde", VLC_FALSE );
- VLC_AddIntf( 0, "rc", VLC_FALSE );
-#endif
-
/* Add a blocking interface and keep the return value */
i_ret = VLC_AddIntf( 0, NULL, VLC_TRUE );