Commit bf7985b7 authored by Sam Hocevar's avatar Sam Hocevar

* ./include/vlc/vlc.h, ./src/libvlc.c: added VLC_Error() to the libvlc API.

  * ./include/main.h: removed p_vlc->i_status because it was not sufficient
    to represent all the possible states of p_vlc; each part should be tested
    separately upon destruction.
  * ./src/misc/objects.c: fixed a signed/unsigned bug that prevented creation
    of VLC_OBJECT_GENERIC objects.

  * ./src/misc/variables.c: added the VLC_VAR_COMMAND type which is simply a
    variable that stores a function pointer, and calls it when var_Get is
    called for it. The function argument is taken in val.psz_string.
  * ./src/misc/objects.c: vlc_dumpstructure and vlc_liststructure are no longer
    exported to the rest of the program; instead, they're VLC_VAR_COMMAND vars
    ("tree" and "list").
  * ./modules/control/rc/rc.c: moved a few commands to VLC_VAR_COMMAND vars.
parent ebda60f2
...@@ -155,6 +155,7 @@ HEADERS_include = \ ...@@ -155,6 +155,7 @@ HEADERS_include = \
include/beos_specific.h \ include/beos_specific.h \
include/configuration.h \ include/configuration.h \
include/darwin_specific.h \ include/darwin_specific.h \
include/error.h \
include/input_ext-dec.h \ include/input_ext-dec.h \
include/input_ext-intf.h \ include/input_ext-intf.h \
include/input_ext-plugins.h \ include/input_ext-plugins.h \
...@@ -336,6 +337,7 @@ SOURCES_libvlc = \ ...@@ -336,6 +337,7 @@ SOURCES_libvlc = \
src/misc/messages.c \ src/misc/messages.c \
src/misc/objects.c \ src/misc/objects.c \
src/misc/variables.c \ src/misc/variables.c \
src/misc/error.c \
src/misc/extras.c \ src/misc/extras.c \
$(SOURCES_libvlc_win32) \ $(SOURCES_libvlc_win32) \
$(SOURCES_libvlc_beos) \ $(SOURCES_libvlc_beos) \
......
...@@ -2129,12 +2129,14 @@ AC_ARG_ENABLE(testsuite, ...@@ -2129,12 +2129,14 @@ AC_ARG_ENABLE(testsuite,
[ --enable-testsuite build test modules (default disabled)]) [ --enable-testsuite build test modules (default disabled)])
if test "x${enable_testsuite}" = "xyes" if test "x${enable_testsuite}" = "xyes"
then then
TESTS="test1 test2 test3" TESTS="test1 test2 test3 test4"
dnl we define those so that bootstrap sets the right linker dnl we define those so that bootstrap sets the right linker
CXXFLAGS_test2="${CXXFLAGS_test2}" CXXFLAGS_test2="${CXXFLAGS_test2}"
OBJCFLAGS_test3="${OBJCFLAGS_test3}" OBJCFLAGS_test3="${OBJCFLAGS_test3}"
dnl this one is needed until automake knows what to do dnl this one is needed until automake knows what to do
LDFLAGS_test3="${LDFLAGS_test3} -lobjc" LDFLAGS_test3="${LDFLAGS_test3} -lobjc"
PLUGINS="${PLUGINS} ${TESTS}" PLUGINS="${PLUGINS} ${TESTS}"
#BUILTINS="${BUILTINS} ${TESTS}" #BUILTINS="${BUILTINS} ${TESTS}"
fi fi
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* Declaration and extern access to global program object. * Declaration and extern access to global program object.
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000, 2001, 2002 VideoLAN * 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> * Authors: Vincent Seguin <seguin@via.ecp.fr>
* *
...@@ -73,9 +73,6 @@ struct vlc_t ...@@ -73,9 +73,6 @@ struct vlc_t
{ {
VLC_COMMON_MEMBERS VLC_COMMON_MEMBERS
/* The vlc structure status */
int i_status;
/* Global properties */ /* Global properties */
int i_argc; /* command line arguments count */ int i_argc; /* command line arguments count */
char ** ppsz_argv; /* command line arguments */ char ** ppsz_argv; /* command line arguments */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* variables.h: variables handling * variables.h: variables handling
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * 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> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#define VLC_VAR_FLOAT 0x0400 #define VLC_VAR_FLOAT 0x0400
#define VLC_VAR_TIME 0x0500 #define VLC_VAR_TIME 0x0500
#define VLC_VAR_ADDRESS 0x0600 #define VLC_VAR_ADDRESS 0x0600
#define VLC_VAR_COMMAND 0x0700
/***************************************************************************** /*****************************************************************************
* vlc_value_t is the common union for variable values; variable_t is the * vlc_value_t is the common union for variable values; variable_t is the
...@@ -51,9 +52,10 @@ struct variable_t ...@@ -51,9 +52,10 @@ struct variable_t
/***************************************************************************** /*****************************************************************************
* Prototypes * Prototypes
*****************************************************************************/ *****************************************************************************/
VLC_EXPORT( void, __var_Create, ( vlc_object_t *, const char *, int ) ); VLC_EXPORT( int, __var_Create, ( vlc_object_t *, const char *, int ) );
VLC_EXPORT( void, __var_Destroy, ( vlc_object_t *, const char * ) ); 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_Set, ( vlc_object_t *, const char *, vlc_value_t ) );
VLC_EXPORT( int, __var_Get, ( vlc_object_t *, const char *, vlc_value_t * ) ); VLC_EXPORT( int, __var_Get, ( vlc_object_t *, const char *, vlc_value_t * ) );
...@@ -63,6 +65,9 @@ VLC_EXPORT( int, __var_Get, ( vlc_object_t *, const char *, vlc_value_t * ) ); ...@@ -63,6 +65,9 @@ VLC_EXPORT( int, __var_Get, ( vlc_object_t *, const char *, vlc_value_t * ) );
#define var_Destroy(a,b) \ #define var_Destroy(a,b) \
__var_Destroy( VLC_OBJECT(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) \ #define var_Set(a,b,c) \
__var_Set( VLC_OBJECT(a), b, c ) __var_Set( VLC_OBJECT(a), b, c )
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* vlc.h: global header for vlc * vlc.h: global header for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN * 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 * 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 * it under the terms of the GNU General Public License as published by
...@@ -39,7 +39,7 @@ typedef union ...@@ -39,7 +39,7 @@ typedef union
char * psz_string; char * psz_string;
void * p_address; 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; struct { char a, b, c, d, e, f, g, h; } padding;
} vlc_value_t; } vlc_value_t;
...@@ -49,11 +49,16 @@ typedef union ...@@ -49,11 +49,16 @@ typedef union
*****************************************************************************/ *****************************************************************************/
#define VLC_SUCCESS -0 /* No error */ #define VLC_SUCCESS -0 /* No error */
#define VLC_ENOMEM -1 /* Not enough memory */ #define VLC_ENOMEM -1 /* Not enough memory */
#define VLC_EMODULE -2 /* Module not found */ #define VLC_ETHREAD -2 /* Thread error */
#define VLC_ESTATUS -3 /* Invalid status */
#define VLC_ETHREAD -4 /* Could not spawn thread */ #define VLC_ENOMOD -10 /* Module not found */
#define VLC_EOBJECT -5 /* Object not found */
#define VLC_EVAR -6 /* Variable 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_EEXIT -255 /* Program exited */
#define VLC_EGENERIC -666 /* Generic error */ #define VLC_EGENERIC -666 /* Generic error */
...@@ -63,14 +68,6 @@ typedef union ...@@ -63,14 +68,6 @@ typedef union
#define VLC_FALSE 0 #define VLC_FALSE 0
#define VLC_TRUE 1 #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 * Playlist
*****************************************************************************/ *****************************************************************************/
...@@ -110,22 +107,23 @@ typedef union ...@@ -110,22 +107,23 @@ typedef union
/***************************************************************************** /*****************************************************************************
* Exported libvlc API * Exported libvlc API
*****************************************************************************/ *****************************************************************************/
char * VLC_Version ( void ); char const * VLC_Version ( void );
char const * VLC_Error ( int );
int VLC_Create ( void );
int VLC_Init ( int, int, char *[] ); int VLC_Create ( void );
int VLC_Die ( int ); int VLC_Init ( int, int, char *[] );
int VLC_Destroy ( int ); 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_Set ( int, char const *, vlc_value_t );
int VLC_AddIntf ( int, const char *, vlc_bool_t ); int VLC_Get ( int, char const *, vlc_value_t * );
int VLC_AddTarget ( int, const char *, int, int ); 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_Play ( int );
int VLC_Stop ( int ); int VLC_Pause ( int );
int VLC_FullScreen ( int ); int VLC_Stop ( int );
int VLC_FullScreen ( int );
# ifdef __cplusplus # ifdef __cplusplus
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* vlc_objects.h: vlc_object_t definition. * vlc_objects.h: vlc_object_t definition.
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * 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> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -77,9 +77,6 @@ VLC_EXPORT( void, __vlc_object_release, ( vlc_object_t * ) ); ...@@ -77,9 +77,6 @@ VLC_EXPORT( void, __vlc_object_release, ( vlc_object_t * ) );
VLC_EXPORT( vlc_list_t *, __vlc_list_find, ( vlc_object_t *, int, int ) ); 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_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) \ #define vlc_object_create(a,b) \
__vlc_object_create( VLC_OBJECT(a), b ) __vlc_object_create( VLC_OBJECT(a), b )
...@@ -108,9 +105,3 @@ VLC_EXPORT( void, __vlc_dumpstructure, ( vlc_object_t * ) ); ...@@ -108,9 +105,3 @@ VLC_EXPORT( void, __vlc_dumpstructure, ( vlc_object_t * ) );
#define vlc_list_find(a,b,c) \ #define vlc_list_find(a,b,c) \
__vlc_list_find( VLC_OBJECT(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) )
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* rc.c : remote control stdin/stdout plugin for vlc * rc.c : remote control stdin/stdout plugin for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * 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> * Authors: Peter Surda <shurdeek@panorama.sth.ac.at>
* *
...@@ -57,6 +57,10 @@ ...@@ -57,6 +57,10 @@
static int Activate ( vlc_object_t * ); static int Activate ( vlc_object_t * );
static void Run ( intf_thread_t *p_intf ); 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 * Module descriptor
*****************************************************************************/ *****************************************************************************/
...@@ -89,7 +93,7 @@ static int Activate( vlc_object_t *p_this ) ...@@ -89,7 +93,7 @@ static int Activate( vlc_object_t *p_this )
if( !config_GetInt( p_intf, "fake-tty" ) && !isatty( 0 ) ) if( !config_GetInt( p_intf, "fake-tty" ) && !isatty( 0 ) )
{ {
msg_Warn( p_intf, "fd 0 is not a TTY" ); msg_Warn( p_intf, "fd 0 is not a TTY" );
return 1; return VLC_EGENERIC;
} }
#endif #endif
...@@ -101,7 +105,7 @@ static int Activate( vlc_object_t *p_this ) ...@@ -101,7 +105,7 @@ static int Activate( vlc_object_t *p_this )
CONSOLE_INTRO_MSG; CONSOLE_INTRO_MSG;
printf( "remote control interface initialized, `h' for help\n" ); printf( "remote control interface initialized, `h' for help\n" );
return 0; return VLC_SUCCESS;
} }
/***************************************************************************** /*****************************************************************************
...@@ -116,7 +120,6 @@ static void Run( intf_thread_t *p_intf ) ...@@ -116,7 +120,6 @@ static void Run( intf_thread_t *p_intf )
playlist_t * p_playlist; playlist_t * p_playlist;
char p_buffer[ MAX_LINE_LENGTH + 1 ]; 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" ); vlc_bool_t b_showpos = config_GetInt( p_intf, "rc-show-pos" );
input_info_category_t * p_category; input_info_category_t * p_category;
input_info_t * p_info; input_info_t * p_info;
...@@ -124,20 +127,34 @@ static void Run( intf_thread_t *p_intf ) ...@@ -124,20 +127,34 @@ static void Run( intf_thread_t *p_intf )
int i_dummy; int i_dummy;
off_t i_oldpos = 0; off_t i_oldpos = 0;
off_t i_newpos; 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_input = NULL;
p_playlist = NULL; p_playlist = NULL;
var_Create( p_intf, "foo", VLC_VAR_STRING ); /* Register commands that will be cleaned up upon object destruction */
var_Set( p_intf, "foo", (vlc_value_t)"test" ); 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 ) while( !p_intf->b_die )
{ {
b_complete = 0; fd_set fds;
struct timeval tv;
vlc_bool_t b_complete = VLC_FALSE;
/* Check stdin */ /* Check stdin */
tv.tv_sec = 0; tv.tv_sec = 0;
...@@ -164,7 +181,7 @@ static void Run( intf_thread_t *p_intf ) ...@@ -164,7 +181,7 @@ static void Run( intf_thread_t *p_intf )
|| p_buffer[ i_size ] == '\n' ) || p_buffer[ i_size ] == '\n' )
{ {
p_buffer[ i_size ] = 0; p_buffer[ i_size ] = 0;
b_complete = 1; b_complete = VLC_TRUE;
} }
} }
...@@ -215,83 +232,58 @@ static void Run( intf_thread_t *p_intf ) ...@@ -215,83 +232,58 @@ static void Run( intf_thread_t *p_intf )
} }
/* Is there something to do? */ /* 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" ) ) /* Skip heading spaces */
{ psz_cmd = p_buffer;
p_intf->p_vlc->b_die = VLC_TRUE; while( *psz_cmd == ' ' )
}
else if( !strcmp( p_cmd, "segfault" ) )
{
raise( SIGSEGV );
}
else if( !strcmp( p_cmd, "prev" ) )
{ {
if( p_playlist ) playlist_Prev( p_playlist ); psz_cmd++;
} }
else if( !strcmp( p_cmd, "next" ) )
{ /* Split psz_cmd at the first space and make sure that
if( p_playlist ) playlist_Next( p_playlist ); * psz_arg is valid */
} psz_arg = strchr( psz_cmd, ' ' );
else if( !strcmp( p_cmd, "play" ) ) if( psz_arg )
{
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" ) )
{ {
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; psz_arg = "";
value.psz_string = p_cmd + 7;
var_Set( p_intf, "foo", value );
} }
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; vlc_value_t val;
var_Get( p_intf, "foo", &value ); int i_ret;
printf( "current value is '%s'\n", value.psz_string );
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; vlc_value_t val;
char *psz_oldmodule = config_GetPsz( p_intf->p_vlc, "intf" ); int i_ret;
config_PutPsz( p_intf->p_vlc, "intf", p_cmd + 5 ); val.psz_string = psz_arg;
p_newintf = intf_Create( p_intf->p_vlc ); /* FIXME: it's a global command, but we should pass the
config_PutPsz( p_intf->p_vlc, "intf", psz_oldmodule ); * local object as an argument, not p_intf->p_libvlc. */
i_ret = var_Get( p_intf->p_libvlc, psz_cmd, &val );
if( psz_oldmodule ) printf( "%s: returned %i (%s)\n",
{ psz_cmd, i_ret, vlc_error( i_ret ) );
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 );
}
}
} }
else if( !strcmp( p_cmd, "info" ) ) else if( !strcmp( psz_cmd, "info" ) )
{ {
if ( p_input ) if ( p_input )
{ {
...@@ -319,13 +311,13 @@ static void Run( intf_thread_t *p_intf ) ...@@ -319,13 +311,13 @@ static void Run( intf_thread_t *p_intf )
printf( "no input\n" ); printf( "no input\n" );
} }
} }
else switch( p_cmd[0] ) else switch( psz_cmd[0] )
{ {
case 'a': case 'a':
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 ); PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
} }
break; break;
...@@ -356,15 +348,15 @@ static void Run( intf_thread_t *p_intf ) ...@@ -356,15 +348,15 @@ static void Run( intf_thread_t *p_intf )
if( p_input ) if( p_input )
{ {
for( i_dummy = 1; for( i_dummy = 1;
i_dummy < MAX_LINE_LENGTH && p_cmd[ i_dummy ] >= '0' i_dummy < MAX_LINE_LENGTH && psz_cmd[ i_dummy ] >= '0'
&& p_cmd[ i_dummy ] <= '9'; && psz_cmd[ i_dummy ] <= '9';
i_dummy++ ) i_dummy++ )
{ {
; ;
} }
p_cmd[ i_dummy ] = 0; psz_cmd[ i_dummy ] = 0;
input_Seek( p_input, (off_t)atoi( p_cmd + 1 ), input_Seek( p_input, (off_t)atoi( psz_cmd + 1 ),
INPUT_SEEK_SECONDS | INPUT_SEEK_SET ); INPUT_SEEK_SECONDS | INPUT_SEEK_SET );
/* rcreseek(f_cpos); */ /* rcreseek(f_cpos); */
} }
...@@ -395,7 +387,7 @@ static void Run( intf_thread_t *p_intf ) ...@@ -395,7 +387,7 @@ static void Run( intf_thread_t *p_intf )
/* Ignore empty lines */ /* Ignore empty lines */
break; break;
default: default:
printf( "unknown command `%s', type `help' for help\n", p_cmd ); printf( "unknown command `%s', type `help' for help\n", psz_cmd );
break; break;
} }
} }
...@@ -412,7 +404,95 @@ static void Run( intf_thread_t *p_intf ) ...@@ -412,7 +404,95 @@ static void Run( intf_thread_t *p_intf )
vlc_object_release( p_playlist ); vlc_object_release( p_playlist );
p_playlist = NULL; 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;
}
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* familiar.c : familiar plugin for vlc * familiar.c : familiar plugin for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * 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> * Authors: Jean-Paul Saman <jpsaman@wxs.nl>
* *
...@@ -75,7 +75,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -75,7 +75,7 @@ static int Open( vlc_object_t *p_this )
if( p_intf->p_sys->p_gtk_main == NULL ) if( p_intf->p_sys->p_gtk_main == NULL )
{ {
free( p_intf->p_sys ); free( p_intf->p_sys );
return VLC_EMODULE; return VLC_ENOMOD;
} }
/* Initialize Gtk+ thread */ /* Initialize Gtk+ thread */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* gnome.c : Gnome plugin for vlc * gnome.c : Gnome plugin for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2000 VideoLAN * 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> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -102,7 +102,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -102,7 +102,7 @@ static int Open( vlc_object_t *p_this )
if( p_intf->p_sys->p_gtk_main == NULL ) if( p_intf->p_sys->p_gtk_main == NULL )
{ {
free( p_intf->p_sys ); free( p_intf->p_sys );
return VLC_EMODULE; return VLC_ENOMOD;
} }
p_intf->pf_run = Run; p_intf->pf_run = Run;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* gtk.c : Gtk+ plugin for vlc * gtk.c : Gtk+ plugin for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2000-2001 VideoLAN * 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> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -100,7 +100,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -100,7 +100,7 @@ static int Open( vlc_object_t *p_this )
if( p_intf->p_sys->p_gtk_main == NULL ) if( p_intf->p_sys->p_gtk_main == NULL )
{ {
free( p_intf->p_sys ); free( p_intf->p_sys );
return VLC_EMODULE; return VLC_ENOMOD;
} }
#endif #endif
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* libvlc.c: main libvlc source * libvlc.c: main libvlc source
***************************************************************************** *****************************************************************************
* Copyright (C) 1998-2002 VideoLAN * 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> * Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org> * Samuel Hocevar <sam@zoy.org>
...@@ -61,6 +61,7 @@ ...@@ -61,6 +61,7 @@
#include "vlc_cpu.h" /* CPU detection */ #include "vlc_cpu.h" /* CPU detection */
#include "os_specific.h" #include "os_specific.h"
#include "error.h"
#include "netutils.h" /* network_ChannelJoin */ #include "netutils.h" /* network_ChannelJoin */
#include "stream_control.h" #include "stream_control.h"
...@@ -86,7 +87,7 @@ static vlc_t * p_static_vlc; ...@@ -86,7 +87,7 @@ static vlc_t * p_static_vlc;
* Local prototypes * Local prototypes
*****************************************************************************/ *****************************************************************************/
static int GetFilenames ( vlc_t *, int, char *[] ); 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 ListModules ( vlc_t * );
static void Version ( void ); static void Version ( void );
...@@ -99,11 +100,21 @@ static void ShowConsole ( void ); ...@@ -99,11 +100,21 @@ static void ShowConsole ( void );
***************************************************************************** *****************************************************************************
* This function returns full version string (numeric version and codename). * This function returns full version string (numeric version and codename).
*****************************************************************************/ *****************************************************************************/
char * VLC_Version( void ) char const * VLC_Version( void )
{ {
return VERSION_MESSAGE; 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. * VLC_Create: allocate a vlc_t structure, and initialize libvlc if needed.
***************************************************************************** *****************************************************************************
...@@ -182,9 +193,6 @@ int VLC_Create( void ) ...@@ -182,9 +193,6 @@ int VLC_Create( void )
/* Store data for the non-reentrant API */ /* Store data for the non-reentrant API */
p_static_vlc = p_vlc; p_static_vlc = p_vlc;
/* Update the handle status */
p_vlc->i_status = VLC_STATUS_CREATED;
return p_vlc->i_object_id; return p_vlc->i_object_id;
} }
...@@ -208,11 +216,9 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] ) ...@@ -208,11 +216,9 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] )
p_vlc = i_object ? vlc_object_get( &libvlc, i_object ) : p_static_vlc; p_vlc = i_object ? vlc_object_get( &libvlc, i_object ) : p_static_vlc;
/* Check that the handle is valid */ if( !p_vlc )
if( !p_vlc || p_vlc->i_status != VLC_STATUS_CREATED )
{ {
fprintf( stderr, "error: invalid status (!CREATED)\n" ); return VLC_ENOOBJ;
return VLC_ESTATUS;
} }
/* Support for gettext */ /* Support for gettext */
...@@ -482,9 +488,6 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] ) ...@@ -482,9 +488,6 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] )
return VLC_EGENERIC; return VLC_EGENERIC;
} }
/* Update the handle status */
p_vlc->i_status = VLC_STATUS_STOPPED;
/* /*
* Get input filenames given as commandline arguments * Get input filenames given as commandline arguments
*/ */
...@@ -501,7 +504,7 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] ) ...@@ -501,7 +504,7 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] )
* separate thread. If b_block is set to 1, VLC_AddIntf will continue until * separate thread. If b_block is set to 1, VLC_AddIntf will continue until
* user requests to quit. * 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; int i_err;
intf_thread_t *p_intf; intf_thread_t *p_intf;
...@@ -510,11 +513,9 @@ int VLC_AddIntf( int i_object, const char *psz_module, vlc_bool_t b_block ) ...@@ -510,11 +513,9 @@ int VLC_AddIntf( int i_object, const char *psz_module, vlc_bool_t b_block )
p_vlc = i_object ? vlc_object_get( &libvlc, i_object ) : p_static_vlc; p_vlc = i_object ? vlc_object_get( &libvlc, i_object ) : p_static_vlc;
/* Check that the handle is valid */ if( !p_vlc )
if( !p_vlc || p_vlc->i_status != VLC_STATUS_RUNNING )
{ {
fprintf( stderr, "error: invalid status (!RUNNING)\n" ); return VLC_ENOOBJ;
return VLC_ESTATUS;
} }
if( psz_module ) if( psz_module )
...@@ -566,52 +567,44 @@ int VLC_Destroy( int i_object ) ...@@ -566,52 +567,44 @@ int VLC_Destroy( int i_object )
p_vlc = i_object ? vlc_object_get( &libvlc, i_object ) : p_static_vlc; p_vlc = i_object ? vlc_object_get( &libvlc, i_object ) : p_static_vlc;
/* Check that the handle is valid */ if( !p_vlc )
if( !p_vlc || (p_vlc->i_status != VLC_STATUS_STOPPED
&& p_vlc->i_status != VLC_STATUS_CREATED) )
{ {
fprintf( stderr, "error: invalid status " return VLC_ENOOBJ;
"(!STOPPED&&!CREATED)\n" );
return VLC_ESTATUS;
} }
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 )
{ {
/* network_ChannelJoin( p_vlc, COMMON_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 );
/* 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 */ if( p_vlc->psz_homedir )
p_vlc->i_status = VLC_STATUS_NONE; {
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 */ /* Destroy mutexes */
vlc_mutex_destroy( &p_vlc->config_lock ); vlc_mutex_destroy( &p_vlc->config_lock );
...@@ -639,8 +632,7 @@ int VLC_Die( int i_object ) ...@@ -639,8 +632,7 @@ int VLC_Die( int i_object )
if( !p_vlc ) if( !p_vlc )
{ {
fprintf( stderr, "error: invalid status (!EXIST)\n" ); return VLC_ENOOBJ;
return VLC_ESTATUS;
} }
p_vlc->b_die = VLC_TRUE; p_vlc->b_die = VLC_TRUE;
...@@ -654,7 +646,7 @@ int VLC_Die( int i_object ) ...@@ -654,7 +646,7 @@ int VLC_Die( int i_object )
* This function adds psz_target to the current playlist. If a playlist does * This function adds psz_target to the current playlist. If a playlist does
* not exist, it will create one. * 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; int i_err;
playlist_t *p_playlist; playlist_t *p_playlist;
...@@ -662,11 +654,9 @@ int VLC_AddTarget( int i_object, const char *psz_target, int i_mode, int i_pos ) ...@@ -662,11 +654,9 @@ int VLC_AddTarget( int i_object, const char *psz_target, int i_mode, int i_pos )
p_vlc = i_object ? vlc_object_get( &libvlc, i_object ) : p_static_vlc; p_vlc = i_object ? vlc_object_get( &libvlc, i_object ) : p_static_vlc;
if( !p_vlc || ( p_vlc->i_status != VLC_STATUS_STOPPED if( !p_vlc )
&& p_vlc->i_status != VLC_STATUS_RUNNING ) )
{ {
fprintf( stderr, "error: invalid status (!STOPPED&&!RUNNING)\n" ); return VLC_ENOOBJ;
return VLC_ESTATUS;
} }
p_playlist = vlc_object_find( p_vlc, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); p_playlist = vlc_object_find( p_vlc, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
...@@ -696,7 +686,7 @@ int VLC_AddTarget( int i_object, const char *psz_target, int i_mode, int i_pos ) ...@@ -696,7 +686,7 @@ int VLC_AddTarget( int i_object, const char *psz_target, int i_mode, int i_pos )
***************************************************************************** *****************************************************************************
* *
*****************************************************************************/ *****************************************************************************/
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; vlc_t *p_vlc;
...@@ -704,8 +694,7 @@ int VLC_Set( int i_object, const char *psz_var, vlc_value_t value ) ...@@ -704,8 +694,7 @@ int VLC_Set( int i_object, const char *psz_var, vlc_value_t value )
if( !p_vlc ) if( !p_vlc )
{ {
fprintf( stderr, "error: invalid status\n" ); return VLC_ENOOBJ;
return VLC_ESTATUS;
} }
/* FIXME: Temporary hack for Mozilla, if variable starts with conf:: then /* FIXME: Temporary hack for Mozilla, if variable starts with conf:: then
...@@ -713,7 +702,7 @@ int VLC_Set( int i_object, const char *psz_var, vlc_value_t value ) ...@@ -713,7 +702,7 @@ int VLC_Set( int i_object, const char *psz_var, vlc_value_t value )
if( !strncmp( psz_var, "conf::", 6 ) ) if( !strncmp( psz_var, "conf::", 6 ) )
{ {
module_config_t *p_item; 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 ); p_item = config_FindConfig( VLC_OBJECT(p_vlc), psz_newvar );
...@@ -746,7 +735,7 @@ int VLC_Set( int i_object, const char *psz_var, vlc_value_t value ) ...@@ -746,7 +735,7 @@ int VLC_Set( int i_object, const char *psz_var, vlc_value_t value )
***************************************************************************** *****************************************************************************
* *
*****************************************************************************/ *****************************************************************************/
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; vlc_t *p_vlc;
...@@ -754,8 +743,7 @@ int VLC_Get( int i_object, const char *psz_var, vlc_value_t *p_value ) ...@@ -754,8 +743,7 @@ int VLC_Get( int i_object, const char *psz_var, vlc_value_t *p_value )
if( !p_vlc ) if( !p_vlc )
{ {
fprintf( stderr, "error: invalid status\n" ); return VLC_ENOOBJ;
return VLC_ESTATUS;
} }
return var_Get( p_vlc, psz_var, p_value ); return var_Get( p_vlc, psz_var, p_value );
...@@ -774,20 +762,16 @@ int VLC_Play( int i_object ) ...@@ -774,20 +762,16 @@ int VLC_Play( int i_object )
p_vlc = i_object ? vlc_object_get( &libvlc, i_object ) : p_static_vlc; p_vlc = i_object ? vlc_object_get( &libvlc, i_object ) : p_static_vlc;
/* Check that the handle is valid */ /* 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_ENOOBJ;
return VLC_ESTATUS;
} }
/* Update the handle status */
p_vlc->i_status = VLC_STATUS_RUNNING;
p_playlist = vlc_object_find( p_vlc, VLC_OBJECT_PLAYLIST, FIND_CHILD ); p_playlist = vlc_object_find( p_vlc, VLC_OBJECT_PLAYLIST, FIND_CHILD );
if( !p_playlist ) if( !p_playlist )
{ {
return VLC_EOBJECT; return VLC_ENOOBJ;
} }
vlc_mutex_lock( &p_playlist->object_lock ); vlc_mutex_lock( &p_playlist->object_lock );
...@@ -820,11 +804,9 @@ int VLC_Stop( int i_object ) ...@@ -820,11 +804,9 @@ int VLC_Stop( int i_object )
p_vlc = i_object ? vlc_object_get( &libvlc, i_object ) : p_static_vlc; p_vlc = i_object ? vlc_object_get( &libvlc, i_object ) : p_static_vlc;
/* Check that the handle is valid */ /* Check that the handle is valid */
if( !p_vlc || ( p_vlc->i_status != VLC_STATUS_STOPPED if( !p_vlc )
&& p_vlc->i_status != VLC_STATUS_RUNNING ) )
{ {
fprintf( stderr, "error: invalid status (!STOPPED&&!RUNNING)\n" ); return VLC_ENOOBJ;
return VLC_ESTATUS;
} }
/* /*
...@@ -873,9 +855,6 @@ int VLC_Stop( int i_object ) ...@@ -873,9 +855,6 @@ int VLC_Stop( int i_object )
aout_Delete( p_aout ); aout_Delete( p_aout );
} }
/* Update the handle status */
p_vlc->i_status = VLC_STATUS_STOPPED;
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -891,14 +870,14 @@ int VLC_Pause( int i_object ) ...@@ -891,14 +870,14 @@ int VLC_Pause( int i_object )
if( !p_vlc ) if( !p_vlc )
{ {
return VLC_ESTATUS; return VLC_ENOOBJ;
} }
p_input = vlc_object_find( p_vlc, VLC_OBJECT_INPUT, FIND_CHILD ); p_input = vlc_object_find( p_vlc, VLC_OBJECT_INPUT, FIND_CHILD );
if( !p_input ) if( !p_input )
{ {
return VLC_EOBJECT; return VLC_ENOOBJ;
} }
input_SetStatus( p_input, INPUT_STATUS_PAUSE ); input_SetStatus( p_input, INPUT_STATUS_PAUSE );
...@@ -919,14 +898,14 @@ int VLC_FullScreen( int i_object ) ...@@ -919,14 +898,14 @@ int VLC_FullScreen( int i_object )
if( !p_vlc ) if( !p_vlc )
{ {
return VLC_ESTATUS; return VLC_ENOOBJ;
} }
p_vout = vlc_object_find( p_vlc, VLC_OBJECT_VOUT, FIND_CHILD ); p_vout = vlc_object_find( p_vlc, VLC_OBJECT_VOUT, FIND_CHILD );
if( !p_vout ) if( !p_vout )
{ {
return VLC_EOBJECT; return VLC_ENOOBJ;
} }
p_vout->i_changes |= VOUT_FULLSCREEN_CHANGE; p_vout->i_changes |= VOUT_FULLSCREEN_CHANGE;
...@@ -963,7 +942,7 @@ static int GetFilenames( vlc_t *p_vlc, int i_argc, char *ppsz_argv[] ) ...@@ -963,7 +942,7 @@ static int GetFilenames( vlc_t *p_vlc, int i_argc, char *ppsz_argv[] )
***************************************************************************** *****************************************************************************
* Print a short inline help. Message interface is initialized at this stage. * 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" #define FORMAT_STRING " --%s%s%s%s%s%s%s %s%s\n"
/* option name -------------' | | | | | | /* option name -------------' | | | | | |
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* modules, especially intf modules. See config.h for output configuration. * modules, especially intf modules. See config.h for output configuration.
***************************************************************************** *****************************************************************************
* Copyright (C) 1998-2002 VideoLAN * 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> * Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org> * Samuel Hocevar <sam@zoy.org>
...@@ -469,14 +469,14 @@ static void PrintMsg ( vlc_object_t * p_this, msg_item_t * p_item ) ...@@ -469,14 +469,14 @@ static void PrintMsg ( vlc_object_t * p_this, msg_item_t * p_item )
/* Send the message to stderr */ /* Send the message to stderr */
if( p_this->p_libvlc->b_color ) 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, p_item->i_object_id, p_item->psz_module, psz_object,
ppsz_type[i_type], ppsz_color[i_type], ppsz_type[i_type], ppsz_color[i_type],
p_item->psz_msg ); p_item->psz_msg );
} }
else 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_module, psz_object, ppsz_type[i_type],
p_item->psz_msg ); p_item->psz_msg );
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* modules.c : Builtin and plugin modules management functions * modules.c : Builtin and plugin modules management functions
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * 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> * Authors: Samuel Hocevar <sam@zoy.org>
* Ethan C. Baldridge <BaldridgeE@cadmus.com> * Ethan C. Baldridge <BaldridgeE@cadmus.com>
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
# undef HAVE_DYNAMIC_PLUGINS # undef HAVE_DYNAMIC_PLUGINS
#endif #endif
#include "error.h"
#include "netutils.h" #include "netutils.h"
#include "interface.h" #include "interface.h"
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* objects.c: vlc_object_t handling * objects.c: vlc_object_t handling
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * 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> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -46,6 +46,8 @@ ...@@ -46,6 +46,8 @@
/***************************************************************************** /*****************************************************************************
* Local prototypes * Local prototypes
*****************************************************************************/ *****************************************************************************/
static int DumpCommand( vlc_object_t *, char *, char * );
static vlc_object_t * FindObject ( vlc_object_t *, int, int ); static vlc_object_t * FindObject ( vlc_object_t *, int, int );
static void DetachObject ( vlc_object_t * ); static void DetachObject ( vlc_object_t * );
static void PrintObject ( vlc_object_t *, const char * ); static void PrintObject ( vlc_object_t *, const char * );
...@@ -113,8 +115,10 @@ void * __vlc_object_create( vlc_object_t *p_this, int i_type ) ...@@ -113,8 +115,10 @@ void * __vlc_object_create( vlc_object_t *p_this, int i_type )
psz_type = "audio output"; psz_type = "audio output";
break; break;
default: default:
i_size = i_type > sizeof(vlc_object_t) i_size = i_type > 0
? i_type : sizeof(vlc_object_t); ? i_type > sizeof(vlc_object_t)
? i_type : sizeof(vlc_object_t)
: sizeof(vlc_object_t);
i_type = VLC_OBJECT_GENERIC; i_type = VLC_OBJECT_GENERIC;
psz_type = "generic"; psz_type = "generic";
break; break;
...@@ -206,6 +210,11 @@ void * __vlc_object_create( vlc_object_t *p_this, int i_type ) ...@@ -206,6 +210,11 @@ void * __vlc_object_create( vlc_object_t *p_this, int i_type )
if( i_type == VLC_OBJECT_ROOT ) if( i_type == VLC_OBJECT_ROOT )
{ {
vlc_mutex_init( p_new, &structure_lock ); 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; return p_new;
...@@ -225,14 +234,12 @@ void __vlc_object_destroy( vlc_object_t *p_this ) ...@@ -225,14 +234,12 @@ void __vlc_object_destroy( vlc_object_t *p_this )
if( p_this->i_children ) if( p_this->i_children )
{ {
msg_Err( p_this, "cannot delete object with children" ); msg_Err( p_this, "cannot delete object with children" );
vlc_dumpstructure( p_this );
return; return;
} }
if( p_this->p_parent ) if( p_this->p_parent )
{ {
msg_Err( p_this, "cannot delete object with a parent" ); msg_Err( p_this, "cannot delete object with a parent" );
vlc_dumpstructure( p_this );
return; return;
} }
...@@ -517,51 +524,63 @@ vlc_list_t * __vlc_list_find( vlc_object_t *p_this, int i_type, int i_mode ) ...@@ -517,51 +524,63 @@ vlc_list_t * __vlc_list_find( vlc_object_t *p_this, int i_type, int i_mode )
} }
/***************************************************************************** /*****************************************************************************
* vlc_liststructure: print the current vlc objects * DumpCommand: print the current vlc structure
***************************************************************************** *****************************************************************************
* This function prints alist of vlc objects, and additional information such * This function prints either an ASCII tree showing the connections between
* as their refcount, thread ID, etc. * 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 ); vlc_mutex_lock( &structure_lock );
pp_current = p_this->p_libvlc->pp_objects; if( *psz_cmd == 't' )
pp_end = pp_current + p_this->p_libvlc->i_objects;
for( ; pp_current < pp_end ; pp_current++ )
{ {
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 else
{ {
printf( " o %.6x %s (not attached)\n", p_object = p_this->p_vlc ? VLC_OBJECT(p_this->p_vlc) : p_this;
(*pp_current)->i_object_id,
(*pp_current)->psz_object_type );
} }
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;
/***************************************************************************** for( ; pp_current < pp_end ; pp_current++ )
* vlc_dumpstructure: print the current vlc structure {
***************************************************************************** if( (*pp_current)->b_attached )
* This function prints an ASCII tree showing the connections between vlc {
* objects, and additional information such as their refcount, thread ID, etc. PrintObject( *pp_current, "" );
*****************************************************************************/ }
void __vlc_dumpstructure( vlc_object_t *p_this ) else
{ {
char psz_foo[2 * MAX_DUMPSTRUCTURE_DEPTH + 1]; 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 ); vlc_mutex_unlock( &structure_lock );
return VLC_SUCCESS;
} }
/***************************************************************************** /*****************************************************************************
...@@ -775,7 +794,7 @@ static void PrintObject( vlc_object_t *p_this, const char *psz_prefix ) ...@@ -775,7 +794,7 @@ static void PrintObject( vlc_object_t *p_this, const char *psz_prefix )
psz_thread[19] = '\0'; 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, p_this->i_object_id, p_this->psz_object_type,
psz_name, psz_thread, psz_refcount, psz_children ); psz_name, psz_thread, psz_refcount, psz_children );
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* variables.c: routines for object variables handling * variables.c: routines for object variables handling
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * 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> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -46,7 +46,7 @@ static int LookupInner ( variable_t *, int, u32 ); ...@@ -46,7 +46,7 @@ static int LookupInner ( variable_t *, int, u32 );
* may require slow memory copies, but think about what we gain in the log(n) * may require slow memory copies, but think about what we gain in the log(n)
* lookup phase when setting/getting the variable value! * 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; int i_new;
...@@ -76,6 +76,8 @@ void __var_Create( vlc_object_t *p_this, const char *psz_name, int i_type ) ...@@ -76,6 +76,8 @@ void __var_Create( vlc_object_t *p_this, const char *psz_name, int i_type )
p_this->i_vars++; p_this->i_vars++;
vlc_mutex_unlock( &p_this->var_lock ); vlc_mutex_unlock( &p_this->var_lock );
return VLC_SUCCESS;
} }
/***************************************************************************** /*****************************************************************************
...@@ -84,7 +86,7 @@ void __var_Create( vlc_object_t *p_this, const char *psz_name, int i_type ) ...@@ -84,7 +86,7 @@ void __var_Create( vlc_object_t *p_this, const char *psz_name, int i_type )
* Look for the variable and destroy it if it is found. As in var_Create we * 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. * 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; int i_del;
...@@ -96,7 +98,7 @@ void __var_Destroy( vlc_object_t *p_this, const char *psz_name ) ...@@ -96,7 +98,7 @@ void __var_Destroy( vlc_object_t *p_this, const char *psz_name )
{ {
msg_Err( p_this, "variable %s was not found", psz_name ); msg_Err( p_this, "variable %s was not found", psz_name );
vlc_mutex_unlock( &p_this->var_lock ); vlc_mutex_unlock( &p_this->var_lock );
return; return VLC_ENOVAR;
} }
/* Free value if needed */ /* Free value if needed */
...@@ -128,6 +130,34 @@ void __var_Destroy( vlc_object_t *p_this, const char *psz_name ) ...@@ -128,6 +130,34 @@ void __var_Destroy( vlc_object_t *p_this, const char *psz_name )
p_this->i_vars--; p_this->i_vars--;
vlc_mutex_unlock( &p_this->var_lock ); 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;
} }
/***************************************************************************** /*****************************************************************************
...@@ -145,9 +175,8 @@ int __var_Set( vlc_object_t *p_this, const char *psz_name, vlc_value_t val ) ...@@ -145,9 +175,8 @@ int __var_Set( vlc_object_t *p_this, const char *psz_name, vlc_value_t val )
if( i_var < 0 ) if( i_var < 0 )
{ {
msg_Err( p_this, "variable %s was not found", psz_name );
vlc_mutex_unlock( &p_this->var_lock ); vlc_mutex_unlock( &p_this->var_lock );
return VLC_EVAR; return VLC_ENOVAR;
} }
/* Duplicate value if needed */ /* Duplicate value if needed */
...@@ -183,8 +212,7 @@ int __var_Set( vlc_object_t *p_this, const char *psz_name, vlc_value_t val ) ...@@ -183,8 +212,7 @@ int __var_Set( vlc_object_t *p_this, const char *psz_name, vlc_value_t val )
***************************************************************************** *****************************************************************************
* *
*****************************************************************************/ *****************************************************************************/
int __var_Get( vlc_object_t *p_this, const char *psz_name, int __var_Get( vlc_object_t *p_this, const char *psz_name, vlc_value_t *p_val )
vlc_value_t *p_value )
{ {
int i_var; int i_var;
...@@ -194,19 +222,35 @@ int __var_Get( vlc_object_t *p_this, const char *psz_name, ...@@ -194,19 +222,35 @@ int __var_Get( vlc_object_t *p_this, const char *psz_name,
if( i_var < 0 ) if( i_var < 0 )
{ {
msg_Err( p_this, "variable %s was not found", psz_name );
vlc_mutex_unlock( &p_this->var_lock ); vlc_mutex_unlock( &p_this->var_lock );
return VLC_EVAR; return VLC_ENOVAR;
} }
if( !p_this->p_vars[i_var].b_set ) 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 ); 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 */ /* Duplicate value if needed */
switch( p_this->p_vars[i_var].i_type ) switch( p_this->p_vars[i_var].i_type )
...@@ -214,9 +258,9 @@ int __var_Get( vlc_object_t *p_this, const char *psz_name, ...@@ -214,9 +258,9 @@ int __var_Get( vlc_object_t *p_this, const char *psz_name,
case VLC_VAR_STRING: case VLC_VAR_STRING:
case VLC_VAR_MODULE: case VLC_VAR_MODULE:
case VLC_VAR_FILE: 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; break;
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* vlc.c: the vlc player * vlc.c: the vlc player
***************************************************************************** *****************************************************************************
* Copyright (C) 1998-2001 VideoLAN * 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> * Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org> * Samuel Hocevar <sam@zoy.org>
...@@ -96,17 +96,6 @@ int main( int i_argc, char *ppsz_argv[] ) ...@@ -96,17 +96,6 @@ int main( int i_argc, char *ppsz_argv[] )
/* Run libvlc, in non-blocking mode */ /* Run libvlc, in non-blocking mode */
i_ret = VLC_Play( 0 ); 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 */ /* Add a blocking interface and keep the return value */
i_ret = VLC_AddIntf( 0, NULL, VLC_TRUE ); i_ret = VLC_AddIntf( 0, NULL, VLC_TRUE );
......
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