[vlc-commits] mmdevice: only use active devices

Jean-Baptiste Kempf git at videolan.org
Thu Jun 30 13:41:11 CEST 2016


vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Tue Jun 28 11:24:39 2016 +0200| [589cd9f5fcb74e4813d7c991e8d7d62d1e14c5e5] | committer: Thomas Guillem

mmdevice: only use active devices

This fixes a crash (a Windows Exception) when VLC is run just after windows
start and when an unactive device is activated.

This issue is very hard to reproduce, here is the backtrace:

 #0  0x000007feb6ef2f2a in ntdll!ZwDelayExecution ()
   from C:\Windows\SYSTEM32\ntdll.dll
 #1  0x000007feb42111f2 in SleepEx () from C:\Windows\system32\KernelBase.dll
 #2  0x000007feb5f989b0 in SetStateVersion ()
   from C:\Windows\system32\kernel32.dll
 #3  0x000007feb4290ba7 in UnhandledExceptionFilter ()
   from C:\Windows\system32\KernelBase.dll
 #4  0x000007feb6fe9183 in ntdll!SbExecuteProcedure ()
   from C:\Windows\SYSTEM32\ntdll.dll
 #5  0x000007feb6f14fea in ntdll!__C_specific_handler ()
   from C:\Windows\SYSTEM32\ntdll.dll
 #6  0x000007feb6f1464d in ntdll!RtlLookupFunctionEntry ()
   from C:\Windows\SYSTEM32\ntdll.dll
 #7  0x000007feb6f1567c in ntdll!DbgPrint () from C:\Windows\SYSTEM32\ntdll.dll
 #8  0x000007feb6f15b28 in ntdll!RtlRaiseException ()
   from C:\Windows\SYSTEM32\ntdll.dll
 #9  0x000007feb42289cc in RaiseException ()
   from C:\Windows\system32\KernelBase.dll
 #10 0x000007feb157278b in MMDevAPI!DllCanUnloadNow ()
   from C:\Windows\System32\MMDevAPI.dll
 #11 0x000007feb1574b24 in MMDevAPI!DllGetClassObject ()
   from C:\Windows\System32\MMDevAPI.dll
 #12 0x000007fea57e1c87 in DllGetClassObject ()
   from C:\Windows\SYSTEM32\AudioSes.dll
 #13 0x000007feb1575a15 in MMDevAPI!DllGetClassObject ()
   from C:\Windows\System32\MMDevAPI.dll
 #14 0x0000000054a71438 in ActivateDevice (opaque=<optimized out>,
    iid=<optimized out>, actparms=<optimized out>, pv=<optimized out>)
    at ../../extras/package/win32/../../../modules/audio_output/mmdevice.c:1018
 ...

Signed-off-by: Thomas Guillem <thomas at gllm.fr>

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

 modules/audio_output/mmdevice.c |   11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/modules/audio_output/mmdevice.c b/modules/audio_output/mmdevice.c
index 666ad98..b48dbb3 100644
--- a/modules/audio_output/mmdevice.c
+++ b/modules/audio_output/mmdevice.c
@@ -488,12 +488,15 @@ static bool DeviceIsRender(IMMDevice *dev)
 
     IMMEndpoint *ep = pv;
     EDataFlow flow;
-
-    if (FAILED(IMMEndpoint_GetDataFlow(ep, &flow)))
-        flow = eCapture;
+    HRESULT hr = IMMEndpoint_GetDataFlow(ep, &flow);
 
     IMMEndpoint_Release(ep);
-    return flow == eRender;
+    if (FAILED(hr) || flow != eRender)
+        return false;
+
+    DWORD pdwState;
+    hr = IMMDevice_GetState(dev, &pdwState);
+    return !FAILED(hr) && pdwState == DEVICE_STATE_ACTIVE;
 }
 
 static HRESULT DeviceUpdated(audio_output_t *aout, LPCWSTR wid)



More information about the vlc-commits mailing list