Beispiel #1
0
        internal void OnUnderrun()
        {
            if (!IsStarted)
            {
                return;
            }

            if (LogUnderruns)
            {
                Console.WriteLine("Sound underrun detected!");
            }
            _outputProvider.OnVolatility();
        }
Beispiel #2
0
        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();
            }
        }