コード例 #1
0
ファイル: XAudio2Driver.cs プロジェクト: MiLO83/libsnesdotnet
        public bool TryPlay(AudioUpdatedEventArgs e)
        {
            AssertUndisposed();

            if (!_isBusy.TryAcquire(true)) { return false; }

            if (_isPaused)
            {
                _sourceVoice.Start();
                _isPaused = false;
            }

            _audioBuffer.AudioData = _bufferStreams[_bufferCursor];
            _audioBuffer.AudioBytes = (int)e.SampleCount * 4;
            e.AudioBuffer.ReadRange<byte>(_buffers[_bufferCursor], 0, _audioBuffer.AudioBytes);
            _sourceVoice.SubmitSourceBuffer(_audioBuffer);
            _bufferCursor = _bufferCursor >= BufferCount -1 ? 0 : _bufferCursor + 1;

            if (_sourceVoice.State.BuffersQueued >= BufferCount)
            {
                _isBusy.Value = true;
            }

            if (_sourceVoice.State.BuffersQueued < BufferCount)
            {
                _isBusy.Value = false;
            }

            return true;
        }
コード例 #2
0
ファイル: CoreDriver.cs プロジェクト: MiLO83/libsnesdotnet
 void Snes_AudioUpdated(object sender, AudioUpdatedEventArgs e)
 {
     if (_isAudioSynced)
     {
         _audioDriver.Play(e);
     }
     else
     {
         _audioDriver.TryPlay(e);
     }
 }
コード例 #3
0
ファイル: XAudio2Driver.cs プロジェクト: MiLO83/libsnesdotnet
 public void Play(AudioUpdatedEventArgs e)
 {
     while (!TryPlay(e))
     {
         _isBusy.WaitWhile();
     }
 }