In Windows 10 versions 1703 and higher, event-driven loopback clients are supported, and no longer need the workaround involving the render stream.Ī client can enable loopback mode only for a shared-mode stream (AUDCLNT_SHAREMODE_SHARED). Each time the client receives an event for the render stream, it must signal the capture client to run the capture thread that reads the next set of samples from the capture endpoint buffer. To work around this, initialize a render stream in event-driven mode. In versions of Windows prior to Windows 10 1703, pull-mode capture client does not receive any events when a stream is initialized with event-driven buffering and is loopback-enabled. In the call to the IAudioClient::Initialize method, change the value of the second parameter ( StreamFlags) from 0 to AUDCLNT_STREAMFLAGS_LOOPBACK.In the call to the IMMDeviceEnumerator::GetDefaultAudioEndpoint method, change the first parameter ( dataFlow) from eCapture to eRender.
In the code example in Capturing a Stream, the RecordAudioStream function can be easily modified to configure a loopback-mode capture stream.
However, other types of audio applications might find loopback mode useful for capturing the system mix that is being played by the audio engine. WASAPI provides loopback mode primarily to support acoustic echo cancellation (AEC).