How to correctly Dispose a SourceVoice once its finished

Posted by clamp on Game Development See other posts from Game Development or by clamp
Published on 2013-07-03T14:40:22Z Indexed on 2013/07/03 17:19 UTC
Read the original article Hit count: 392

Filed under:
|
|
|
|

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.

© Game Development or respective owner

Related posts about directx

Related posts about sound