Esempio n. 1
0
        protected virtual bool ReadAndQueueBuffer()
        {
            // Initially accessed from Main thread, then from Playing thread

            //Debug.WriteLine("Get samples from provider");

            // Read samples from Provider
            _watch.Restart();
            bool filled = _sampleProvider.Fill(_buffer);

            _watch.Stop();
            if (!filled)
            {
                return(false);         // provider failed or wants to stop the engine
            }
            //Debug.WriteLine("Sample buffer filled in {0} ms. Audio buffer: {1}", _watch.ElapsedMilliseconds, _currentAudioBuffer);
            if (_watch.ElapsedMilliseconds >= _bufferLengthMs * 9 / 10)
            {
                Debug.WriteLine("Warning! Sample buffer filled in {0} ms", _watch.ElapsedMilliseconds);
            }

            // Get free audio buffer and copy data from sample buffer
            SA.AudioBuffer audioBuffer = _audioBuffers[_currentAudioBuffer];
            audioBuffer.BufferData(_buffer, _audioFormat);
            // Queue audioBuffer to engine source
            //Debug.WriteLine("Queue audio buffer");
            _source.QueueBuffer(audioBuffer);

            // Switch to next audio buffer
            _currentAudioBuffer += 1;
            _currentAudioBuffer %= _audioBufferCount;

            return(true);
        }
Esempio n. 2
0
 /// <summary>
 /// Queries to buffer to the playback queue
 /// </summary>
 /// <param name="buffer">the buffer to submit</param>
 public abstract void QueueBuffer(AudioBuffer buffer);