Stability issues with WASAPI on Windows

Jonas Kvinge jonas at timeoutofmind.net
Thu Dec 10 15:30:03 UTC 2020


Hi

I'm working on a open source music player
(https://github.com/strawberrymusicplayer/strawberry). I'm having
several issues since adding the WASAPI plugin on Windows.

Issue 1: When using gst_element_set_state in a concurrent thread it
fails because of a missing CoInitializeEx() in
gst_wasapi_util_get_device_enumerator, so initial playback fails.
I added the following patch to gstwsapiutil.c which seem to fix it, but
I'm not entirely sure if this is correct:

diff --git a/sys/wasapi/gstwasapiutil.c b/sys/wasapi/gstwasapiutil.c
index 1111111..2222222 100644
--- a/sys/wasapi/gstwasapiutil.c
+++ b/sys/wasapi/gstwasapiutil.c
@@ -311,10 +311,14 @@ gst_wasapi_util_get_device_enumerator (GstObject *
self)
   HRESULT hr;
   IMMDeviceEnumerator *enumerator = NULL;
 
+  HRESULT hr_coinit = CoInitializeEx (NULL, COINIT_MULTITHREADED);
+
   hr = CoCreateInstance (&CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL,
       &IID_IMMDeviceEnumerator, (void **) &enumerator);
   HR_FAILED_RET (hr, CoCreateInstance (MMDeviceEnumerator), NULL);
 
+  if (hr_coinit == S_OK || hr_coinit == S_FALSE) CoUninitialize();
+
   return enumerator;
 }
 
Issue 2: After starting and stopping playback, it is no longer possible
to drag and drop songs in the playlist. I don't know if this is a Qt
bug, or gstreamer bug, but the problem only occurs on Windows when using
WASAPI as output.. I'm using Qt 5.15.2
This can be seen using the builds from
https://builds.strawberrymusicplayer.org/windows/
This problem occurs with or without my patch for issue 1.

Issue 3: I'm using a windows thumbbar, the pointer to the taskbar list
get invalidated after using the wasapi plugin. I had to change my code
for the thumbbar after adding wasapi.
This is the code:
  static const GUID CLSID_ITaskbarList = {
0x56FDF344,0xFD6D,0x11d0,{0x95,0x8A,0x00,0x60,0x97,0xC9,0xA0,0x90}};
  HRESULT hr = CoCreateInstance(CLSID_ITaskbarList, nullptr, CLSCTX_ALL,
IID_ITaskbarList3, (void**)&taskbar_list);

It seems taskbar_list gets freed somehow when starting / stopping
playback. But this only occurs when using wasapi. Maybe the correct
behavior is to call CoCreateInstance again on each event in my code,
that's what I did to fix it.

Jonas



More information about the gstreamer-devel mailing list