[vlc-devel] commit: libvlc: another reentrancy fix ( Rafaël Carré )

git version control git at videolan.org
Mon Aug 25 11:18:06 CEST 2008


vlc | branch: 0.8.6-bugfix | Rafaël Carré <rcarre at m2x.nl> | Mon Aug 25 11:15:31 2008 +0200| [b9c8c1570d6c6d525b7fd3a65637e93fcae5edfe] | committer: Rafaël Carré 

libvlc: another reentrancy fix

system_{Init,End}() are meant to be used once per process.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b9c8c1570d6c6d525b7fd3a65637e93fcae5edfe
---

 src/libvlc.c |   24 ++++++++++++++++++------
 1 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/src/libvlc.c b/src/libvlc.c
index e525e35..76777b9 100644
--- a/src/libvlc.c
+++ b/src/libvlc.c
@@ -303,7 +303,18 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] )
     /*
      * System specific initialization code
      */
-    system_Init( p_vlc, &i_argc, ppsz_argv );
+    var_Create( p_libvlc, "libvlc", VLC_VAR_MUTEX );
+    var_Get( p_libvlc, "libvlc", &val );
+    vlc_mutex_lock( val.p_address );
+
+    static vlc_bool_t b_inited = VLC_FALSE;
+    if( !b_inited )
+    {
+        b_inited = VLC_TRUE;
+        system_Init( p_vlc, &i_argc, ppsz_argv );
+    }
+
+    vlc_mutex_unlock( val.p_address );
 
     /* Get the executable name (similar to the basename command) */
     if( i_argc > 0 )
@@ -1022,11 +1033,6 @@ int VLC_Destroy( int i_object )
     }
 
     /*
-     * System specific cleaning code
-     */
-    system_End( p_vlc );
-
-    /*
      * Free message queue.
      * Nobody shall use msg_* afterward.
      */
@@ -1040,8 +1046,14 @@ int VLC_Destroy( int i_object )
     vlc_mutex_unlock( lockval.p_address );
 
     if( b_destroy )
+    {
         msg_Destroy( p_libvlc );
 
+        /*
+         * System specific cleaning code
+         */
+        system_End( p_vlc );
+    }
 
     /* Destroy global iconv */
     LocaleDeinit();




More information about the vlc-devel mailing list