Instead of holding the memory allocated to an AudioBuffer object, it's being destroyed as soon as it is submitted to the SourceVoice. This is against XAudio2 API which requests the memory to be allocated to it until the buffer in question has been played, since it doesn't create a copy of the buffer. The result of the premature destruction is the XAudio2 API reading memory to which it doesn't have access, creating distortions and memory access violations.
Instead of holding the memory allocated to an
AudioBuffer
object, it's being destroyed as soon as it is submitted to theSourceVoice
. This is against XAudio2 API which requests the memory to be allocated to it until the buffer in question has been played, since it doesn't create a copy of the buffer. The result of the premature destruction is the XAudio2 API reading memory to which it doesn't have access, creating distortions and memory access violations.