Condividi tramite


The mysterious WASAPI lock on Windows 7

CaptureExclusiveEventDriven.zip

Problem: On Windows 7, if a stream is initialized to be timer driven and in exclusive mode, the WASAPI release of the capture audio client (IAudioCaptureClient) will lock if the release is called when a USB audio device is disconnected. 

Workaround: The problem is actually in the audiodg.exe. When someone pull the plug of a USB audio capture device in the middle of the audio capture session, it releases the audio driver handle without waiting for the recording application to finish all of its cleanup job. This behavior doesn’t exist on Windows 8.

You can bypass this problem by using WASAPI in event driven mode. It is actually far better than timer mode and highly recommended for the applications those require low latency. I have attached a sample application to demonstrate this workaround.