Пример #1
0
        /// <summary>
        /// Restarts streaming from the beginning.
        /// </summary>
        protected virtual void RestartInternal()
        {
            ReadyToPlay.TrySetResult(false);
            ReadyToPlay      = new TaskCompletionSource <bool>();
            readyToPlay      = false;
            prebufferedCount = 0;

            PrepareInternal();
        }
Пример #2
0
 /// <summary>
 /// Restarts streaming from the beginning.
 /// </summary>
 protected void Restart()
 {
     ReadyToPlay.TrySetResult(false);
     ReadyToPlay = new TaskCompletionSource <bool>();
     Ended.TrySetResult(false);
     Ended            = new TaskCompletionSource <bool>();
     readyToPlay      = false;
     prebufferedCount = 0;
 }
Пример #3
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)
        {
            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);
        }
Пример #4
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="endOfStream">If this buffer is the last buffer of the stream set to true, if not false</param>
        protected void FillBuffer(IntPtr pcm, int bufferSize, bool endOfStream)
        {
            var buffer = freeBuffers.Dequeue();

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

            prebufferedCount++;
            if (prebufferedCount > 1)
            {
                return;
            }

            readyToPlay = true;
            ReadyToPlay.TrySetResult(true);
        }
Пример #5
0
        /// <summary>
        /// If CanFillis true with this method you can fill the next free buffer
        /// </summary>
        /// <param name="pcm">The array containing 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 unsafe void FillBuffer(short[] pcm, int bufferSize, AudioLayer.BufferType type)
        {
            var buffer = freeBuffers.Dequeue();

            fixed(short *pcmBuffer = pcm)
            AudioLayer.SourceQueueBuffer(SoundInstance.Source, buffer, new IntPtr(pcmBuffer), bufferSize, type);

            if (readyToPlay)
            {
                return;
            }

            prebufferedCount++;
            if (prebufferedCount < prebufferedTarget)
            {
                return;
            }
            readyToPlay = true;
            ReadyToPlay.TrySetResult(true);
        }
Пример #6
0
    void Start()
    {
        ReadyToPlay   readyToPlay   = new ReadyToPlay(modeText, leaderboard);
        LevelSelecter levelSelecter = new LevelSelecter(modeText);
        GameRunner    gameRunner    = new GameRunner(blockMover, scoreboardFactory, audioPlayer);
        GamePauser    gamePauser    = new GamePauser(modeText, audioPlayer);
        GameEnder     gameEnder     = new GameEnder(modeText, blockField);
        GameRestarter gameRestarter = new GameRestarter(modeText, leaderboard);

        gameRunner.gravity = gravity;

        readyToPlay.LevelSelecter = levelSelecter;
        levelSelecter.GameRunner  = gameRunner;
        gameRunner.GamePauser     = gamePauser;
        gameRunner.GameEnder      = gameEnder;
        gameEnder.GameRestarter   = gameRestarter;
        gameRestarter.StartScreen = readyToPlay;

        readyToPlay.Show();
        currentMode = readyToPlay;
    }
Пример #7
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);
        }