[vlc-devel] commit: Use msg_{Create,Destroy} only 1 time ( Rafaël Carré )
git version control
git at videolan.org
Mon Aug 4 12:18:53 CEST 2008
vlc | branch: 0.8.6-bugfix | Rafaël Carré <rcarre at m2x.nl> | Mon Aug 4 11:50:53 2008 +0200| [7ee81e13baa7e6a07724735debd2a9a832e6fdff] | committer: Rafaël Carré
Use msg_{Create,Destroy} only 1 time
This fixes a reentrancy problem with libvlc
This was experimented when using 2 plugins instance on a mozilla browser
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7ee81e13baa7e6a07724735debd2a9a832e6fdff
---
src/libvlc.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/libvlc.c b/src/libvlc.c
index 6d4f98a..904529f 100644
--- a/src/libvlc.c
+++ b/src/libvlc.c
@@ -89,6 +89,7 @@
static libvlc_t libvlc;
static libvlc_t * p_libvlc;
static vlc_t * p_static_vlc;
+static unsigned int i_libvlc = 0; /* number of libvlc instances running */
/*****************************************************************************
* Local prototypes
@@ -222,7 +223,8 @@ int VLC_Create( void )
#endif
/* Initialize message queue */
- msg_Create( p_libvlc );
+ if( i_libvlc == 0 ) /* only one time */
+ msg_Create( p_libvlc );
/* Announce who we are */
msg_Dbg( p_libvlc, COPYRIGHT_MESSAGE );
@@ -233,6 +235,8 @@ int VLC_Create( void )
libvlc.b_ready = VLC_TRUE;
}
+
+ i_libvlc++;
vlc_mutex_unlock( lockval.p_address );
var_Destroy( p_libvlc, "libvlc" );
@@ -1027,7 +1031,8 @@ int VLC_Destroy( int i_object )
* Nobody shall use msg_* afterward.
*/
msg_Flush( p_vlc );
- msg_Destroy( p_libvlc );
+ if( --i_libvlc == 0 )
+ msg_Destroy( p_libvlc );
/* Destroy global iconv */
LocaleDeinit();
More information about the vlc-devel
mailing list