protected override void Destroy() { base.Destroy(); if (IsDisposed) { return; } // Stop and dispose all the instances foreach (var seInstance in Instances.ToArray()) { seInstance.Dispose(); } DestroyImpl(); // free the audio data. if (nativeDataBuffer != IntPtr.Zero) { Utilities.FreeMemory(nativeDataBuffer); nativeDataBuffer = IntPtr.Zero; WaveDataPtr = IntPtr.Zero; WaveDataSize = 0; } // Unregister this from the sound to dispose by the audio engine AudioEngine.UnregisterSound(this); }
internal override void DestroyImpl() { AudioEngine.UnregisterSound(this); IsDisposing = true; lock (WorkerLock) // avoid to have simultaneous destroy and submit buffer (via BufferNeeded of working thread). { base.DestroyImpl(); } Interlocked.Decrement(ref numberOfInstances); if (numberOfInstances == 0) { awakeWorkerThread.Set(); if (!workerTask.Wait(500)) { throw new AudioSystemInternalException("The DynamicSoundEffectInstance worker did not complete in allowed time."); } awakeWorkerThread.Dispose(); } }
internal override void DestroyImpl() { AudioEngine.UnregisterSound(this); // mediaInputStream is disposed by AudioEngine.ProcessPlayerClosed() }