public void Stop(PlaySoundHandle handle) { if (handle.VoiceIndex >= 0 && handle.VoiceIndex < _sourceVoices.Length) { _sourceVoices[handle.VoiceIndex].StopVerified(handle.VoiceCounter); } }
public bool TryPlaySound(MemoryChunk <byte> soundData, out PlaySoundHandle handle) { Unsafe.SkipInit(out handle); var index = GetNextVoiceIndex(); if (index == -1) { Logger.Warning <XAudio2Device>("Can't play sound, all voices are being used."); } else { Logger.Trace <XAudio2Device>($"Playing on source voice: {index}"); var counter = _sourceVoices[index].Play(soundData, default); handle = new PlaySoundHandle(index, counter); return(true); } return(false); }