예제 #1
0
        /// <summary>
        /// Sets the Bass inputstream and initializes the playbackbuffer.
        /// </summary>
        /// <param name="stream">New inputstream.</param>
        public void SetInputStream(BassStream stream)
        {
            ResetInputStream();

            _inputStream = stream;

            // If a Mixer has been created before, e.g. because of UpDownMixing,
            // use the mixer as output stream instead of using a Ringbuffer
            if (stream.BassInfo.ctype == BASSChannelType.BASS_CTYPE_STREAM_MIXER)
            {
                _outputStream = stream;
            }
            else
            {
                _buffer      = new AudioRingBuffer(stream.SampleRate, stream.Channels, _bufferSize);
                _streamEnded = false;
                _buffer.ResetPointers();

                CreateOutputStream();

                // Ensure prebuffering
                _updateThreadFinished.Reset();

                StartBufferUpdateThread();
                _updateThreadFinished.WaitOne();
            }

            CreateVizStream();
            _inputStreamInitialized = true;
        }
예제 #2
0
        /// <summary>
        /// Reclculates the visualization stream byte-offset according usersettings.
        /// </summary>
        private void UpdateVizLatencyCorrection()
        {
            BassPlayerSettings settings = Controller.GetSettings();

            _vizReadOffset      = InternalSettings.VizLatencyCorrectionRange.Add(settings.VizStreamLatencyCorrection);
            _vizReadOffsetBytes = AudioRingBuffer.CalculateLength(_inputStream.SampleRate, _inputStream.Channels, _vizReadOffset);

            Log.Debug("Vizstream reading offset: {0} ms", _vizReadOffset.TotalMilliseconds);
        }
예제 #3
0
        /// <summary>
        /// Sets the Bass inputstream and initializes the playbackbuffer.
        /// </summary>
        /// <param name="stream">New inputstream.</param>
        public void SetInputStream(BassStream stream)
        {
            ResetInputStream();

            _inputStream = stream;

            _buffer      = new AudioRingBuffer(stream.SampleRate, stream.Channels, _bufferSize);
            _streamEnded = false;
            _buffer.ResetPointers();

            CreateOutputStream();
            CreateVizStream();
            _inputStreamInitialized = true;

            // Ensure prebuffering
            _updateThreadFinished.Reset();

            StartBufferUpdateThread();
            _updateThreadFinished.WaitOne();
        }
예제 #4
0
        /// <summary>
        /// Resets the instance to its uninitialized state.
        /// </summary>
        public void ResetInputStream()
        {
            TerminateBufferUpdateThread();
            if (_inputStreamInitialized)
            {
                _inputStreamInitialized = false;

                _outputStream.Dispose();
                _outputStream = null;

                _vizStream.Dispose();
                _vizStream = null;

                _vizRawStream.Dispose();
                _vizRawStream = null;

                _buffer             = null;
                _inputStream        = null;
                _vizReadOffsetBytes = 0;
            }
        }