This project has moved and is read-only. For the latest updates, please go here.

WasapiLoopbackCapture sound hang issue

Aug 3, 2014 at 9:05 PM
Edited Aug 10, 2014 at 9:39 PM
Hi there,

I'm using the WasapiLoopbackCapture to get the audio played on a system and visualize it.

When I playback music and exit the music player or press stop then the sound "hangs" (happens with VLC and Winamp, not Windows Media Player). It seems that the last soundbuffer just gets repeated.

While normal music playback it looks like there is sound coming from both applications (my application and the music player). Actually there isn't any sound coming from my application, if i mute it there is no output difference on my headphones, but my application doesn't get any sound from the loopback.
This looks like this.

When pressing stop or exiting the music player the last soundbuffer continues to play over and over until i exit my application. Looking into the volume control you can see this. The sound is coming from my application.

I'm using Windows 7 x64.

How can i prevent this?

Here is a video to better show you whats the issue

Aug 6, 2014 at 11:07 AM
why have you made your own WasapiCapture and WasapiLoopbackCapture classes? The default constructor is getting the default Render device and it should be getting the default Capture device.
Aug 8, 2014 at 6:50 PM
Edited Aug 8, 2014 at 7:38 PM
I made my own classes because with the standard classes i get an exception (ArgumentException("Unsupported Wave Format")) when selecting more than 2 channels (eg, 4, 6 or 8) with my Asus Xonar DS.
However just copying the code from this source and writing my own classes without any changes fixes this.

EDIT: However the issue is unrelated to my own 2 classes. I just used WasapiLoopbackCapture and WasapiCapture from NAudio instead and the problem persists.
EDIT2: While using a screen recording software the issue disappears.
Aug 10, 2014 at 9:39 PM
I've added a video to the main post.
Aug 14, 2014 at 3:01 PM
Any ideas?
Aug 20, 2014 at 2:30 PM
WasapiLoopback capture will get no fresh audio if no applications are playing system sound.
Are you trying to capture audio and play it back at the same time?
Aug 26, 2014 at 10:59 PM
Edited Aug 26, 2014 at 11:01 PM
What I'm doing is:
  • create WasapiLoopbackCapture
  • register SampleAggregator to the WasapiLoopbackCapture.DataAvailable
  • perform FFT
  • display via DirectX
My application is not playing any audio and I'm not recording the audio.

I just checked on a second PC and I get the same visual results eg. it seems there is sound coming from my application but the sound doesn't hang there.
Are there any known issues with specific soundcards?