[vlc-devel] [PATCH] mmdevice: allow apartment-threading as it may have been initialized that way

Steve Lhomme robUx4 at videolabs.io
Wed Mar 18 11:03:34 CET 2015


Fixes #14202

Similar to what is done in 0bbd58595c84527fa7884df2a0bdc41f06d73df1

In #14202 the DMO creates a thread and initializes COM with apartment-thread. If then
starts the aout which also initiliazes COM but with multithreading.

The same issue may occur when DMO is used for video.

Another fix could be to force DMO to use multithreading. Or have all the
CoInitializeEx use the same threading mode.
---
 modules/audio_output/mmdevice.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/modules/audio_output/mmdevice.c b/modules/audio_output/mmdevice.c
index 3df2686..b16764e 100644
--- a/modules/audio_output/mmdevice.c
+++ b/modules/audio_output/mmdevice.c
@@ -80,6 +80,9 @@ DEFINE_GUID (GUID_VLC_AUD_OUT, 0x4533f59d, 0x59ee, 0x00c6,
 static int TryEnterMTA(vlc_object_t *obj)
 {
     HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
+    if (SUCCEEDED(hr))
+        return 0;
+    hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
     if (unlikely(FAILED(hr)))
     {
         msg_Err (obj, "cannot initialize COM (error 0x%lx)", hr);
@@ -92,6 +95,9 @@ static int TryEnterMTA(vlc_object_t *obj)
 static void EnterMTA(void)
 {
     HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
+    if (SUCCEEDED(hr))
+        return;
+    hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
     if (unlikely(FAILED(hr)))
         abort();
 }
-- 
2.3.2




More information about the vlc-devel mailing list