コード例 #1
0
ファイル: SoundEffect.cs プロジェクト: yongweisun/paradox
        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);
        }
コード例 #2
0
        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();
            }
        }
コード例 #3
0
 internal override void DestroyImpl()
 {
     AudioEngine.UnregisterSound(this);
     // mediaInputStream is disposed by AudioEngine.ProcessPlayerClosed()
 }