naudio / NAudio

Audio and MIDI library for .NET
MIT License
5.37k stars 1.09k forks source link

System.MemoryAccessViolation Exception for WaveInEvent #1150

Open SineVector241 opened 2 months ago

SineVector241 commented 2 months ago

This is an issue I only ran into once but I feel like it should be known. Basically when I stopped the WaveInEvent and disposed of it as my VOIP app timed out, it crashed with this error (I had to use Event Viewer to see the actual error). I believe this might be the case of no thread safety and no SafeHandle or reference count for the Interop. It's a very specific issue with a pretty specific timing to trigger even though I was stopping the WaveInEvent on the main thread.

Might be a one off issue but it could be an issue later down the track. image.png