private void ReinitIfNoAudioConsumed(bool paused) { const double reinitTime = 0.25; double worldTime = World.Time.ElapsedTime; ulong audioOutputTimeInFrames = AudioNativeCalls.GetAudioOutputTimeInFrames(); bool audioConsumed = audioOutputTimeInFrames != m_lastAudioOutputTimeInFrames; bool audioNeedsReinit = worldTime - m_lastWorldTimeAudioConsumed >= reinitTime; if (!audioConsumed && !paused && audioNeedsReinit) { AudioNativeCalls.ReinitAudio(); } m_lastAudioOutputTimeInFrames = audioOutputTimeInFrames; m_lastWorldTimeAudioConsumed = (audioConsumed || paused || audioNeedsReinit) ? worldTime : m_lastWorldTimeAudioConsumed; }