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) )
This diff is collapsed.
...@@ -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
......
This diff is collapsed.
...@@ -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