Пример #1
0
        /// <summary>
        /// If CanFillis true with this method you can fill the next free buffer
        /// </summary>
        /// <param name="pcm">The pointer to PCM data</param>
        /// <param name="bufferSize">The full size in bytes of PCM data</param>
        /// <param name="type">If this buffer is the last buffer of the stream set to true, if not false</param>
        protected void FillBuffer(IntPtr pcm, int bufferSize, AudioLayer.BufferType type)
        {
            if (bufferSize > nativeBufferSizeBytes)
            {
                Logger.Error("Provided buffer size is bigger than native buffer. Data will be cut.");
                bufferSize = nativeBufferSizeBytes;
            }

            var buffer = freeBuffers.Dequeue();

            AudioLayer.SourceQueueBuffer(SoundInstance.Source, buffer, pcm, bufferSize, type);
            if (readyToPlay)
            {
                return;
            }

            prebufferedCount++;
            if (prebufferedCount < prebufferedTarget)
            {
                return;
            }
            readyToPlay = true;
            ReadyToPlay.TrySetResult(true);
        }