/// <summary> /// Releases all unmanaged resources used by the current instance. /// </summary> public void Dispose() { if (!IsDisposed) { IsDisposed = true; lock (children) { foreach (var item in children) { SoundEffectInstance soundEffectInstance = item.Target as SoundEffectInstance; if (soundEffectInstance != null) { soundEffectInstance.ParentDisposed(); } } children.Clear(); VoicePool.Release(); VoicePool = null; } AudioBuffer.Stream.Dispose(); AudioBuffer = null; LoopedAudioBuffer = null; } }
/// <summary> /// Removes the specified pool from "unshared" list. /// </summary> /// <param name="pool">The pool to remove.</param> internal void RemoveUnshared(SourceVoicePool pool) { lock (sharedVoicePools) { unsharedVoicePools.Remove(pool); } }
/// <summary> /// Gets the <see cref="SourceVoicePool"/> for the specified wave format. /// </summary> /// <param name="waveFormat">The wave format of the requested source voice pool.</param> /// <returns>The source voice pool for the provided wave format.</returns> public SourceVoicePool GetVoicePool(WaveFormat waveFormat) { lock (sharedVoicePools) { var waveKey = MakeWaveFormatKey(waveFormat); SourceVoicePool pool; if (waveKey == 0) { pool = new SourceVoicePool(this, waveFormat, false); unsharedVoicePools.Add(pool); } else { if (!sharedVoicePools.TryGetValue(waveKey, out pool)) { sharedVoicePools[waveKey] = pool = new SourceVoicePool(this, waveFormat, true); } } return(pool); } }