Commit 89987e11 authored by Sam Hocevar's avatar Sam Hocevar

* ./configure.ac.in: removed now unnecessary --force-exe-suffix flag.

  * ./src/misc/objects.c: structure_lock is now local.
  * ./src/misc/threads.c: implemented named mutexes which provide a handy
    way to protect data across plugins which might be sharing the same
    resources. Thread-unsafe libraries come to mind, but we can imagine
    using a named mutex for configuration files, or special devices.
  * ./include/main.h: removed global_lock because of vlc_mutex_need, removed
    p_global_data because it was never used, removed structure_lock because
    it did not belong here.
parent 656bdcea
...@@ -99,7 +99,7 @@ case "x${target_os}" in ...@@ -99,7 +99,7 @@ case "x${target_os}" in
SYS=mingw32 SYS=mingw32
AC_CHECK_TOOL(WINDRES, windres, :) AC_CHECK_TOOL(WINDRES, windres, :)
CPPFLAGS_save="${CPPFLAGS_save} -D_OFF_T_ -D_off_t=long"; CPPFLAGS="${CPPFLAGS_save}" CPPFLAGS_save="${CPPFLAGS_save} -D_OFF_T_ -D_off_t=long"; CPPFLAGS="${CPPFLAGS_save}"
LDFLAGS_vlc="${LDFLAGS_vlc} -lws2_32 -lnetapi32 -mwindows -Xlinker --force-exe-suffix" LDFLAGS_vlc="${LDFLAGS_vlc} -lws2_32 -lnetapi32 -mwindows"
LDFLAGS_ipv4="${LDFLAGS_ipv4} -lws2_32" LDFLAGS_ipv4="${LDFLAGS_ipv4} -lws2_32"
LDFLAGS_ipv6="${LDFLAGS_ipv6} -lws2_32" LDFLAGS_ipv6="${LDFLAGS_ipv6} -lws2_32"
LDFLAGS_access_http="${LDFLAGS_http} -lws2_32" LDFLAGS_access_http="${LDFLAGS_http} -lws2_32"
......
...@@ -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.47 2002/10/03 18:56:09 sam Exp $ * $Id: main.h,v 1.48 2002/10/04 18:07:21 sam Exp $
* *
* Authors: Vincent Seguin <seguin@via.ecp.fr> * Authors: Vincent Seguin <seguin@via.ecp.fr>
* *
...@@ -48,13 +48,6 @@ struct libvlc_t ...@@ -48,13 +48,6 @@ struct libvlc_t
int i_objects; /* Attached objects count */ int i_objects; /* Attached objects count */
vlc_object_t ** pp_objects; /* Array of all objects */ vlc_object_t ** pp_objects; /* Array of all objects */
/* The big, evil global lock */
vlc_mutex_t global_lock;
void * p_global_data;
/* Locks */
vlc_mutex_t structure_lock; /* lock for the p_vlc tree */
/* The message bank */ /* The message bank */
msg_bank_t msg_bank; msg_bank_t msg_bank;
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* This header provides a portable threads implementation. * This header provides a portable threads implementation.
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2002 VideoLAN * Copyright (C) 1999, 2002 VideoLAN
* $Id: vlc_threads_funcs.h,v 1.4 2002/10/03 17:01:59 gbazin Exp $ * $Id: vlc_threads_funcs.h,v 1.5 2002/10/04 18:07:21 sam Exp $
* *
* Authors: Jean-Marc Dressler <polux@via.ecp.fr> * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
* Samuel Hocevar <sam@via.ecp.fr> * Samuel Hocevar <sam@via.ecp.fr>
...@@ -38,6 +38,9 @@ VLC_EXPORT( int, __vlc_thread_create, ( vlc_object_t *, char *, int, char *, vo ...@@ -38,6 +38,9 @@ VLC_EXPORT( int, __vlc_thread_create, ( vlc_object_t *, char *, int, char *, vo
VLC_EXPORT( void, __vlc_thread_ready, ( vlc_object_t * ) ); VLC_EXPORT( void, __vlc_thread_ready, ( vlc_object_t * ) );
VLC_EXPORT( void, __vlc_thread_join, ( vlc_object_t *, char *, int ) ); VLC_EXPORT( void, __vlc_thread_join, ( vlc_object_t *, char *, int ) );
VLC_EXPORT( vlc_mutex_t *, __vlc_mutex_need, ( vlc_object_t *, char * ) );
VLC_EXPORT( void , __vlc_mutex_unneed, ( vlc_object_t *, char * ) );
/***************************************************************************** /*****************************************************************************
* vlc_threads_init: initialize threads system * vlc_threads_init: initialize threads system
*****************************************************************************/ *****************************************************************************/
...@@ -56,6 +59,12 @@ VLC_EXPORT( void, __vlc_thread_join, ( vlc_object_t *, char *, int ) ); ...@@ -56,6 +59,12 @@ VLC_EXPORT( void, __vlc_thread_join, ( vlc_object_t *, char *, int ) );
#define vlc_mutex_init( P_THIS, P_MUTEX ) \ #define vlc_mutex_init( P_THIS, P_MUTEX ) \
__vlc_mutex_init( VLC_OBJECT(P_THIS), P_MUTEX ) __vlc_mutex_init( VLC_OBJECT(P_THIS), P_MUTEX )
/*****************************************************************************
* vlc_mutex_need: create a global mutex from its name
*****************************************************************************/
#define vlc_mutex_need( P_THIS, P_NAME ) \
__vlc_mutex_need( VLC_OBJECT(P_THIS), P_NAME )
/***************************************************************************** /*****************************************************************************
* vlc_mutex_lock: lock a mutex * vlc_mutex_lock: lock a mutex
*****************************************************************************/ *****************************************************************************/
...@@ -192,6 +201,12 @@ static inline int __vlc_mutex_unlock( char * psz_file, int i_line, ...@@ -192,6 +201,12 @@ static inline int __vlc_mutex_unlock( char * psz_file, int i_line,
return i_result; return i_result;
} }
/*****************************************************************************
* vlc_mutex_unneed: destroycreate a global mutex from its name
*****************************************************************************/
#define vlc_mutex_unneed( P_THIS, P_NAME ) \
__vlc_mutex_unneed( VLC_OBJECT(P_THIS), P_NAME )
/***************************************************************************** /*****************************************************************************
* vlc_mutex_destroy: destroy a mutex * vlc_mutex_destroy: destroy a mutex
*****************************************************************************/ *****************************************************************************/
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* vcd.c : VCD input module for vlc * vcd.c : VCD input module for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2000 VideoLAN * Copyright (C) 2000 VideoLAN
* $Id: vcd.c,v 1.5 2002/08/29 23:53:22 massiot Exp $ * $Id: vcd.c,v 1.6 2002/10/04 18:07:21 sam Exp $
* *
* Author: Johan Bilien <jobi@via.ecp.fr> * Author: Johan Bilien <jobi@via.ecp.fr>
* *
...@@ -181,7 +181,7 @@ static int VCDOpen( vlc_object_t *p_this ) ...@@ -181,7 +181,7 @@ static int VCDOpen( vlc_object_t *p_this )
if( p_vcd->i_handle == -1 ) if( p_vcd->i_handle == -1 )
{ {
msg_Err( p_input, "could not open %s\n", psz_source ); msg_Err( p_input, "could not open %s", psz_source );
free (p_vcd); free (p_vcd);
return -1; return -1;
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* arts.c : aRts module * arts.c : aRts module
***************************************************************************** *****************************************************************************
* Copyright (C) 2001-2002 VideoLAN * Copyright (C) 2001-2002 VideoLAN
* $Id: arts.c,v 1.12 2002/09/30 11:05:35 sam Exp $ * $Id: arts.c,v 1.13 2002/10/04 18:07:21 sam Exp $
* *
* Authors: Emmanuel Blindauer <manu@agat.net> * Authors: Emmanuel Blindauer <manu@agat.net>
* Samuel Hocevar <sam@zoy.org> * Samuel Hocevar <sam@zoy.org>
...@@ -123,7 +123,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -123,7 +123,7 @@ static int Open( vlc_object_t *p_this )
* (mtime_t)arts_stream_get( p_sys->stream, ARTS_P_SERVER_LATENCY ); * (mtime_t)arts_stream_get( p_sys->stream, ARTS_P_SERVER_LATENCY );
p_sys->i_size = arts_stream_get( p_sys->stream, ARTS_P_PACKET_SIZE ); p_sys->i_size = arts_stream_get( p_sys->stream, ARTS_P_PACKET_SIZE );
msg_Dbg( p_aout, "aRts initialized, latency %i000, %i packets of size %i\n", msg_Dbg( p_aout, "aRts initialized, latency %i000, %i packets of size %i",
arts_stream_get( p_sys->stream, ARTS_P_SERVER_LATENCY ), arts_stream_get( p_sys->stream, ARTS_P_SERVER_LATENCY ),
arts_stream_get( p_sys->stream, ARTS_P_PACKET_COUNT ), arts_stream_get( p_sys->stream, ARTS_P_PACKET_COUNT ),
arts_stream_get( p_sys->stream, ARTS_P_PACKET_SIZE ) ); arts_stream_get( p_sys->stream, ARTS_P_PACKET_SIZE ) );
......
...@@ -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.4 2002/10/04 12:01:40 gbazin Exp $ * $Id: gtk.c,v 1.5 2002/10/04 18:07:21 sam Exp $
* *
* Authors: Samuel Hocevar <sam@zoy.org> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -171,11 +171,7 @@ static void Run( intf_thread_t *p_intf ) ...@@ -171,11 +171,7 @@ static void Run( intf_thread_t *p_intf )
int i_args = 1; int i_args = 1;
int i_dummy; int i_dummy;
/* gtk_init will register stuff with g_atexit, so we need to take
* the global lock if we want to be able to intercept the calls */
vlc_mutex_lock( &p_intf->p_libvlc->global_lock );
gtk_init( &i_args, &pp_args ); gtk_init( &i_args, &pp_args );
vlc_mutex_unlock( &p_intf->p_libvlc->global_lock );
#endif #endif
/* Create some useful widgets that will certainly be used */ /* Create some useful widgets that will certainly be used */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* gtk_main.c : Gtk+ wrapper for gtk_main * gtk_main.c : Gtk+ wrapper for gtk_main
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * Copyright (C) 2002 VideoLAN
* $Id: gtk_main.c,v 1.8 2002/10/04 13:13:54 sam Exp $ * $Id: gtk_main.c,v 1.9 2002/10/04 18:07:21 sam Exp $
* *
* Authors: Samuel Hocevar <sam@zoy.org> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -56,6 +56,7 @@ typedef struct gtk_main_t ...@@ -56,6 +56,7 @@ typedef struct gtk_main_t
/***************************************************************************** /*****************************************************************************
* Local variables (mutex-protected). * Local variables (mutex-protected).
*****************************************************************************/ *****************************************************************************/
static vlc_mutex_t * p_gtklock;
static int i_refcount = 0; static int i_refcount = 0;
static gtk_main_t * p_gtk_main = NULL; static gtk_main_t * p_gtk_main = NULL;
...@@ -80,12 +81,15 @@ vlc_module_end(); ...@@ -80,12 +81,15 @@ vlc_module_end();
*****************************************************************************/ *****************************************************************************/
static int Open( vlc_object_t *p_this ) static int Open( vlc_object_t *p_this )
{ {
vlc_mutex_lock( &p_this->p_libvlc->global_lock ); /* FIXME: put this in the module (de)initialization ASAP */
p_gtklock = vlc_mutex_need( p_this, "gtk" );
vlc_mutex_lock( p_gtklock );
if( i_refcount > 0 ) if( i_refcount > 0 )
{ {
i_refcount++; i_refcount++;
vlc_mutex_unlock( &p_this->p_libvlc->global_lock ); vlc_mutex_unlock( p_gtklock );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -105,12 +109,13 @@ static int Open( vlc_object_t *p_this ) ...@@ -105,12 +109,13 @@ static int Open( vlc_object_t *p_this )
{ {
vlc_object_destroy( p_gtk_main ); vlc_object_destroy( p_gtk_main );
i_refcount--; i_refcount--;
vlc_mutex_unlock( &p_this->p_libvlc->global_lock ); vlc_mutex_unlock( p_gtklock );
vlc_mutex_unneed( p_this, "gtk" );
return VLC_ETHREAD; return VLC_ETHREAD;
} }
i_refcount++; i_refcount++;
vlc_mutex_unlock( &p_this->p_libvlc->global_lock ); vlc_mutex_unlock( p_gtklock );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -120,13 +125,14 @@ static int Open( vlc_object_t *p_this ) ...@@ -120,13 +125,14 @@ static int Open( vlc_object_t *p_this )
*****************************************************************************/ *****************************************************************************/
static void Close( vlc_object_t *p_this ) static void Close( vlc_object_t *p_this )
{ {
vlc_mutex_lock( &p_this->p_libvlc->global_lock ); vlc_mutex_lock( p_gtklock );
i_refcount--; i_refcount--;
if( i_refcount > 0 ) if( i_refcount > 0 )
{ {
vlc_mutex_unlock( &p_this->p_libvlc->global_lock ); vlc_mutex_unlock( p_gtklock );
vlc_mutex_unneed( p_this, "gtk" );
return; return;
} }
...@@ -136,7 +142,8 @@ static void Close( vlc_object_t *p_this ) ...@@ -136,7 +142,8 @@ static void Close( vlc_object_t *p_this )
vlc_object_destroy( p_gtk_main ); vlc_object_destroy( p_gtk_main );
p_gtk_main = NULL; p_gtk_main = NULL;
vlc_mutex_unlock( &p_this->p_libvlc->global_lock ); vlc_mutex_unlock( p_gtklock );
vlc_mutex_unneed( p_this, "gtk" );
} }
static gint foo( gpointer bar ) { return TRUE; } static gint foo( gpointer bar ) { return TRUE; }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* qte.cpp : QT Embedded plugin for vlc * qte.cpp : QT Embedded plugin for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 1998-2002 VideoLAN * Copyright (C) 1998-2002 VideoLAN
* $Id: qte.cpp,v 1.3 2002/09/23 21:44:23 jpsaman Exp $ * $Id: qte.cpp,v 1.4 2002/10/04 18:07:21 sam Exp $
* *
* Authors: Gerald Hansink <gerald.hansink@ordain.nl> * Authors: Gerald Hansink <gerald.hansink@ordain.nl>
* Jean-Paul Saman <jpsaman@wxs.nl> * Jean-Paul Saman <jpsaman@wxs.nl>
...@@ -160,7 +160,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -160,7 +160,7 @@ static int Open( vlc_object_t *p_this )
CreateQtWindow(p_vout); CreateQtWindow(p_vout);
//msg_Err(p_vout, "-vout_Create::qte\n" ); //msg_Err(p_vout, "-vout_Create::qte" );
return( 0 ); return( 0 );
} }
...@@ -173,7 +173,7 @@ static void Close ( vlc_object_t *p_this ) ...@@ -173,7 +173,7 @@ static void Close ( vlc_object_t *p_this )
{ {
vout_thread_t * p_vout = (vout_thread_t *)p_this; vout_thread_t * p_vout = (vout_thread_t *)p_this;
//msg_Err( p_vout, "+vout_Destroy::qte\n" ); //msg_Err( p_vout, "+vout_Destroy::qte" );
DestroyQtWindow(p_vout); DestroyQtWindow(p_vout);
free(p_vout->p_sys); free(p_vout->p_sys);
} }
...@@ -191,7 +191,7 @@ static int Init( vout_thread_t *p_vout ) ...@@ -191,7 +191,7 @@ static int Init( vout_thread_t *p_vout )
int dd = QPixmap::defaultDepth(); int dd = QPixmap::defaultDepth();
//msg_Err( p_vout,"+vout_Init::qte\n" ); //msg_Err( p_vout,"+vout_Init::qte" );
I_OUTPUTPICTURES = 0; I_OUTPUTPICTURES = 0;
...@@ -234,7 +234,7 @@ static int Init( vout_thread_t *p_vout ) ...@@ -234,7 +234,7 @@ static int Init( vout_thread_t *p_vout )
I_OUTPUTPICTURES++; I_OUTPUTPICTURES++;
} }
//msg_Err(p_vout, "-vout_Init::qte %d output pictures\n", I_OUTPUTPICTURES); //msg_Err(p_vout, "-vout_Init::qte %d output pictures", I_OUTPUTPICTURES);
return( 0 ); return( 0 );
} }
...@@ -245,7 +245,7 @@ static int Init( vout_thread_t *p_vout ) ...@@ -245,7 +245,7 @@ static int Init( vout_thread_t *p_vout )
*****************************************************************************/ *****************************************************************************/
static void Render( vout_thread_t *p_vout, picture_t *p_pic ) static void Render( vout_thread_t *p_vout, picture_t *p_pic )
{ {
//msg_Err(p_vout, "+vout_Render::qte\n" ); //msg_Err(p_vout, "+vout_Render::qte" );
; ;
} }
...@@ -319,7 +319,7 @@ static void Display( vout_thread_t *p_vout, picture_t *p_pic ) ...@@ -319,7 +319,7 @@ static void Display( vout_thread_t *p_vout, picture_t *p_pic )
*****************************************************************************/ *****************************************************************************/
static int Manage( vout_thread_t *p_vout ) static int Manage( vout_thread_t *p_vout )
{ {
//msg_Err(p_vout, "+vout_Manage::qte\n" ); //msg_Err(p_vout, "+vout_Manage::qte" );
return 0; return 0;
} }
...@@ -333,7 +333,7 @@ static void End( vout_thread_t *p_vout ) ...@@ -333,7 +333,7 @@ static void End( vout_thread_t *p_vout )
{ {
int i_index; int i_index;
//msg_Err(p_vout, "+vout_End::qte\n" ); //msg_Err(p_vout, "+vout_End::qte" );
/* Free the direct buffers we allocated */ /* Free the direct buffers we allocated */
for( i_index = I_OUTPUTPICTURES ; i_index ; ) for( i_index = I_OUTPUTPICTURES ; i_index ; )
...@@ -353,7 +353,7 @@ static int NewPicture( vout_thread_t *p_vout, picture_t *p_pic ) ...@@ -353,7 +353,7 @@ static int NewPicture( vout_thread_t *p_vout, picture_t *p_pic )
{ {
int dd = QPixmap::defaultDepth(); int dd = QPixmap::defaultDepth();
//msg_Err(p_vout, "+NewPicture::dd = %d\n",dd ); //msg_Err(p_vout, "+NewPicture::dd = %d",dd );
p_pic->p_sys = (picture_sys_t*) malloc( sizeof( picture_sys_t ) ); p_pic->p_sys = (picture_sys_t*) malloc( sizeof( picture_sys_t ) );
...@@ -428,7 +428,7 @@ static int NewPicture( vout_thread_t *p_vout, picture_t *p_pic ) ...@@ -428,7 +428,7 @@ static int NewPicture( vout_thread_t *p_vout, picture_t *p_pic )
} }
/* /*
msg_Err(p_vout, "NewPicture: %d %d %d\n",p_vout->output.i_width, msg_Err(p_vout, "NewPicture: %d %d %d",p_vout->output.i_width,
p_vout->output.i_height, p_vout->output.i_height,
p_vout->output.i_chroma ); p_vout->output.i_chroma );
*/ */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* input.c : internal management of input streams for the audio output * input.c : internal management of input streams for the audio output
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * Copyright (C) 2002 VideoLAN
* $Id: input.c,v 1.14 2002/09/27 23:38:04 massiot Exp $ * $Id: input.c,v 1.15 2002/10/04 18:07:22 sam Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -168,7 +168,6 @@ int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input, ...@@ -168,7 +168,6 @@ int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input,
mdate() - p_buffer->start_date ); mdate() - p_buffer->start_date );
aout_BufferFree( p_buffer ); aout_BufferFree( p_buffer );
vlc_mutex_unlock( &p_input->lock );
return 0; return 0;
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* libvlc.c: main libvlc source * libvlc.c: main libvlc source
***************************************************************************** *****************************************************************************
* Copyright (C) 1998-2002 VideoLAN * Copyright (C) 1998-2002 VideoLAN
* $Id: libvlc.c,v 1.35 2002/10/03 18:56:09 sam Exp $ * $Id: libvlc.c,v 1.36 2002/10/04 18:07:22 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>
...@@ -142,6 +142,7 @@ vlc_t * vlc_create_r( void ) ...@@ -142,6 +142,7 @@ vlc_t * vlc_create_r( void )
{ {
int i_ret; int i_ret;
vlc_t * p_vlc = NULL; vlc_t * p_vlc = NULL;
vlc_mutex_t * p_libvlc_lock;
/* vlc_threads_init *must* be the first internal call! No other call is /* vlc_threads_init *must* be the first internal call! No other call is
* allowed before the thread system has been initialized. */ * allowed before the thread system has been initialized. */
...@@ -152,16 +153,13 @@ vlc_t * vlc_create_r( void ) ...@@ -152,16 +153,13 @@ vlc_t * vlc_create_r( void )
} }
/* Now that the thread system is initialized, we don't have much, but /* Now that the thread system is initialized, we don't have much, but
* at least we have libvlc.global_lock */ * at least we have vlc_mutex_need */
vlc_mutex_lock( &libvlc.global_lock ); p_libvlc_lock = vlc_mutex_need( &libvlc, "libvlc" );
vlc_mutex_lock( p_libvlc_lock );
if( !libvlc.b_ready ) if( !libvlc.b_ready )
{ {
char *psz_env; char *psz_env;
vlc_mutex_init( &libvlc, &libvlc.structure_lock );
libvlc.p_global_data = NULL;
libvlc.b_ready = VLC_TRUE;
/* Guess what CPU we have */ /* Guess what CPU we have */
libvlc.i_cpu = CPUCapabilities(); libvlc.i_cpu = CPUCapabilities();
...@@ -182,14 +180,17 @@ vlc_t * vlc_create_r( void ) ...@@ -182,14 +180,17 @@ vlc_t * vlc_create_r( void )
msg_Dbg( &libvlc, COPYRIGHT_MESSAGE ); msg_Dbg( &libvlc, COPYRIGHT_MESSAGE );
msg_Dbg( &libvlc, "libvlc was configured with %s", CONFIGURE_LINE ); msg_Dbg( &libvlc, "libvlc was configured with %s", CONFIGURE_LINE );
/* Initialize the module bank and and load the configuration of the /* Initialize the module bank and load the configuration of the
* main module. We need to do this at this stage to be able to display * main module. We need to do this at this stage to be able to display
* a short help if required by the user. (short help == main module * a short help if required by the user. (short help == main module
* options) */ * options) */
module_InitBank( &libvlc ); module_InitBank( &libvlc );
module_LoadMain( &libvlc ); module_LoadMain( &libvlc );
libvlc.b_ready = VLC_TRUE;
} }
vlc_mutex_unlock( &libvlc.global_lock ); vlc_mutex_unlock( p_libvlc_lock );
vlc_mutex_unneed( &libvlc, "libvlc" );
/* Allocate a vlc object */ /* Allocate a vlc object */
p_vlc = vlc_object_create( &libvlc, VLC_OBJECT_VLC ); p_vlc = vlc_object_create( &libvlc, VLC_OBJECT_VLC );
...@@ -416,9 +417,9 @@ vlc_error_t vlc_init_r( vlc_t *p_vlc, int i_argc, char *ppsz_argv[] ) ...@@ -416,9 +417,9 @@ vlc_error_t vlc_init_r( vlc_t *p_vlc, int i_argc, char *ppsz_argv[] )
else else
{ {
int i_tmp = config_GetInt( p_vlc, "verbose" ); int i_tmp = config_GetInt( p_vlc, "verbose" );
if( i_tmp >= 0 && i_tmp <= 4 ) if( i_tmp >= 0 )
{ {
libvlc.i_verbose = i_tmp; libvlc.i_verbose = __MIN( i_tmp, 4 );
} }
} }
libvlc.b_color = libvlc.b_color || config_GetInt( p_vlc, "color" ); libvlc.b_color = libvlc.b_color || config_GetInt( p_vlc, "color" );
......
...@@ -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.22 2002/10/03 18:56:10 sam Exp $ * $Id: objects.c,v 1.23 2002/10/04 18:07:22 sam Exp $
* *
* Authors: Samuel Hocevar <sam@zoy.org> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -56,6 +56,11 @@ static void SetAttachment ( vlc_object_t *, vlc_bool_t ); ...@@ -56,6 +56,11 @@ static void SetAttachment ( vlc_object_t *, vlc_bool_t );
static vlc_list_t * NewList ( void ); static vlc_list_t * NewList ( void );
static vlc_list_t * ListAppend ( vlc_list_t *, vlc_object_t * ); static vlc_list_t * ListAppend ( vlc_list_t *, vlc_object_t * );
/*****************************************************************************
* Local structure lock
*****************************************************************************/
static vlc_mutex_t structure_lock;
/***************************************************************************** /*****************************************************************************
* vlc_object_create: initialize a vlc object * vlc_object_create: initialize a vlc object
***************************************************************************** *****************************************************************************
...@@ -142,10 +147,9 @@ void * __vlc_object_create( vlc_object_t *p_this, int i_type ) ...@@ -142,10 +147,9 @@ void * __vlc_object_create( vlc_object_t *p_this, int i_type )
p_new->b_dead = VLC_FALSE; p_new->b_dead = VLC_FALSE;
p_new->b_attached = VLC_FALSE; p_new->b_attached = VLC_FALSE;
/* If i_type is root, then p_new is our own p_libvlc */
if( i_type == VLC_OBJECT_ROOT ) if( i_type == VLC_OBJECT_ROOT )
{ {
/* We are the first object ... no need to lock. */ /* If i_type is root, then p_new is actually p_libvlc */
p_new->p_libvlc = (libvlc_t*)p_new; p_new->p_libvlc = (libvlc_t*)p_new;
p_new->p_vlc = NULL; p_new->p_vlc = NULL;
...@@ -163,7 +167,7 @@ void * __vlc_object_create( vlc_object_t *p_this, int i_type ) ...@@ -163,7 +167,7 @@ void * __vlc_object_create( vlc_object_t *p_this, int i_type )
p_new->p_vlc = ( i_type == VLC_OBJECT_VLC ) ? (vlc_t*)p_new p_new->p_vlc = ( i_type == VLC_OBJECT_VLC ) ? (vlc_t*)p_new
: p_this->p_vlc; : p_this->p_vlc;
vlc_mutex_lock( &p_this->p_libvlc->structure_lock ); vlc_mutex_lock( &structure_lock );
p_new->p_libvlc->i_counter++; p_new->p_libvlc->i_counter++;
p_new->i_object_id = p_new->p_libvlc->i_counter; p_new->i_object_id = p_new->p_libvlc->i_counter;
...@@ -176,7 +180,7 @@ void * __vlc_object_create( vlc_object_t *p_this, int i_type ) ...@@ -176,7 +180,7 @@ void * __vlc_object_create( vlc_object_t *p_this, int i_type )
p_new->p_libvlc->i_objects * sizeof(vlc_object_t *) ); p_new->p_libvlc->i_objects * sizeof(vlc_object_t *) );
p_new->p_libvlc->pp_objects[ p_new->p_libvlc->i_objects - 1 ] = p_new;