Commit 464bd2e5 authored by Sam Hocevar's avatar Sam Hocevar

Changes to the libvlc API:

  * ./include/vlc/vlc.h: changed the naming conventions for libvlc. Now
    exported functions start with VLC_ instead of vlc_ to avoid conflicts.
  * ./include/vlc/vlc.h: removed the vlc_object_t, vlc_list_t, vlc_error_t
    and vlc_t types; they are now internal types only.
  * ./include/vlc/vlc.h: merged the reentrant and non-reentrant libvlc
    calls. In non-reentrant mode, we just use 0 as the first argument. In
    reentrant mode, we use an object's ID. (see below)

Internal changes:
  * ./src/libvlc.c, ./src/misc/objects.c: instead of manipulating vlc_object_t
    pointers, we manipulate their i_object_id. When needed, an object is
    retrieved using vlc_object_get (I hope the lookup isn't too expensive,
    that's why I designed the pp_objects layout to allow log2(n) seeks).
  * ./src/misc/objects.c: activated the per-object variable storage. Unused
    yet, unless you want to try "getfoo" and "setfoo blablah" in vlc -I rc.
  * ./include/vlc_objects.h: moved the vlc_object_t and vlc_list_t definitions
    here.

Misc:
  * ./src/vlc.c, ./mozilla/vlcshell.cpp: removed inclusion of config.h in
    code portions not part of libvlc; it was just required for the
    COPYRIGHT_MESSAGE string which is now available from VLC_Version().
parent 37741cf8
......@@ -171,6 +171,7 @@ HEADERS_include = \
include/os_specific.h \
include/stream_control.h \
include/stream_output.h \
include/variables.h \
include/video.h \
include/video_output.h \
include/vlc_common.h \
......@@ -334,6 +335,7 @@ SOURCES_libvlc = \
src/misc/iso-639.def \
src/misc/messages.c \
src/misc/objects.c \
src/misc/variables.c \
src/misc/extras.c \
$(SOURCES_libvlc_win32) \
$(SOURCES_libvlc_beos) \
......
......@@ -2126,7 +2126,7 @@ then
dnl this one is needed until automake knows what to do
LDFLAGS_test3="${LDFLAGS_test3} -lobjc"
PLUGINS="${PLUGINS} ${TESTS}"
BUILTINS="${BUILTINS} ${TESTS}"
#BUILTINS="${BUILTINS} ${TESTS}"
fi
dnl
......@@ -2200,7 +2200,7 @@ dnl do not touch this line (bootstrap needs it)
dnl
dnl Stuff used by the program
dnl
AC_DEFINE_UNQUOTED(VERSION_MESSAGE, "vlc ${VERSION} ${CODENAME} Copyright 1996-2002 VideoLAN", [Simple version string])
AC_DEFINE_UNQUOTED(VERSION_MESSAGE, "${VERSION} ${CODENAME}", [Simple version string])
AC_DEFINE_UNQUOTED(COPYRIGHT_MESSAGE, "VideoLAN Client - version ${VERSION} ${CODENAME} - (c) 1996-2002 VideoLAN", [Copyright string])
AC_DEFINE_UNQUOTED(CONFIGURE_LINE, "${CONFIGURE_LINE}", [The ./configure command line])
......
......@@ -4,7 +4,7 @@
* interface, such as message output.
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: interface.h,v 1.35 2002/10/04 12:01:40 gbazin Exp $
* $Id: interface.h,v 1.36 2002/10/11 22:32:55 sam Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
*
......@@ -55,7 +55,7 @@ struct intf_thread_t
*****************************************************************************/
#define intf_Create(a) __intf_Create(VLC_OBJECT(a))
VLC_EXPORT( intf_thread_t *, __intf_Create, ( vlc_object_t * ) );
VLC_EXPORT( vlc_error_t, intf_RunThread, ( intf_thread_t * ) );
VLC_EXPORT( int, intf_RunThread, ( intf_thread_t * ) );
VLC_EXPORT( void, intf_StopThread, ( intf_thread_t * ) );
VLC_EXPORT( void, intf_Destroy, ( intf_thread_t * ) );
......@@ -68,7 +68,7 @@ VLC_EXPORT( void, intf_Destroy, ( intf_thread_t * ) );
freopen( "CONOUT$", "w", stdout ); \
freopen( "CONOUT$", "w", stderr ); \
freopen( "CONIN$", "r", stdin ); \
msg_Info( p_intf, VERSION_MESSAGE ); \
msg_Info( p_intf, COPYRIGHT_MESSAGE ); \
msg_Info( p_intf, _("\nWarning: if you can't access the GUI " \
"anymore, open a dos command box, go to the " \
"directory where you installed VLC and run " \
......
......@@ -2,7 +2,7 @@
* vlc.h: global header for vlc
*****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN
* $Id: vlc.h,v 1.14 2002/09/29 18:19:53 sam Exp $
* $Id: vlc.h,v 1.15 2002/10/11 22:32:56 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
......@@ -29,13 +29,20 @@ extern "C" {
/*****************************************************************************
* Our custom types
*****************************************************************************/
typedef struct vlc_t vlc_t;
typedef struct vlc_list_t vlc_list_t;
typedef struct vlc_object_t vlc_object_t;
typedef signed int vlc_error_t;
typedef int vlc_bool_t;
typedef int vlc_status_t;
typedef union
{
int i_int;
vlc_bool_t b_bool;
float f_float;
char * psz_string;
void * p_address;
/* Use this to make sure the structure is at least 64bits */
struct { char a, b, c, d, e, f, g, h; } padding;
} vlc_value_t;
/*****************************************************************************
* Error values
......@@ -46,6 +53,7 @@ typedef int vlc_status_t;
#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_EEXIT -255 /* Program exited */
#define VLC_EGENERIC -666 /* Generic error */
......@@ -102,40 +110,22 @@ typedef int vlc_status_t;
/*****************************************************************************
* Exported libvlc API
*****************************************************************************/
vlc_status_t vlc_status ( void );
vlc_error_t vlc_create ( void );
vlc_error_t vlc_init ( int, char *[] );
vlc_error_t vlc_die ( void );
vlc_error_t vlc_destroy ( void );
vlc_error_t vlc_set ( const char *, const char * );
vlc_error_t vlc_add_intf ( const char *, vlc_bool_t );
vlc_error_t vlc_add_target ( const char *, int, int );
vlc_error_t vlc_play ( );
vlc_error_t vlc_pause ( );
vlc_error_t vlc_stop ( void );
vlc_error_t vlc_fullscreen ( );
/*****************************************************************************
* Exported libvlc reentrant API
*****************************************************************************/
vlc_status_t vlc_status_r ( vlc_t * );
vlc_t * vlc_create_r ( void );
vlc_error_t vlc_init_r ( vlc_t *, int, char *[] );
vlc_error_t vlc_die_r ( vlc_t * );
vlc_error_t vlc_destroy_r ( vlc_t * );
vlc_error_t vlc_set_r ( vlc_t *, const char *, const char * );
vlc_error_t vlc_add_intf_r ( vlc_t *, const char *, vlc_bool_t );
vlc_error_t vlc_add_target_r ( vlc_t *, const char *, int, int );
vlc_error_t vlc_play_r ( vlc_t * );
vlc_error_t vlc_pause_r ( vlc_t * );
vlc_error_t vlc_stop_r ( vlc_t * );
vlc_error_t vlc_fullscreen_r ( vlc_t * );
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 );
# ifdef __cplusplus
}
......
......@@ -3,7 +3,7 @@
* Collection of useful common types and macros definitions
*****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN
* $Id: vlc_common.h,v 1.28 2002/10/03 13:21:54 sam Exp $
* $Id: vlc_common.h,v 1.29 2002/10/11 22:32:55 sam Exp $
*
* Authors: Samuel Hocevar <sam@via.ecp.fr>
* Vincent Seguin <seguin@via.ecp.fr>
......@@ -156,6 +156,10 @@ typedef u32 vlc_fourcc_t;
/* Internal types */
typedef struct libvlc_t libvlc_t;
typedef struct vlc_t vlc_t;
typedef struct vlc_list_t vlc_list_t;
typedef struct vlc_object_t vlc_object_t;
typedef struct variable_t variable_t;
/* Messages */
typedef struct msg_bank_t msg_bank_t;
......@@ -271,11 +275,18 @@ typedef struct iso639_lang_t iso639_lang_t;
vlc_mutex_t object_lock; \
vlc_cond_t object_wait; \
\
/* Object properties */ \
volatile vlc_bool_t b_error; /* set by the object */ \
volatile vlc_bool_t b_die; /* set by the outside */ \
volatile vlc_bool_t b_dead; /* set by the object */ \
volatile vlc_bool_t b_attached; /* set by the object */ \
\
/* Object variables */ \
vlc_mutex_t var_lock; \
int i_vars; \
variable_t * p_vars; \
\
/* Stuff related to the libvlc structure */ \
libvlc_t * p_libvlc; /* root of all evil */ \
vlc_t * p_vlc; /* (root of all evil) - 1 */ \
\
......@@ -290,23 +301,6 @@ typedef struct iso639_lang_t iso639_lang_t;
/* Just a reminder so that people don't cast garbage */ \
int be_sure_to_add_VLC_COMMON_MEMBERS_to_struct; \
/* The real vlc_object_t type. Yes, it's that simple :-) */
struct vlc_object_t
{
VLC_COMMON_MEMBERS
};
/* The object list */
struct vlc_list_t
{
int i_count;
vlc_object_t ** pp_objects;
/* Private */
int _i_extra;
vlc_object_t * _p_first;
};
/* VLC_OBJECT: attempt at doing a clever cast */
#define VLC_OBJECT( x ) \
((vlc_object_t *)(x))+0*(x)->be_sure_to_add_VLC_COMMON_MEMBERS_to_struct
......@@ -508,12 +502,13 @@ typedef __int64 off_t;
#include "vlc_symbols.h"
#include "os_specific.h"
#include "vlc_messages.h"
#include "variables.h"
#include "vlc_objects.h"
#include "vlc_threads_funcs.h"
#include "mtime.h"
#include "modules.h"
#include "main.h"
#include "configuration.h"
#include "vlc_objects.h"
#if defined( __BORLANDC__ )
# undef PACKAGE
......
......@@ -2,7 +2,7 @@
* vlc_objects.h: vlc_object_t definition.
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: vlc_objects.h,v 1.11 2002/10/03 13:21:54 sam Exp $
* $Id: vlc_objects.h,v 1.12 2002/10/11 22:32:55 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -42,6 +42,27 @@
#define FIND_STRICT 0x0010
/*****************************************************************************
* The vlc_object_t type. Yes, it's that simple :-)
*****************************************************************************/
struct vlc_object_t
{
VLC_COMMON_MEMBERS
};
/*****************************************************************************
* The vlc_list_t object list type
*****************************************************************************/
struct vlc_list_t
{
int i_count;
vlc_object_t ** pp_objects;
/* Private */
int _i_extra;
vlc_object_t * _p_first;
};
/*****************************************************************************
* Prototypes
*****************************************************************************/
......@@ -49,6 +70,7 @@ VLC_EXPORT( void *, __vlc_object_create, ( vlc_object_t *, int ) );
VLC_EXPORT( void, __vlc_object_destroy, ( vlc_object_t * ) );
VLC_EXPORT( void, __vlc_object_attach, ( vlc_object_t *, vlc_object_t * ) );
VLC_EXPORT( void, __vlc_object_detach, ( vlc_object_t * ) );
VLC_EXPORT( void *, __vlc_object_get, ( vlc_object_t *, int ) );
VLC_EXPORT( void *, __vlc_object_find, ( vlc_object_t *, int, int ) );
VLC_EXPORT( void, __vlc_object_yield, ( vlc_object_t * ) );
VLC_EXPORT( void, __vlc_object_release, ( vlc_object_t * ) );
......@@ -71,6 +93,9 @@ VLC_EXPORT( void, __vlc_dumpstructure, ( vlc_object_t * ) );
#define vlc_object_attach(a,b) \
__vlc_object_attach( VLC_OBJECT(a), VLC_OBJECT(b) )
#define vlc_object_get(a,b) \
__vlc_object_get( VLC_OBJECT(a),b)
#define vlc_object_find(a,b,c) \
__vlc_object_find( VLC_OBJECT(a),b,c)
......
......@@ -2,7 +2,7 @@
* rc.c : remote control stdin/stdout plugin for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: rc.c,v 1.7 2002/10/03 17:01:59 gbazin Exp $
* $Id: rc.c,v 1.8 2002/10/11 22:32:56 sam Exp $
*
* Authors: Peter Surda <shurdeek@panorama.sth.ac.at>
*
......@@ -69,7 +69,9 @@ static void Run ( intf_thread_t *p_intf );
vlc_module_begin();
add_category_hint( N_("Remote control"), NULL );
add_bool( "rc-show-pos", 0, NULL, POS_TEXT, POS_LONGTEXT );
#ifdef HAVE_ISATTY
add_bool( "fake-tty", 0, NULL, TTY_TEXT, TTY_LONGTEXT );
#endif
set_description( _("remote control interface module") );
set_capability( "interface", 20 );
set_callbacks( Activate, NULL );
......@@ -130,6 +132,9 @@ static void Run( intf_thread_t *p_intf )
p_input = NULL;
p_playlist = NULL;
var_Create( p_intf, "foo", VLC_VAR_STRING );
var_Set( p_intf, "foo", (vlc_value_t)"test" );
while( !p_intf->b_die )
{
b_complete = 0;
......@@ -213,7 +218,6 @@ static void Run( intf_thread_t *p_intf )
if( b_complete == 1 )
{
char *p_cmd = p_buffer;
char *p_tmp;
if( !strcmp( p_cmd, "quit" ) )
{
......@@ -251,13 +255,17 @@ static void Run( intf_thread_t *p_intf )
{
vlc_liststructure( p_intf->p_vlc );
}
else if( !strncmp( p_cmd, "set ", 4 ) )
else if( !strncmp( p_cmd, "setfoo ", 7 ) )
{
// vlc_set_r( p_intf->p_vlc, p_cmd + 4, strstr( p_cmd + 4, " " ) );
p_tmp = strstr( p_cmd + 4, " " );
p_tmp[0] = '\0';
config_PutPsz( p_intf->p_vlc, p_cmd + 4, p_tmp + 1 );
config_PutInt( p_intf->p_vlc, p_cmd + 4, atoi(p_tmp + 1) );
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 ) )
{
......@@ -391,8 +399,6 @@ static void Run( intf_thread_t *p_intf )
break;
}
}
msleep( INTF_IDLE_SLEEP );
}
if( p_input )
......@@ -406,5 +412,7 @@ static void Run( intf_thread_t *p_intf )
vlc_object_release( p_playlist );
p_playlist = NULL;
}
var_Destroy( p_intf, "foo" );
}
......@@ -2,7 +2,7 @@
* vlcpeer.cpp: scriptable peer descriptor
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: vlcpeer.cpp,v 1.2 2002/09/30 11:05:41 sam Exp $
* $Id: vlcpeer.cpp,v 1.3 2002/10/11 22:32:56 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -70,12 +70,12 @@ NS_IMETHODIMP VlcPeer::Play()
{
if( !p_plugin->b_stream && p_plugin->psz_target )
{
vlc_add_target_r( p_plugin->p_vlc, p_plugin->psz_target,
VLC_AddTarget( p_plugin->i_vlc, p_plugin->psz_target,
PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
p_plugin->b_stream = 1;
}
vlc_play_r( p_plugin->p_vlc );
VLC_Play( p_plugin->i_vlc );
}
return NS_OK;
}
......@@ -84,7 +84,7 @@ NS_IMETHODIMP VlcPeer::Pause()
{
if( p_plugin )
{
vlc_pause_r( p_plugin->p_vlc );
VLC_Pause( p_plugin->i_vlc );
}
return NS_OK;
}
......@@ -93,7 +93,7 @@ NS_IMETHODIMP VlcPeer::Stop()
{
if( p_plugin )
{
vlc_stop_r( p_plugin->p_vlc );
VLC_Stop( p_plugin->i_vlc );
p_plugin->b_stream = 0;
}
return NS_OK;
......@@ -103,7 +103,7 @@ NS_IMETHODIMP VlcPeer::Fullscreen()
{
if( p_plugin )
{
vlc_fullscreen_r( p_plugin->p_vlc );
VLC_FullScreen( p_plugin->i_vlc );
}
return NS_OK;
}
......
......@@ -2,7 +2,7 @@
* vlcplugin.h: a VideoLAN plugin for Mozilla
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: vlcplugin.h,v 1.4 2002/09/30 11:05:41 sam Exp $
* $Id: vlcplugin.h,v 1.5 2002/10/11 22:32:56 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -47,7 +47,7 @@ public:
uint32 width, height;
/* vlc data members */
vlc_t * p_vlc;
int i_vlc;
int b_stream;
int b_autoplay;
char * psz_target;
......@@ -64,7 +64,7 @@ private:
#define PLUGIN_DESCRIPTION \
"VideoLAN Client Multimedia Player Plugin <br>" \
" <br>" \
/*COPYRIGHT_MESSAGE*/ " <br>" \
"version %s <br>" \
"VideoLAN WWW: <a href=\"http://www.videolan.org/\">http://www.videolan.org/</a>"
#define PLUGIN_MIMETYPES \
......
......@@ -2,7 +2,7 @@
* vlcshell.c: a VideoLAN Client plugin for Mozilla
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: vlcshell.cpp,v 1.3 2002/10/03 18:56:09 sam Exp $
* $Id: vlcshell.cpp,v 1.4 2002/10/11 22:32:56 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -29,7 +29,6 @@
/* vlc stuff */
#include <vlc/vlc.h>
#include "config.h"
/* Mozilla stuff */
#include <npapi.h>
......@@ -88,6 +87,7 @@ char * NPP_GetMIMEDescription( void )
NPError NPP_GetValue( NPP instance, NPPVariable variable, void *value )
{
static nsIID nsid = VLCINTF_IID;
static char psz_desc[1000];
switch( variable )
{
......@@ -96,8 +96,14 @@ NPError NPP_GetValue( NPP instance, NPPVariable variable, void *value )
return NPERR_NO_ERROR;
case NPPVpluginDescriptionString:
*((char **)value) = PLUGIN_DESCRIPTION;
snprintf( psz_desc, 1000-1, PLUGIN_DESCRIPTION, VLC_Version() );
psz_desc[1000-1] = 0;
*((char **)value) = psz_desc;
return NPERR_NO_ERROR;
default:
/* go on... */
break;
}
if( instance == NULL )
......@@ -154,6 +160,7 @@ void NPP_Shutdown( void )
NPError NPP_New( NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc,
char* argn[], char* argv[], NPSavedData* saved )
{
vlc_value_t value;
int i_ret;
int i;
......@@ -185,26 +192,29 @@ NPError NPP_New( NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc,
p_plugin->fWindow = NULL;
p_plugin->window = 0;
p_plugin->p_vlc = vlc_create_r();
if( p_plugin->p_vlc == NULL )
p_plugin->i_vlc = VLC_Create();
if( p_plugin->i_vlc < 0 )
{
p_plugin->i_vlc = 0;
delete p_plugin;
p_plugin = NULL;
return NPERR_GENERIC_ERROR;
}
i_ret = vlc_init_r( p_plugin->p_vlc, sizeof(ppsz_foo)/sizeof(char*), ppsz_foo );
i_ret = VLC_Init( p_plugin->i_vlc, sizeof(ppsz_foo)/sizeof(char*), ppsz_foo );
if( i_ret )
{
vlc_destroy_r( p_plugin->p_vlc );
p_plugin->p_vlc = NULL;
VLC_Destroy( p_plugin->i_vlc );
p_plugin->i_vlc = 0;
delete p_plugin;
p_plugin = NULL;
return NPERR_GENERIC_ERROR;
}
vlc_set_r( p_plugin->p_vlc, "vout", "xvideo,x11,dummy" );
vlc_set_r( p_plugin->p_vlc, "intf", "dummy" );
value.psz_string = "xvideo,x11,dummy";
VLC_Set( p_plugin->i_vlc, "conf::vout", value );
value.psz_string = "dummy";
VLC_Set( p_plugin->i_vlc, "conf::intf", value );
p_plugin->b_stream = 0;
p_plugin->b_autoplay = 0;
......@@ -227,7 +237,8 @@ NPError NPP_New( NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc,
{
if( !strcmp( argv[i], "yes" ) )
{
vlc_set_r( p_plugin->p_vlc, "loop", "1" );
value.b_bool = VLC_TRUE;
VLC_Set( p_plugin->i_vlc, "conf::loop", value );
}
}
}
......@@ -251,11 +262,11 @@ NPError NPP_Destroy( NPP instance, NPSavedData** save )
if( p_plugin != NULL )
{
if( p_plugin->p_vlc != NULL )
if( p_plugin->i_vlc )
{
vlc_stop_r( p_plugin->p_vlc );
vlc_destroy_r( p_plugin->p_vlc );
p_plugin->p_vlc = NULL;
VLC_Stop( p_plugin->i_vlc );
VLC_Destroy( p_plugin->i_vlc );
p_plugin->i_vlc = 0;
}
if( p_plugin->psz_target )
......@@ -274,7 +285,7 @@ NPError NPP_Destroy( NPP instance, NPSavedData** save )
NPError NPP_SetWindow( NPP instance, NPWindow* window )
{
char psz_window[32];
vlc_value_t value;
if( instance == NULL )
{
......@@ -284,9 +295,8 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
VlcPlugin* p_plugin = (VlcPlugin*)instance->pdata;
/* Write the window ID for vlc */
sprintf( psz_window, "%li", (long int)window->window );
vlc_set_r( p_plugin->p_vlc, "x11-drawable", psz_window );
vlc_set_r( p_plugin->p_vlc, "xvideo-drawable", psz_window );
value.p_address = (void*)window->window;
VLC_Set( p_plugin->i_vlc, "drawable", value );
/*
* PLUGIN DEVELOPERS:
......@@ -323,7 +333,7 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
if( p_plugin->psz_target )
{
vlc_add_target_r( p_plugin->p_vlc, p_plugin->psz_target,
VLC_AddTarget( p_plugin->i_vlc, p_plugin->psz_target,
i_mode, PLAYLIST_END );
p_plugin->b_stream = 1;
}
......@@ -422,7 +432,7 @@ void NPP_StreamAsFile( NPP instance, NPStream *stream, const char* fname )
VlcPlugin* p_plugin = (VlcPlugin*)instance->pdata;
fprintf(stderr, "NPP_StreamAsFile\n");
vlc_add_target_r( p_plugin->p_vlc, fname,
VLC_AddTarget( p_plugin->i_vlc, fname,
PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
}
......
......@@ -4,7 +4,7 @@
* interface, such as command line.
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
* $Id: interface.c,v 1.99 2002/08/29 23:53:22 massiot Exp $
* $Id: interface.c,v 1.100 2002/10/11 22:32:56 sam Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
*
......@@ -78,8 +78,8 @@ intf_thread_t* __intf_Create( vlc_object_t *p_this )
}
/* Initialize structure */
p_intf->b_menu = 0;
p_intf->b_menu_change = 0;
p_intf->b_menu = VLC_FALSE;
p_intf->b_menu_change = VLC_FALSE;
/* Initialize mutexes */
vlc_mutex_init( p_intf, &p_intf->change_lock );
......@@ -98,7 +98,7 @@ intf_thread_t* __intf_Create( vlc_object_t *p_this )
* This function either creates a new thread and runs the interface in it,
* or runs the interface in the current thread, depending on b_block.
*****************************************************************************/
vlc_error_t intf_RunThread( intf_thread_t *p_intf )
int intf_RunThread( intf_thread_t *p_intf )
{
if( p_intf->b_block )
{
......@@ -112,7 +112,7 @@ vlc_error_t intf_RunThread( intf_thread_t *p_intf )
p_intf->pf_run( p_intf );
p_intf->b_die = 1;
p_intf->b_die = VLC_TRUE;
/* Do not join the thread... intf_StopThread will do it for us */
}
......@@ -140,7 +140,7 @@ void intf_StopThread( intf_thread_t *p_intf )
/* Tell the interface to die */
if( !p_intf->b_block )
{
p_intf->b_die = 1;
p_intf->b_die = VLC_TRUE;
}
/* Wait for the thread to exit */
......@@ -180,7 +180,7 @@ static void Manager( intf_thread_t *p_intf )
if( p_intf->p_vlc->b_die )
{
p_intf->b_die = 1;
p_intf->b_die = VLC_TRUE;
return;
}
}
......
......@@ -2,7 +2,7 @@
* libvlc.c: main libvlc source
*****************************************************************************
* Copyright (C) 1998-2002 VideoLAN
* $Id: libvlc.c,v 1.37 2002/10/08 18:10:09 sam Exp $
* $Id: libvlc.c,v 1.38 2002/10/11 22:32:56 sam Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
......@@ -80,9 +80,7 @@
* The evil global variable. We handle it with care, don't worry.
*****************************************************************************/
static libvlc_t libvlc;
//#define GLOBAL_VLC NULL
#define GLOBAL_VLC ((vlc_t*)libvlc.pp_children[1])
static vlc_t * p_static_vlc;
/*****************************************************************************
* Local prototypes
......@@ -97,48 +95,22 @@ static void ShowConsole ( void );
#endif
/*****************************************************************************
* vlc_create: allocate a vlc_t structure, and initialize libvlc if needed.
* VLC_Version: return the libvlc version.
*****************************************************************************
* This function allocates a vlc_t structure and returns NULL in case of
* failure. Also, the thread system is initialized.
* This function returns full version string (numeric version and codename).
*****************************************************************************/
vlc_error_t vlc_create( void )
char * VLC_Version( void )
{
vlc_t * p_vlc;
vlc_bool_t b_failed = VLC_FALSE;
/* This call should be thread-safe, but an additional check will be
* necessary afterwards to check that only one p_vlc is created. */
p_vlc = vlc_create_r();
if( p_vlc == NULL )
{
return VLC_EGENERIC;
}
/* We have created an object, which ensures us that p_global_lock has
* been properly initialized. We can now atomically check that we are
* the only p_vlc object. */
#if 0
vlc_mutex_lock( libvlc.p_global_lock );
if( libvlc.i_children != 1 ) /* FIXME !!! FIXME */
{
b_failed = VLC_TRUE;
}
vlc_mutex_unlock( libvlc.p_global_lock );
#endif
/* There can be only one */
if( b_failed )
{
vlc_destroy_r( p_vlc );
return VLC_EGENERIC;
}
return VLC_SUCCESS;
return VERSION_MESSAGE;
}
vlc_t * vlc_create_r( void )
/*****************************************************************************
* VLC_Create: allocate a vlc_t structure, and initialize libvlc if needed.
*****************************************************************************
* This function allocates a vlc_t structure and returns a negative value
* in case of failure. Also, the thread system is initialized.
*****************************************************************************/
int VLC_Create( void )
{
int i_ret;
vlc_t * p_vlc = NULL;
......@@ -147,9 +119,9 @@ vlc_t * vlc_create_r( void )
/* vlc_threads_init *must* be the first internal call! No other call is
* allowed before the thread system has been initialized. */
i_ret = vlc_threads_init( &libvlc );
if( i_ret )
if( i_ret < 0 )
{
return NULL;
return i_ret;
}
/* Now that the thread system is initialized, we don't have much, but
......@@ -196,7 +168,7 @@ vlc_t * vlc_create_r( void )
p_vlc = vlc_object_create( &libvlc, VLC_OBJECT_VLC );
if( p_vlc == NULL )
{
return NULL;
return VLC_EGENERIC;
}
p_vlc->psz_object_name = "root";
......@@ -207,14 +179,17 @@ vlc_t * vlc_create_r( void )
/* Store our newly allocated structure in the global list */
vlc_object_attach( p_vlc, &libvlc );
/* 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;
return p_vlc->i_object_id;
}
/*****************************************************************************
* vlc_init: initialize a vlc_t structure.
* VLC_Init: initialize a vlc_t structure.
*****************************************************************************
* This function initializes a previously allocated vlc_t structure:
* - CPU detection
......@@ -222,19 +197,17 @@ vlc_t * vlc_create_r( void )
* - message queue, module bank and playlist initialization
* - configuration and commandline parsing
*****************************************************************************/
vlc_error_t vlc_init( int i_argc, char *ppsz_argv[] )
{
return vlc_init_r( GLOBAL_VLC, i_argc, ppsz_argv );
}
vlc_error_t vlc_init_r( vlc_t *p_vlc, int i_argc, char *ppsz_argv[] )
int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] )
{
char p_capabilities[200];
char * p_tmp;
vlc_bool_t b_exit;
vlc_t * p_vlc;
module_t *p_help_module;
playlist_t *p_playlist;
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 )
{
......@@ -521,26 +494,22 @@ vlc_error_t vlc_init_r( vlc_t *p_vlc, int i_argc, char *ppsz_argv[] )
}
/*****************************************************************************
* vlc_add_intf: add an interface
* VLC_AddIntf: add an interface
*****************************************************************************
* This function opens an interface plugin and runs it. If b_block is set
* to 0, vlc_add_intf will return immediately and let the interface run in a
* separate thread. If b_block is set to 1, vlc_add_intf will continue until
* to 0, VLC_AddIntf will return immediately and let the interface run in a
* separate thread. If b_block is set to 1, VLC_AddIntf will continue until
* user requests to quit.
*****************************************************************************/
vlc_error_t vlc_add_intf( const char *psz_module, vlc_bool_t b_block )
{
return vlc_add_intf_r( GLOBAL_VLC,
psz_module, b_block );
}
vlc_error_t vlc_add_intf_r( vlc_t *p_vlc, const char *psz_module,
vlc_bool_t b_block )
int VLC_AddIntf( int i_object, const char *psz_module, vlc_bool_t b_block )
{
vlc_error_t err;
int i_err;
intf_thread_t *p_intf;
vlc_t *p_vlc;
char *psz_oldmodule = NULL;
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 )
{
......@@ -574,30 +543,29 @@ vlc_error_t vlc_add_intf_r( vlc_t *p_vlc, const char *psz_module,
/* Try to run the interface */
p_intf->b_block = b_block;
err = intf_RunThread( p_intf );
if( err )
i_err = intf_RunThread( p_intf );
if( i_err )
{
vlc_object_detach( p_intf );
intf_Destroy( p_intf );
return err;
return i_err;
}
return VLC_SUCCESS;
}
/*****************************************************************************
* vlc_destroy: stop playing and destroy everything.
* VLC_Destroy: stop playing and destroy everything.
*****************************************************************************
* This function requests the running threads to finish, waits for their
* termination, and destroys their structure.
*****************************************************************************/
vlc_error_t vlc_destroy( void )
int VLC_Destroy( int i_object )
{
return vlc_destroy_r( GLOBAL_VLC );
}
vlc_t *p_vlc;
p_vlc = i_object ? vlc_object_get( &libvlc, i_object ) : p_static_vlc;
vlc_error_t vlc_destroy_r( vlc_t *p_vlc )
{
/* Check that the handle is valid */
if( !p_vlc || (p_vlc->i_status != VLC_STATUS_STOPPED
&& p_vlc->i_status != VLC_STATUS_CREATED) )
......@@ -658,18 +626,17 @@ vlc_error_t vlc_destroy_r( vlc_t *p_vlc )
}
/*****************************************************************************
* vlc_die: ask vlc to die.
* VLC_Die: ask vlc to die.
*****************************************************************************
* This function sets p_vlc->b_die to VLC_TRUE, but does not do any other
* task. It is your duty to call vlc_end and vlc_destroy afterwards.
* task. It is your duty to call vlc_end and VLC_Destroy afterwards.
*****************************************************************************/
vlc_error_t vlc_die( void )
int VLC_Die( int i_object )
{
return vlc_die_r( GLOBAL_VLC );
}
vlc_t *p_vlc;
p_vlc = i_object ? vlc_object_get( &libvlc, i_object ) : p_static_vlc;
vlc_error_t vlc_die_r( vlc_t *p_vlc )
{
if( !p_vlc )
{
fprintf( stderr, "error: invalid status (!EXIST)\n" );
......@@ -682,42 +649,18 @@ vlc_error_t vlc_die_r( vlc_t *p_vlc )
}
/*****************************************************************************
* vlc_status: return the current vlc status.
*****************************************************************************
* This function returns the current value of p_vlc->i_status.
*****************************************************************************/
vlc_status_t vlc_status( void )
{
return vlc_status_r( GLOBAL_VLC );
}
vlc_status_t vlc_status_r( vlc_t *p_vlc )
{
if( !p_vlc )
{
return VLC_STATUS_NONE;
}
return p_vlc->i_status;
}
/*****************************************************************************
* vlc_add_target: adds a target for playing.
* VLC_AddTarget: adds a target for playing.
*****************************************************************************
* This function adds psz_target to the current playlist. If a playlist does
* not exist, it will create one.
*****************************************************************************/
vlc_error_t vlc_add_target( const char *psz_target, int i_mode, int i_pos )
int VLC_AddTarget( int i_object, const char *psz_target, int i_mode, int i_pos )
{
return vlc_add_target_r( GLOBAL_VLC,
psz_target, i_mode, i_pos );
}
vlc_error_t vlc_add_target_r( vlc_t *p_vlc, const char *psz_target,
int i_mode, int i_pos )
{
vlc_error_t err;
int i_err;
playlist_t *p_playlist;
vlc_t *p_vlc;
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 ) )
......@@ -741,26 +684,23 @@ vlc_error_t vlc_add_target_r( vlc_t *p_vlc, const char *psz_target,
vlc_object_yield( p_playlist );
}
err = playlist_Add( p_playlist, psz_target, i_mode, i_pos );
i_err = playlist_Add( p_playlist, psz_target, i_mode, i_pos );
vlc_object_release( p_playlist );
return err;
return i_err;
}
/*****************************************************************************
* vlc_set: set a vlc variable
* VLC_Set: set a vlc variable
*****************************************************************************
*
*****************************************************************************/
vlc_error_t vlc_set( const char *psz_var, const char *psz_val )
int VLC_Set( int i_object, const char *psz_var, vlc_value_t value )
{
return vlc_set_r( GLOBAL_VLC, psz_var, psz_val );
}
vlc_t *p_vlc;
vlc_error_t vlc_set_r( vlc_t *p_vlc, const char *psz_var, const char *psz_val )
{
module_config_t *p_config;
p_vlc = i_object ? vlc_object_get( &libvlc, i_object ) : p_static_vlc;
if( !p_vlc )
{
......@@ -768,101 +708,70 @@ vlc_error_t vlc_set_r( vlc_t *p_vlc, const char *psz_var, const char *psz_val )
return VLC_ESTATUS;
}
p_config = config_FindConfig( VLC_OBJECT(p_vlc), psz_var );
if( !p_config )
/* FIXME: Temporary hack for Mozilla, if variable starts with conf:: then
* we handle it as a configuration variable. Don't tell Gildas :) -- sam */
if( !strncmp( psz_var, "conf::", 6 ) )
{
msg_Err( p_vlc, "option %s does not exist", psz_var );
return VLC_EGENERIC;
}
module_config_t *p_item;
const char *psz_newvar = psz_var + 6;
vlc_mutex_lock( p_config->p_lock );
p_item = config_FindConfig( VLC_OBJECT(p_vlc), psz_newvar );
switch( p_config->i_type )
{
case CONFIG_ITEM_BOOL:
if( psz_val && *psz_val )
{
if( !strcmp( psz_val, "off" ) || !strcmp( psz_val, "no" ) )
if( p_item )
{
p_config->i_value = VLC_FALSE;
}
else
{
p_config->i_value = atoi( psz_val );
}
}
else
switch( p_item->i_type )
{
p_config->i_value = VLC_TRUE;
}
case CONFIG_ITEM_BOOL:
config_PutInt( p_vlc, psz_newvar, value.b_bool );
break;
case CONFIG_ITEM_INTEGER:
if( psz_val && *psz_val )
{
p_config->i_value = atoi( psz_val );
}
else
{
p_config->i_value = 0;
}
config_PutInt( p_vlc, psz_newvar, value.i_int );
break;
case CONFIG_ITEM_FLOAT:
if( psz_val && *psz_val )
{
p_config->f_value = (float)atof( psz_val );
}
else
{
p_config->f_value = 0.0;
}
config_PutFloat( p_vlc, psz_newvar, value.f_float );
break;
case CONFIG_ITEM_STRING:
case CONFIG_ITEM_FILE:
case CONFIG_ITEM_MODULE:
default:
if( p_config->psz_value )
{
free( p_config->psz_value );
}
if( psz_val )
{
p_config->psz_value = strdup( psz_val );
}
else
{
p_config->psz_value = NULL;
}
config_PutPsz( p_vlc, psz_newvar, value.psz_string );
break;
}
if( p_config->pf_callback )
{
vlc_mutex_unlock( p_config->p_lock );
p_config->pf_callback( VLC_OBJECT(p_vlc) );
return VLC_SUCCESS;
}
else
{
vlc_mutex_unlock( p_config->p_lock );
}
return VLC_SUCCESS;
return var_Set( p_vlc, psz_var, value );
}
/* XXX: temporary hacks */
/*****************************************************************************
* vlc_play: play
* VLC_Get: get a vlc variable
*****************************************************************************
*
*****************************************************************************/
vlc_error_t vlc_play( )
int VLC_Get( int i_object, const char *psz_var, vlc_value_t *p_value )
{
return vlc_play_r( GLOBAL_VLC );
vlc_t *p_vlc;
p_vlc = i_object ? vlc_object_get( &libvlc, i_object ) : p_static_vlc;
if( !p_vlc )
{
fprintf( stderr, "error: invalid status\n" );
return VLC_ESTATUS;
}
return var_Get( p_vlc, psz_var, p_value );
}
vlc_error_t vlc_play_r( vlc_t *p_vlc )
/* FIXME: temporary hacks */
/*****************************************************************************
* VLC_Play: play
*****************************************************************************/
int VLC_Play( int i_object )
{
playlist_t * p_playlist;
vlc_t *p_vlc;
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 )
......@@ -898,19 +807,17 @@ vlc_error_t vlc_play_r( vlc_t *p_vlc )
}
/*****************************************************************************
* vlc_stop: stop
* VLC_Stop: stop
*****************************************************************************/
vlc_error_t vlc_stop( )
{
return vlc_stop_r( GLOBAL_VLC );
}
vlc_error_t vlc_stop_r( vlc_t *p_vlc )
int VLC_Stop( int i_object )
{
intf_thread_t * p_intf;
playlist_t * p_playlist;
vout_thread_t * p_vout;
aout_instance_t * p_aout;
vlc_t *p_vlc;
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
......@@ -973,16 +880,19 @@ vlc_error_t vlc_stop_r( vlc_t *p_vlc )
}
/*****************************************************************************
* vlc_pause: toggle pause
* VLC_Pause: toggle pause
*****************************************************************************/
vlc_error_t vlc_pause( )
{
return vlc_pause_r( GLOBAL_VLC );
}
vlc_error_t vlc_pause_r( vlc_t *p_vlc )
int VLC_Pause( int i_object )
{
input_thread_t *p_input;
vlc_t *p_vlc;
p_vlc = i_object ? vlc_object_get( &libvlc, i_object ) : p_static_vlc;
if( !p_vlc )
{
return VLC_ESTATUS;
}
p_input = vlc_object_find( p_vlc, VLC_OBJECT_INPUT, FIND_CHILD );
......@@ -998,16 +908,19 @@ vlc_error_t vlc_pause_r( vlc_t *p_vlc )
}
/*****************************************************************************
* vlc_fullscreen: toggle fullscreen mode
* VLC_FullScreen: toggle fullscreen mode
*****************************************************************************/
vlc_error_t vlc_fullscreen( )
{
return vlc_fullscreen_r( GLOBAL_VLC );
}
vlc_error_t vlc_fullscreen_r( vlc_t *p_vlc )
int VLC_FullScreen( int i_object )
{
vout_thread_t *p_vout;
vlc_t *p_vlc;
p_vlc = i_object ? vlc_object_get( &libvlc, i_object ) : p_static_vlc;
if( !p_vlc )
{
return VLC_ESTATUS;
}
p_vout = vlc_object_find( p_vlc, VLC_OBJECT_VOUT, FIND_CHILD );
......@@ -1036,7 +949,9 @@ static int GetFilenames( vlc_t *p_vlc, int i_argc, char *ppsz_argv[] )
/* We assume that the remaining parameters are filenames */
for( i_opt = optind; i_opt < i_argc; i_opt++ )
{
vlc_add_target_r( p_vlc, ppsz_argv[ i_opt ],
/* TODO: write an internal function of this one, to avoid
* unnecessary lookups. */
VLC_AddTarget( p_vlc->i_object_id, ppsz_argv[ i_opt ],
PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
}
......
......@@ -2,7 +2,7 @@
* objects.c: vlc_object_t handling
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: objects.c,v 1.23 2002/10/04 18:07:22 sam Exp $
* $Id: objects.c,v 1.24 2002/10/11 22:32:56 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -141,12 +141,20 @@ void * __vlc_object_create( vlc_object_t *p_this, int i_type )
p_new->psz_object_name = NULL;
p_new->i_refcount = 0;
p_new->b_die = VLC_FALSE;
p_new->b_error = VLC_FALSE;
p_new->b_dead = VLC_FALSE;
p_new->b_attached = VLC_FALSE;
p_new->i_vars = 0;
p_new->p_vars = (variable_t *)malloc( 16 * sizeof( variable_t ) );
if( !p_new->p_vars )
{
free( p_new );
return NULL;
}
if( i_type == VLC_OBJECT_ROOT )
{
/* If i_type is root, then p_new is actually p_libvlc */
......@@ -183,6 +191,7 @@ void * __vlc_object_create( vlc_object_t *p_this, int i_type )
vlc_mutex_unlock( &structure_lock );
}
p_new->i_refcount = 0;
p_new->p_parent = NULL;
p_new->pp_children = NULL;
p_new->i_children = 0;
......@@ -192,6 +201,7 @@ void * __vlc_object_create( vlc_object_t *p_this, int i_type )
/* Initialize mutexes and condvars */
vlc_mutex_init( p_new, &p_new->object_lock );
vlc_cond_init( p_new, &p_new->object_wait );
vlc_mutex_init( p_new, &p_new->var_lock );
if( i_type == VLC_OBJECT_ROOT )
{
......@@ -250,6 +260,16 @@ void __vlc_object_destroy( vlc_object_t *p_this )
msleep( 100000 );
}
/* Destroy the associated variables, starting from the end so that
* no memmove calls have to be done. */
while( p_this->i_vars )
{
var_Destroy( p_this, p_this->p_vars[p_this->i_vars - 1].psz_name );
}
free( p_this->p_vars );
vlc_mutex_destroy( &p_this->var_lock );
if( p_this->i_object_type == VLC_OBJECT_ROOT )
{
/* We are the root object ... no need to lock. */
......@@ -288,6 +308,66 @@ void __vlc_object_destroy( vlc_object_t *p_this )
free( p_this );
}
/*****************************************************************************
* vlc_object_get: find an object given its ID
*****************************************************************************
* This function looks for the object whose i_object_id field is i_id. We
* use a dichotomy so that lookups are in log2(n).
*****************************************************************************/
void * __vlc_object_get( vlc_object_t *p_this, int i_id )
{
int i_max, i_middle;
vlc_object_t **pp_objects;
vlc_mutex_lock( &structure_lock );
pp_objects = p_this->p_libvlc->pp_objects;
/* Perform our dichotomy */
for( i_max = p_this->p_libvlc->i_objects - 1 ; ; )
{
i_middle = i_max / 2;
if( pp_objects[i_middle]->i_object_id > i_id )
{
i_max = i_middle;
}
else if( pp_objects[i_middle]->i_object_id < i_id )
{
if( i_middle )
{
pp_objects += i_middle;
i_max -= i_middle;
}
else
{
/* This happens when there are only two remaining objects */
if( pp_objects[i_middle+1]->i_object_id == i_id )
{
vlc_mutex_unlock( &structure_lock );
return pp_objects[i_middle+1];
}
break;
}
}
else
{
vlc_mutex_unlock( &structure_lock );
return pp_objects[i_middle];
}
if( i_max == 0 )
{
/* this means that i_max == i_middle, and since we have already
* tested pp_objects[i_middle]), p_found is properly set. */
break;
}
}
vlc_mutex_unlock( &structure_lock );
return NULL;
}
/*****************************************************************************
* vlc_object_find: find a typed object and increment its refcount
*****************************************************************************
......
......@@ -2,7 +2,7 @@
* vlc.c: the vlc player
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
* $Id: vlc.c,v 1.13 2002/10/08 18:10:09 sam Exp $
* $Id: vlc.c,v 1.14 2002/10/11 22:32:56 sam Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
......@@ -32,8 +32,6 @@
#include <vlc/vlc.h>
#include "config.h"
/*****************************************************************************
* Local prototypes.
*****************************************************************************/
......@@ -46,9 +44,9 @@ static void SigHandler ( int i_signal );
*****************************************************************************/
int main( int i_argc, char *ppsz_argv[] )
{
vlc_error_t err;
int i_ret;
fprintf( stderr, COPYRIGHT_MESSAGE "\n" );
fprintf( stderr, "VideoLAN Client %s\n", VLC_Version() );
#ifdef HAVE_PUTENV
# ifdef DEBUG
......@@ -67,10 +65,10 @@ int main( int i_argc, char *ppsz_argv[] )
#endif
/* Create a libvlc structure */
err = vlc_create();
if( err != VLC_SUCCESS )
i_ret = VLC_Create();
if( i_ret < 0 )
{
return err;
return i_ret;
}
#ifndef WIN32
......@@ -88,37 +86,37 @@ int main( int i_argc, char *ppsz_argv[] )
#endif
/* Initialize libvlc */
err = vlc_init( i_argc, ppsz_argv );
if( err != VLC_SUCCESS )
i_ret = VLC_Init( 0, i_argc, ppsz_argv );
if( i_ret < 0 )
{
vlc_destroy();
return err;
VLC_Destroy( 0 );
return i_ret;
}
/* Run libvlc, in non-blocking mode */
err = vlc_play();
i_ret = VLC_Play( 0 );
/* Add background interfaces */
#if 0
{ int i; for( i=10; i--; ) vlc_add_intf( NULL, "dummy", 0 ); }
vlc_add_intf( NULL, "dummy", VLC_FALSE );
vlc_add_intf( NULL, "logger", VLC_FALSE );
vlc_add_intf( NULL, "xosd", VLC_FALSE );
vlc_add_intf( NULL, "gtk", VLC_FALSE );
vlc_add_intf( NULL, "kde", VLC_FALSE );
vlc_add_intf( "rc", VLC_FALSE );
{ 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 */
err = vlc_add_intf( NULL, VLC_TRUE );
i_ret = VLC_AddIntf( 0, NULL, VLC_TRUE );
/* Finish the threads */
vlc_stop();
VLC_Stop( 0 );
/* Destroy the libvlc structure */
vlc_destroy();
VLC_Destroy( 0 );
return err;
return i_ret;
}
#ifndef WIN32
......@@ -146,7 +144,7 @@ static void SigHandler( int i_signal )
"again in case it gets stuck\n", i_signal );
/* Acknowledge the signal received */
vlc_die();
VLC_Die( 0 );
}
else if( time( NULL ) > abort_time + 2 )
{
......
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