[vlc-devel] [PATCHv2 3/3] mmdevice: sys->dev need to be read locked

Thomas Guillem thomas at gllm.fr
Thu Jul 6 11:25:01 CEST 2017


---
 modules/audio_output/mmdevice.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/modules/audio_output/mmdevice.c b/modules/audio_output/mmdevice.c
index 194a8bf91b..772fb48565 100644
--- a/modules/audio_output/mmdevice.c
+++ b/modules/audio_output/mmdevice.c
@@ -1087,9 +1087,6 @@ static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt)
 {
     aout_sys_t *sys = aout->sys;
 
-    if (sys->dev == NULL)
-        return -1;
-
     aout_stream_t *s = vlc_object_create(aout, sizeof (*s));
     if (unlikely(s == NULL))
         return -1;
@@ -1098,6 +1095,15 @@ static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt)
 
     EnterMTA();
     EnterCriticalSection(&sys->lock);
+
+    if (sys->dev == NULL)
+    {
+        vlc_object_release(s);
+        LeaveCriticalSection(&sys->lock);
+        LeaveMTA();
+        return -1;
+    }
+
     for (;;)
     {
         HRESULT hr;
-- 
2.11.0



More information about the vlc-devel mailing list