public void Update(GameTime gameTime) { OpenALSoundController.ActiveLock.EnterUpgradeableReadLock(); for (int index = this.activeSoundEffects.Count - 1; index >= 0; --index) { SoundEffectInstance soundEffectInstance = this.activeSoundEffects[index]; if (soundEffectInstance.RefreshState() || soundEffectInstance.IsDisposed) { OpenALSoundController.ActiveLock.EnterWriteLock(); if (!soundEffectInstance.IsDisposed) { soundEffectInstance.Dispose(); } this.activeSoundEffects.RemoveAt(index); OpenALSoundController.ActiveLock.ExitWriteLock(); } } OpenALSoundController.ActiveLock.ExitUpgradeableReadLock(); float num = (float)gameTime.ElapsedGameTime.TotalSeconds; OpenALSoundController.AllocationsLock.EnterUpgradeableReadLock(); foreach (KeyValuePair <SoundEffect, OpenALSoundController.BufferAllocation> keyValuePair in this.allocatedBuffers) { if (keyValuePair.Value.SourceCount == 0) { keyValuePair.Value.SinceUnused += num; if ((double)keyValuePair.Value.SinceUnused >= 10.0) { this.staleAllocations.Add(keyValuePair); } } } foreach (KeyValuePair <SoundEffect, OpenALSoundController.BufferAllocation> keyValuePair in this.staleAllocations) { OpenALSoundController.AllocationsLock.EnterWriteLock(); this.allocatedBuffers.Remove(keyValuePair.Key); OpenALSoundController.AllocationsLock.ExitWriteLock(); this.freeBuffers.Push(keyValuePair.Value.BufferId); } OpenALSoundController.AllocationsLock.ExitUpgradeableReadLock(); this.TidySources(); this.TidyBuffers(); this.staleAllocations.Clear(); }