[vlc-devel] [PATCH 1/2] audio_output/winstore: do the MTA+lock before setting the initial device

Steve Lhomme robux4 at ycbcr.xyz
Tue Nov 24 09:19:08 CET 2020


The requested device is set to the default one in Open and requires the MTA
setup in order for the activation to work. Otherwise it deadlocks.
---
 modules/audio_output/winstore.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/modules/audio_output/winstore.c b/modules/audio_output/winstore.c
index 07c4422f410..94c2d890663 100644
--- a/modules/audio_output/winstore.c
+++ b/modules/audio_output/winstore.c
@@ -431,6 +431,10 @@ static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt)
     if (unlikely(s == NULL))
         return -1;
 
+    // Load the "out stream" for the requested device
+    EnterMTA();
+    EnterCriticalSection(&sys->lock);
+
     if (sys->requested_device != NULL)
     {
         if (sys->acquired_device == NULL || wcscmp(sys->acquired_device, sys->requested_device))
@@ -439,16 +443,14 @@ static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt)
             DeviceRestartLocked(aout);
             if (sys->client == NULL)
             {
+                LeaveCriticalSection(&sys->lock);
+                LeaveMTA();
                 vlc_object_delete(&s->obj);
                 return -1;
             }
         }
     }
 
-    // Load the "out stream" for the requested device
-    EnterMTA();
-    EnterCriticalSection(&sys->lock);
-
     s->owner.activate = ActivateDevice;
     for (;;)
     {
-- 
2.26.2



More information about the vlc-devel mailing list