コード例 #1
0
        /// <summary>
        /// Stops playing the DynamicSoundEffectInstance.
        /// If the <paramref name="immediate"/> parameter is false, this call has no effect.
        /// </summary>
        /// <remarks>
        /// Calling this also releases all queued buffers.
        /// </remarks>
        /// <param name="immediate">When set to false, this call has no effect.</param>
        public override void Stop(bool immediate)
        {
            AssertNotDisposed();

            if (immediate)
            {
                DynamicSoundEffectInstanceManager.RemoveInstance(this);

                PlatformStop();
                _state = SoundState.Stopped;

                SoundEffectInstancePool.Add(this);
            }
        }
コード例 #2
0
        private void PlatformDispose(bool disposing)
        {
            // SFXI disposal handles buffer detachment and source recycling
            base.Dispose(disposing);

            if (disposing)
            {
                while (_queuedBuffers.Count > 0)
                {
                    var buffer = _queuedBuffers.Dequeue();
                    buffer.Dispose();
                }

                DynamicSoundEffectInstanceManager.RemoveInstance(this);
            }
        }
コード例 #3
0
        /// <summary>
        /// Plays or resumes the DynamicSoundEffectInstance.
        /// </summary>
        public override void Play()
        {
            AssertNotDisposed();

            if (_state != SoundState.Playing)
            {
                // Ensure that the volume reflects master volume, which is done by the setter.
                Volume = Volume;

                // Add the instance to the pool
                if (!SoundEffectInstancePool.SoundsAvailable)
                {
                    throw new InstancePlayLimitException();
                }
                SoundEffectInstancePool.Remove(this);

                PlatformPlay();
                _state = SoundState.Playing;

                CheckBufferCount();
                DynamicSoundEffectInstanceManager.AddInstance(this);
            }
        }
コード例 #4
0
        private void PlatformDispose(bool disposing)
        {
            // Stop the source and bind null buffer so that it can be recycled
            AL.GetError();
            if (AL.IsSource(SourceId))
            {
                AL.SourceStop(SourceId);
                AL.Source(SourceId, ALSourcei.Buffer, 0);
                ALHelper.CheckError("Failed to stop the source.");
                controller.RecycleSource(SourceId);
            }

            if (disposing)
            {
                while (_queuedBuffers.Count > 0)
                {
                    var buffer = _queuedBuffers.Dequeue();
                    buffer.Dispose();
                }

                DynamicSoundEffectInstanceManager.RemoveInstance(this);
            }
        }