How to correctly Dispose a SourceVoice once its finished
- by clamp
i am starting to play a sound with XAudio2 and SourceVoice and once its finished, it should be correctly disposed to not have any leaks.
i was expecting it to be something like this:
sourceVoice.Start();
sourceVoice.StreamEnd += delegate
{
if (!sourceVoice.IsDisposed)
{
sourceVoice.DestroyVoice();
sourceVoice.Dispose();
}
};
but that crashes with a read access violation in native code deep in XAudio2.dll which i cant debug.