Example #1
0
        private bool RefillBuffer(byte[] buffer, int sampleOffset, int bufferSize)
        {
            int read = 0;

            if (_secondaryBuffer.IsBufferLost())
            {
                _secondaryBuffer.Restore();
            }

            if (_playbackState == SoundOut.PlaybackState.Paused)
            {
                Array.Clear(buffer, 0, buffer.Length);
                read = bufferSize;
            }
            else
            {
                if (_source != null)
                {
                    read = _source.Read(buffer, 0, bufferSize);
                }
                else
                {
                    return(false);
                }
            }

            if (read > 0)
            {
                return(_secondaryBuffer.Write(buffer, sampleOffset, bufferSize));
            }
            else
            {
                return(false);
            }
        }