mirror of https://code.videolan.org/videolan/vlc
* ./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.
This commit is contained in:
parent
ebda60f20b
commit
bf7985b74a
|
@ -155,6 +155,7 @@ HEADERS_include = \
|
|||
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 \
|
||||
|
@ -336,6 +337,7 @@ SOURCES_libvlc = \
|
|||
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) \
|
||||
|
|
|
@ -2129,12 +2129,14 @@ AC_ARG_ENABLE(testsuite,
|
|||
[ --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
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* 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>
|
||||
*
|
||||
|
@ -73,9 +73,6 @@ struct vlc_t
|
|||
{
|
||||
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 */
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* 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>
|
||||
*
|
||||
|
@ -30,6 +30,7 @@
|
|||
#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
|
||||
|
@ -51,9 +52,10 @@ struct variable_t
|
|||
/*****************************************************************************
|
||||
* 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 * ) );
|
||||
|
||||
|
@ -63,6 +65,9 @@ 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 )
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* 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
|
||||
|
@ -39,7 +39,7 @@ typedef union
|
|||
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;
|
||||
|
@ -49,11 +49,16 @@ typedef union
|
|||
*****************************************************************************/
|
||||
#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 */
|
||||
|
||||
|
@ -63,14 +68,6 @@ typedef union
|
|||
#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
|
||||
*****************************************************************************/
|
||||
|
@ -110,22 +107,23 @@ typedef union
|
|||
/*****************************************************************************
|
||||
* 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_Die ( int );
|
||||
int VLC_Destroy ( int );
|
||||
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_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 );
|
||||
int VLC_Play ( int );
|
||||
int VLC_Pause ( int );
|
||||
int VLC_Stop ( int );
|
||||
int VLC_FullScreen ( int );
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* 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>
|
||||
*
|
||||
|
@ -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( 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 )
|
||||
|
||||
|
@ -108,9 +105,3 @@ VLC_EXPORT( void, __vlc_dumpstructure, ( vlc_object_t * ) );
|
|||
#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) )
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* 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>
|
||||
*
|
||||
|
@ -57,6 +57,10 @@
|
|||
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
|
||||
*****************************************************************************/
|
||||
|
@ -89,7 +93,7 @@ static int Activate( vlc_object_t *p_this )
|
|||
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
|
||||
|
||||
|
@ -101,7 +105,7 @@ static int Activate( vlc_object_t *p_this )
|
|||
CONSOLE_INTRO_MSG;
|
||||
|
||||
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 )
|
|||
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;
|
||||
|
@ -124,20 +127,34 @@ static void Run( intf_thread_t *p_intf )
|
|||
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;
|
||||
|
@ -164,7 +181,7 @@ static void Run( intf_thread_t *p_intf )
|
|||
|| p_buffer[ i_size ] == '\n' )
|
||||
{
|
||||
p_buffer[ i_size ] = 0;
|
||||
b_complete = 1;
|
||||
b_complete = VLC_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -215,83 +232,58 @@ static void Run( intf_thread_t *p_intf )
|
|||
}
|
||||
|
||||
/* 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;
|
||||
while( *psz_cmd == ' ' )
|
||||
{
|
||||
p_intf->p_vlc->b_die = VLC_TRUE;
|
||||
psz_cmd++;
|
||||
}
|
||||
else if( !strcmp( p_cmd, "segfault" ) )
|
||||
{
|
||||
raise( SIGSEGV );
|
||||
}
|
||||
else if( !strcmp( p_cmd, "prev" ) )
|
||||
{
|
||||
if( p_playlist ) playlist_Prev( p_playlist );
|
||||
}
|
||||
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" ) )
|
||||
{
|
||||
vlc_liststructure( p_intf->p_vlc );
|
||||
}
|
||||
else if( !strncmp( p_cmd, "setfoo ", 7 ) )
|
||||
{
|
||||
vlc_value_t value;
|
||||
value.psz_string = p_cmd + 7;
|
||||
var_Set( p_intf, "foo", value );
|
||||
}
|
||||
else if( !strncmp( p_cmd, "getfoo", 6 ) )
|
||||
{
|
||||
vlc_value_t value;
|
||||
var_Get( p_intf, "foo", &value );
|
||||
printf( "current value is '%s'\n", value.psz_string );
|
||||
}
|
||||
else if( !strncmp( p_cmd, "intf ", 5 ) )
|
||||
{
|
||||
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 )
|
||||
/* Split psz_cmd at the first space and make sure that
|
||||
* psz_arg is valid */
|
||||
psz_arg = strchr( psz_cmd, ' ' );
|
||||
if( psz_arg )
|
||||
{
|
||||
*psz_arg++ = 0;
|
||||
while( *psz_arg == ' ' )
|
||||
{
|
||||
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 );
|
||||
}
|
||||
psz_arg++;
|
||||
}
|
||||
}
|
||||
else if( !strcmp( p_cmd, "info" ) )
|
||||
else
|
||||
{
|
||||
psz_arg = "";
|
||||
}
|
||||
|
||||
/* If the user typed a registered local command, try it */
|
||||
if( var_Type( p_intf, psz_cmd ) == VLC_VAR_COMMAND )
|
||||
{
|
||||
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 ) );
|
||||
}
|
||||
/* Or maybe it's a global command */
|
||||
else if( var_Type( p_intf->p_libvlc, psz_cmd ) == VLC_VAR_COMMAND )
|
||||
{
|
||||
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( psz_cmd, "info" ) )
|
||||
{
|
||||
if ( p_input )
|
||||
{
|
||||
|
@ -319,13 +311,13 @@ static void Run( intf_thread_t *p_intf )
|
|||
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;
|
||||
|
@ -356,15 +348,15 @@ static void Run( intf_thread_t *p_intf )
|
|||
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); */
|
||||
}
|
||||
|
@ -395,7 +387,7 @@ static void Run( intf_thread_t *p_intf )
|
|||
/* 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;
|
||||
}
|
||||
}
|
||||
|
@ -412,7 +404,95 @@ static void Run( intf_thread_t *p_intf )
|
|||
vlc_object_release( p_playlist );
|
||||
p_playlist = NULL;
|
||||
}
|
||||
|
||||
var_Destroy( p_intf, "foo" );
|
||||
}
|
||||
|
||||
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 );
|
||||
}
|
||||
|
||||
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 @@
|
|||
* 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>
|
||||
*
|
||||
|
@ -75,7 +75,7 @@ static int Open( vlc_object_t *p_this )
|
|||
if( p_intf->p_sys->p_gtk_main == NULL )
|
||||
{
|
||||
free( p_intf->p_sys );
|
||||
return VLC_EMODULE;
|
||||
return VLC_ENOMOD;
|
||||
}
|
||||
|
||||
/* Initialize Gtk+ thread */
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* 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>
|
||||
*
|
||||
|
@ -102,7 +102,7 @@ static int Open( vlc_object_t *p_this )
|
|||
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;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* 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>
|
||||
*
|
||||
|
@ -100,7 +100,7 @@ static int Open( vlc_object_t *p_this )
|
|||
if( p_intf->p_sys->p_gtk_main == NULL )
|
||||
{
|
||||
free( p_intf->p_sys );
|
||||
return VLC_EMODULE;
|
||||
return VLC_ENOMOD;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
157
src/libvlc.c
157
src/libvlc.c
|
@ -2,7 +2,7 @@
|
|||
* 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>
|
||||
|
@ -61,6 +61,7 @@
|
|||
#include "vlc_cpu.h" /* CPU detection */
|
||||
#include "os_specific.h"
|
||||
|
||||
#include "error.h"
|
||||
#include "netutils.h" /* network_ChannelJoin */
|
||||
|
||||
#include "stream_control.h"
|
||||
|
@ -86,7 +87,7 @@ static vlc_t * p_static_vlc;
|
|||
* 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 );
|
||||
|
||||
|
@ -99,11 +100,21 @@ static void ShowConsole ( 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.
|
||||
*****************************************************************************
|
||||
|
@ -182,9 +193,6 @@ int VLC_Create( void )
|
|||
/* 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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
||||
/* 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 */
|
||||
|
@ -482,9 +488,6 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] )
|
|||
return VLC_EGENERIC;
|
||||
}
|
||||
|
||||
/* Update the handle status */
|
||||
p_vlc->i_status = VLC_STATUS_STOPPED;
|
||||
|
||||
/*
|
||||
* Get input filenames given as commandline arguments
|
||||
*/
|
||||
|
@ -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
|
||||
* 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;
|
||||
|
@ -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;
|
||||
|
||||
/* 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 )
|
||||
|
@ -566,52 +567,44 @@ int VLC_Destroy( int i_object )
|
|||
|
||||
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 );
|
||||
}
|
||||
network_ChannelJoin( p_vlc, COMMON_CHANNEL );
|
||||
}
|
||||
|
||||
/*
|
||||
* Free allocated memory
|
||||
*/
|
||||
if( p_vlc->p_memcpy_module )
|
||||
{
|
||||
module_Unneed( p_vlc, p_vlc->p_memcpy_module );
|
||||
p_vlc->p_memcpy_module = NULL;
|
||||
}
|
||||
|
||||
if( p_vlc->psz_homedir )
|
||||
{
|
||||
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;
|
||||
p_vlc->psz_homedir = NULL;
|
||||
}
|
||||
|
||||
/* Update the handle status, just in case */
|
||||
p_vlc->i_status = VLC_STATUS_NONE;
|
||||
|
||||
/*
|
||||
* 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 );
|
||||
|
||||
|
@ -639,8 +632,7 @@ int VLC_Die( int i_object )
|
|||
|
||||
if( !p_vlc )
|
||||
{
|
||||
fprintf( stderr, "error: invalid status (!EXIST)\n" );
|
||||
return VLC_ESTATUS;
|
||||
return VLC_ENOOBJ;
|
||||
}
|
||||
|
||||
p_vlc->b_die = VLC_TRUE;
|
||||
|
@ -654,7 +646,7 @@ int VLC_Die( int i_object )
|
|||
* 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;
|
||||
|
@ -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;
|
||||
|
||||
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 );
|
||||
|
@ -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;
|
||||
|
||||
|
@ -704,8 +694,7 @@ int VLC_Set( int i_object, const char *psz_var, vlc_value_t value )
|
|||
|
||||
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
|
||||
|
@ -713,7 +702,7 @@ int VLC_Set( int i_object, const char *psz_var, vlc_value_t value )
|
|||
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 );
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -754,8 +743,7 @@ int VLC_Get( int i_object, const char *psz_var, vlc_value_t *p_value )
|
|||
|
||||
if( !p_vlc )
|
||||
{
|
||||
fprintf( stderr, "error: invalid status\n" );
|
||||
return VLC_ESTATUS;
|
||||
return VLC_ENOOBJ;
|
||||
}
|
||||
|
||||
return var_Get( p_vlc, psz_var, p_value );
|
||||
|
@ -774,20 +762,16 @@ int VLC_Play( int i_object )
|
|||
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 );
|
||||
|
@ -820,11 +804,9 @@ int VLC_Stop( int i_object )
|
|||
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;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -873,9 +855,6 @@ int VLC_Stop( int i_object )
|
|||
aout_Delete( p_aout );
|
||||
}
|
||||
|
||||
/* Update the handle status */
|
||||
p_vlc->i_status = VLC_STATUS_STOPPED;
|
||||
|
||||
return VLC_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -891,14 +870,14 @@ int VLC_Pause( int i_object )
|
|||
|
||||
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 );
|
||||
|
@ -919,14 +898,14 @@ int VLC_FullScreen( int i_object )
|
|||
|
||||
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;
|
||||
|
@ -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.
|
||||
*****************************************************************************/
|
||||
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 -------------' | | | | | |
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* 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>
|
||||
|
@ -469,14 +469,14 @@ static void PrintMsg ( vlc_object_t * p_this, msg_item_t * p_item )
|
|||
/* 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 );
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* 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>
|
||||
|
@ -54,7 +54,7 @@
|
|||
# undef HAVE_DYNAMIC_PLUGINS
|
||||
#endif
|
||||
|
||||
|
||||
#include "error.h"
|
||||
#include "netutils.h"
|
||||
|
||||
#include "interface.h"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* 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>
|
||||
*
|
||||
|
@ -46,6 +46,8 @@
|
|||
/*****************************************************************************
|
||||
* 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 * );
|
||||
|
@ -113,8 +115,10 @@ void * __vlc_object_create( vlc_object_t *p_this, int i_type )
|
|||
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;
|
||||
|
@ -206,6 +210,11 @@ void * __vlc_object_create( vlc_object_t *p_this, int i_type )
|
|||
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;
|
||||
|
@ -225,14 +234,12 @@ void __vlc_object_destroy( vlc_object_t *p_this )
|
|||
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;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
* 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;
|
||||
|
||||
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( (*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_unlock( &structure_lock );
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* 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];
|
||||
|
||||
vlc_mutex_lock( &structure_lock );
|
||||
psz_foo[0] = '|';
|
||||
DumpStructure( p_this, 0, psz_foo );
|
||||
vlc_mutex_unlock( &structure_lock );
|
||||
return VLC_SUCCESS;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
|
@ -775,7 +794,7 @@ static void PrintObject( vlc_object_t *p_this, const char *psz_prefix )
|
|||
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 );
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* 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>
|
||||
*
|
||||
|
@ -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)
|
||||
* 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;
|
||||
|
||||
|
@ -76,6 +76,8 @@ void __var_Create( vlc_object_t *p_this, const char *psz_name, int i_type )
|
|||
p_this->i_vars++;
|
||||
|
||||
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 )
|
|||
* 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;
|
||||
|
||||
|
@ -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 );
|
||||
vlc_mutex_unlock( &p_this->var_lock );
|
||||
return;
|
||||
return VLC_ENOVAR;
|
||||
}
|
||||
|
||||
/* Free value if needed */
|
||||
|
@ -128,6 +130,34 @@ void __var_Destroy( vlc_object_t *p_this, const char *psz_name )
|
|||
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;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
|
@ -145,9 +175,8 @@ int __var_Set( vlc_object_t *p_this, const char *psz_name, vlc_value_t val )
|
|||
|
||||
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 */
|
||||
|
@ -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,
|
||||
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;
|
||||
|
||||
|
@ -194,19 +222,35 @@ int __var_Get( vlc_object_t *p_this, const char *psz_name,
|
|||
|
||||
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;
|
||||
}
|
||||
|
||||
*p_value = p_this->p_vars[i_var].val;
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/* 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 )
|
||||
|
@ -214,9 +258,9 @@ int __var_Get( vlc_object_t *p_this, const char *psz_name,
|
|||
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;
|
||||
}
|
||||
|
|
13
src/vlc.c
13
src/vlc.c
|
@ -2,7 +2,7 @@
|
|||
* 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>
|
||||
|
@ -96,17 +96,6 @@ int main( int i_argc, char *ppsz_argv[] )
|
|||
/* 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 );
|
||||
|
||||
|
|
Loading…
Reference in New Issue