コード例 #1
0
ファイル: Sound.cs プロジェクト: magicono43/BizHawk
        internal void HandleInitializationOrUnderrun(bool isUnderrun, ref int samplesNeeded)
        {
            // Fill device buffer with silence but leave enough room for one frame
            int samplesPerFrame = (int)Math.Round(SampleRate / (double)Global.Emulator.VsyncRate());
            int silenceSamples  = Math.Max(samplesNeeded - samplesPerFrame, 0);

            _outputDevice.WriteSamples(new short[silenceSamples * 2], 0, silenceSamples);
            samplesNeeded -= silenceSamples;

            if (isUnderrun)
            {
                if (LogUnderruns)
                {
                    Console.WriteLine("Sound underrun detected!");
                }
                _outputProvider.OnVolatility();
            }
        }