Skip to content

Commit

Permalink
mmdevice: only use active devices
Browse files Browse the repository at this point in the history
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
 videolan#2  0x000007feb5f989b0 in SetStateVersion ()
   from C:\Windows\system32\kernel32.dll
 videolan#3  0x000007feb4290ba7 in UnhandledExceptionFilter ()
   from C:\Windows\system32\KernelBase.dll
 videolan#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
 videolan#7  0x000007feb6f1567c in ntdll!DbgPrint () from C:\Windows\SYSTEM32\ntdll.dll
 videolan#8  0x000007feb6f15b28 in ntdll!RtlRaiseException ()
   from C:\Windows\SYSTEM32\ntdll.dll
 videolan#9  0x000007feb42289cc in RaiseException ()
   from C:\Windows\system32\KernelBase.dll
 videolan#10 0x000007feb157278b in MMDevAPI!DllCanUnloadNow ()
   from C:\Windows\System32\MMDevAPI.dll
 videolan#11 0x000007feb1574b24 in MMDevAPI!DllGetClassObject ()
   from C:\Windows\System32\MMDevAPI.dll
 videolan#12 0x000007fea57e1c87 in DllGetClassObject ()
   from C:\Windows\SYSTEM32\AudioSes.dll
 videolan#13 0x000007feb1575a15 in MMDevAPI!DllGetClassObject ()
   from C:\Windows\System32\MMDevAPI.dll
 videolan#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@gllm.fr>
  • Loading branch information
jbkempf authored and tguillem committed Jun 30, 2016
1 parent a05aba9 commit 589cd9f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions modules/audio_output/mmdevice.c
Expand Up @@ -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)
Expand Down

0 comments on commit 589cd9f

Please sign in to comment.