diff --git a/BizHawk.Client.EmuHawk/MainForm.cs b/BizHawk.Client.EmuHawk/MainForm.cs index f8cff1ccea..76731a31d4 100644 --- a/BizHawk.Client.EmuHawk/MainForm.cs +++ b/BizHawk.Client.EmuHawk/MainForm.cs @@ -726,15 +726,7 @@ namespace BizHawk.Client.EmuHawk set { Global.Emulator = value; - if (Global.Emulator.HasVideoProvider()) - { - _currentVideoProvider = Global.Emulator.AsVideoProvider(); - } - else - { - _currentVideoProvider = NullVideo.Instance; - } - + _currentVideoProvider = Global.Emulator.AsVideoProviderOrDefault(); _currentSoundProvider = Global.Emulator.AsSoundProviderOrDefault(); } } diff --git a/BizHawk.Emulation.Common/Extensions.cs b/BizHawk.Emulation.Common/Extensions.cs index 3ffa04bdaf..75b268ce33 100644 --- a/BizHawk.Emulation.Common/Extensions.cs +++ b/BizHawk.Emulation.Common/Extensions.cs @@ -34,6 +34,17 @@ namespace BizHawk.Emulation.Common.IEmulatorExtensions return core.ServiceProvider.GetService(); } + /// + /// Returns the core's VideoProvider, or a suitable dummy provider + /// + /// + /// + public static IVideoProvider AsVideoProviderOrDefault(this IEmulator core) + { + return core.ServiceProvider.GetService() + ?? NullVideo.Instance; + } + public static bool HasSoundProvider(this IEmulator core) { if (core == null)