[vlc-commits] Serialized libmodplug loading code.

Laurent Aimar git at videolan.org
Sun May 8 18:03:38 CEST 2011


vlc/vlc-1.1 | branch: master | Laurent Aimar <fenrir at videolan.org> | Sun May  8 17:48:00 2011 +0200| [2ab09e387437a16e1545ecf625a440b123a1e951] | committer: Jean-Baptiste Kempf

Serialized libmodplug loading code.

libmodplug is thread safe except when loading files or configuring settings
(before loading a file).
(cherry picked from commit 64b98d8415574337e8354c9ebb05c41d1d458f6e)

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 modules/demux/mod.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/modules/demux/mod.c b/modules/demux/mod.c
index 37deaa4..587dde6 100644
--- a/modules/demux/mod.c
+++ b/modules/demux/mod.c
@@ -106,6 +106,7 @@ vlc_module_end ()
 /*****************************************************************************
  * Local prototypes
  *****************************************************************************/
+static vlc_mutex_t libmodplug_lock = VLC_STATIC_MUTEX;
 
 struct demux_sys_t
 {
@@ -196,6 +197,7 @@ static int Open( vlc_object_t *p_this )
     }
 
     /* Configure modplug before loading the file */
+    vlc_mutex_lock( &libmodplug_lock );
     ModPlug_GetSettings( &settings );
     settings.mFlags = MODPLUG_ENABLE_OVERSAMPLING;
     settings.mChannels = 2;
@@ -223,7 +225,10 @@ static int Open( vlc_object_t *p_this )
 
     ModPlug_SetSettings( &settings );
 
-    if( ( p_sys->f = ModPlug_Load( p_sys->p_data, p_sys->i_data ) ) == NULL )
+    p_sys->f = ModPlug_Load( p_sys->p_data, p_sys->i_data );
+    vlc_mutex_unlock( &libmodplug_lock );
+
+    if( !p_sys->f )
     {
         msg_Err( p_demux, "failed to understand the file" );
         /* we try to seek to recover for other plugin */



More information about the vlc-commits mailing list