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 = \
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 );
int VLC_Create ( void );
int VLC_Init ( int, int, char *[] );
int VLC_Die ( int );
int VLC_Destroy ( int );
int VLC_Set ( int, const char *, vlc_value_t );
int VLC_Get ( int, const char *, vlc_value_t * );
int VLC_AddIntf ( int, const char *, vlc_bool_t );
int VLC_AddTarget ( int, const char *, int, int );
int VLC_Play ( int );
int VLC_Pause ( int );
int VLC_Stop ( int );
int VLC_FullScreen ( int );
char const * VLC_Version ( void );
char const * VLC_Error ( int );
int VLC_Create ( void );
int VLC_Init ( int, int, char *[] );
int VLC_Die ( int );
int VLC_Destroy ( int );
int VLC_Set ( int, char const *, vlc_value_t );
int VLC_Get ( int, char const *, vlc_value_t * );
int VLC_AddIntf ( int, char const *, vlc_bool_t );
int VLC_AddTarget ( int, char const *, int, int );
int VLC_Play ( int );
int VLC_Pause ( int );
int VLC_Stop ( int );
int VLC_FullScreen ( int );
# ifdef __cplusplus
}
......
......@@ -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" ) )
{
p_intf->p_vlc->b_die = VLC_TRUE;
}
else if( !strcmp( p_cmd, "segfault" ) )
{
raise( SIGSEGV );
}
else if( !strcmp( p_cmd, "prev" ) )
/* Skip heading spaces */
psz_cmd = p_buffer;
while( *psz_cmd == ' ' )
{
if( p_playlist ) playlist_Prev( p_playlist );
psz_cmd++;
}
else if( !strcmp( p_cmd, "next" ) )
{
if( p_playlist ) playlist_Next( p_playlist );
}
else if( !strcmp( p_cmd, "play" ) )
{
if( p_playlist ) playlist_Play( p_playlist );
}
else if( !strcmp( p_cmd, "stop" ) )
{
if( p_playlist ) playlist_Stop( p_playlist );
}
else if( !strcmp( p_cmd, "pause" ) )
{
if( p_input ) input_SetStatus( p_input, INPUT_STATUS_PAUSE );
}
else if( !strcmp( p_cmd, "tree" ) )
{
vlc_dumpstructure( p_intf->p_vlc );
}
else if( !strcmp( p_cmd, "list" ) )
/* Split psz_cmd at the first space and make sure that
* psz_arg is valid */
psz_arg = strchr( psz_cmd, ' ' );
if( psz_arg )
{
vlc_liststructure( p_intf->p_vlc );
*psz_arg++ = 0;
while( *psz_arg == ' ' )
{
psz_arg++;
}
}
else if( !strncmp( p_cmd, "setfoo ", 7 ) )
else
{
vlc_value_t value;
value.psz_string = p_cmd + 7;
var_Set( p_intf, "foo", value );
psz_arg = "";
}
else if( !strncmp( p_cmd, "getfoo", 6 ) )
/* If the user typed a registered local command, try it */
if( var_Type( p_intf, psz_cmd ) == VLC_VAR_COMMAND )
{
vlc_value_t value;
var_Get( p_intf, "foo", &value );
printf( "current value is '%s'\n", value.psz_string );
vlc_value_t val;
int i_ret;
val.psz_string = psz_arg;
i_ret = var_Get( p_intf, psz_cmd, &val );
printf( "%s: returned %i (%s)\n",
psz_cmd, i_ret, vlc_error( i_ret ) );
}
else if( !strncmp( p_cmd, "intf ", 5 ) )
/* Or maybe it's a global command */
else if( var_Type( p_intf->p_libvlc, psz_cmd ) == VLC_VAR_COMMAND )
{
intf_thread_t *p_newintf;
char *psz_oldmodule = config_GetPsz( p_intf->p_vlc, "intf" );
config_PutPsz( p_intf->p_vlc, "intf", p_cmd + 5 );
p_newintf = intf_Create( p_intf->p_vlc );
config_PutPsz( p_intf->p_vlc, "intf", psz_oldmodule );
if( psz_oldmodule )
{
free( psz_oldmodule );
}
if( p_newintf )
{
p_newintf->b_block = VLC_FALSE;
if( intf_RunThread( p_newintf ) )
{
vlc_object_detach( p_newintf );
intf_Destroy( p_newintf );
}
}
vlc_value_t val;
int i_ret;
val.psz_string = psz_arg;
/* FIXME: it's a global command, but we should pass the
* local object as an argument, not p_intf->p_libvlc. */
i_ret = var_Get( p_intf->p_libvlc, psz_cmd, &val );
printf( "%s: returned %i (%s)\n",
psz_cmd, i_ret, vlc_error( i_ret ) );
}
else if( !strcmp( p_cmd, "info" ) )
else if( !strcmp( psz_cmd, "info" ) )
{
if ( p_input )
{
......@@ -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;
}
}
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 @@
* 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
......
......@@ -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 )
{