[vlc-commits] directsound: fix uninitialized mutex and condition variable

Rémi Denis-Courmont git at videolan.org
Thu Nov 13 18:39:37 CET 2014


vlc/vlc-2.2 | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Nov 12 22:10:36 2014 +0200| [e35772f8a82e83fc11c2059c535aa5419d8ea7f1] | committer: Rémi Denis-Courmont

directsound: fix uninitialized mutex and condition variable

Regression from 3044105e9d4664609a7d749469fe0fd6d85e90ff.

(cherry picked from commit 2d3723d149044db9dff5b05035c7efce5e5200f9)

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

 modules/audio_output/directsound.c |   17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/modules/audio_output/directsound.c b/modules/audio_output/directsound.c
index eefd77a..39ae953 100644
--- a/modules/audio_output/directsound.c
+++ b/modules/audio_output/directsound.c
@@ -547,9 +547,12 @@ static HRESULT Stop( aout_stream_sys_t *p_sys )
     vlc_mutex_lock( &p_sys->lock );
     p_sys->b_playing =  true;
     vlc_cond_signal( &p_sys->cond );
-    vlc_cancel( p_sys->eraser_thread );
     vlc_mutex_unlock( &p_sys->lock );
+    vlc_cancel( p_sys->eraser_thread );
     vlc_join( p_sys->eraser_thread, NULL );
+    vlc_cond_destroy( &p_sys->cond );
+    vlc_mutex_destroy( &p_sys->lock );
+
     if( p_sys->p_notify != NULL )
     {
         IDirectSoundNotify_Release(p_sys->p_notify );
@@ -766,12 +769,19 @@ static HRESULT Start( vlc_object_t *obj, aout_stream_sys_t *sys,
         }
     }
 
+    vlc_mutex_init(&sys->lock);
+    vlc_cond_init(&sys->cond);
+
     int ret = vlc_clone(&sys->eraser_thread, PlayedDataEraser, (void*) obj,
                         VLC_THREAD_PRIORITY_LOW);
     if( unlikely( ret ) )
     {
         if( ret != ENOMEM )
             msg_Err( obj, "Couldn't start eraser thread" );
+
+        vlc_cond_destroy(&sys->cond);
+        vlc_mutex_destroy(&sys->lock);
+
         if( sys->p_notify != NULL )
         {
             IDirectSoundNotify_Release( sys->p_notify );
@@ -1086,9 +1096,6 @@ static int Open(vlc_object_t *obj)
     aout_DeviceReport(aout, dev);
     free(dev);
 
-    vlc_mutex_init(&sys->s.lock);
-    vlc_cond_init(&sys->s.cond);
-
     return VLC_SUCCESS;
 }
 
@@ -1096,8 +1103,6 @@ static void Close(vlc_object_t *obj)
 {
     audio_output_t *aout = (audio_output_t *)obj;
     aout_sys_t *sys = aout->sys;
-    vlc_cond_destroy( &sys->s.cond );
-    vlc_mutex_destroy( &sys->s.lock );
 
     var_Destroy(aout, "directx-audio-device");
     FreeLibrary(sys->hdsound_dll); /* free DSOUND.DLL */



More information about the vlc-commits mailing list