[wdmaudiodev] audiodg.exe hangs while system is shutting down on Windows 8.1

  • From: Dhaval Kavar <dkavar47@xxxxxxxxx>
  • To: wdmaudiodev@xxxxxxxxxxxxx
  • Date: Wed, 23 Jul 2014 12:18:19 +0530

Hi All,

We are developing an APO for Input devices.

For echo cancellation, we use Loop-back feature and we use similar method
as described in:
*http://msdn.microsoft.com/en-us/library/windows/desktop/dd370800%28v=vs.85%29.aspx
<http://msdn.microsoft.com/en-us/library/windows/desktop/dd370800%28v=vs.85%29.aspx>*

To capture the render audio data, we have a thread in APO.

We are facing issues on Windows 8.1 OS (both 32bit and 64bit) that happen
in below use case:
a. Start Windows Sound Recorder. This will load our Input APO (MFX on
Windows 8.1 or LFX on Windows 7) in memory under audidg.exe.
b. Shutdown the Windows OS.

When system is getting shutting down, input APO gets APO::UnlockForProcess
and then we make a call to IAudioClient -> Stop method. But, IAudioClient
-> Stop method hangs! This is issue 1.

IAudioClient -> Stop executes in a capture thread and we wait for the
thread to complete its task. Because capture thread is already in hung
state WaitForSingleObject on thread handle times out. Then we release the
objects that we hold and IAudioCaptureClient -> Release hangs too. This is
issue number 2.

*Some consequences that we saw on above hangs are as follows:*
Because audiodg.exe is in hung state, System does not shutdown properly and
"System" process (process ID: 4) makes the system to Sleep. We observe this
behavior via Event Viewer application where we can see an Event ID 42 is
added with "The system is entering sleep. Sleep Reason: Application API"
description.

When we start the machine again, it starts in the same state where
audiodg.exe is in hung state! So, we cannot use input or output device
anymore unless we kill audiodg.exe and restart the audio services again.

*More analysis:*
We saw that when we make IAudioClient -> Stop method call,
IAudioSessionEvents::
OnStateChanged -> AudioSessionStateInactive gets called on Windows 7 while
system is shutting down. But, same method does not executed on Windows 8.1!

Any help or idea on how to solve these issues would be much appreciated.

Regards,
Dhaval

Other related posts: