Exemplo n.º 1
0
        /// <summary>
        /// Attaches a new input pin which will run either in sync or async mode depending
        /// on its SyncMode property. Once attached, the sync mode must not change unless
        /// the pin is re-attached.
        /// </summary>
        public void SetInputPin(ISoundProvider source)
        {
            if (_bufferedProvider != null)
            {
                _bufferedProvider.BaseSoundProvider = null;
                _bufferedProvider.DiscardSamples();
                _bufferedProvider = null;
            }

            if (source == null)
            {
                return;
            }

            if (source.SyncMode == SyncSoundMode.Sync)
            {
                _bufferedProvider = _outputProvider;
            }
            else if (source.SyncMode == SyncSoundMode.Async)
            {
                _bufferedAsync.RecalculateMagic(_getCoreVsyncRateCallback());
                _bufferedProvider = _bufferedAsync;
            }
            else
            {
                throw new InvalidOperationException("Unsupported sync mode.");
            }

            _bufferedProvider.BaseSoundProvider = source;
        }
Exemplo n.º 2
0
        public void StopSound()
        {
            if (!IsStarted)
            {
                return;
            }

            _outputDevice.StopSound();

            _bufferedProvider?.DiscardSamples();

            SoundMaxBufferDeficitMs = 0;

            IsStarted = false;
        }
Exemplo n.º 3
0
        public void StopSound()
        {
            if (!IsStarted)
            {
                return;
            }

            _outputDevice.StopSound();

            if (_bufferedProvider != null)
            {
                _bufferedProvider.DiscardSamples();
            }

            Global.SoundMaxBufferDeficitMs = 0;

            IsStarted = false;
        }