private static void InitScreenCapture() { if (_screenCapture != null && !_screenCapture.IsDisposed()) { // Screen capture already initialized return; } try { LOG.Info($"Initializing screen capture for {SettingsManager.CaptureMethod}"); switch (SettingsManager.CaptureMethod) { case CaptureMethod.DX9: _screenCapture = new DX9ScreenCapture(SettingsManager.MonitorIndex, SettingsManager.HyperionWidth, SettingsManager.HyperionHeight, SettingsManager.CaptureInterval); break; case CaptureMethod.DX11: _screenCapture = new DX11ScreenCapture(SettingsManager.Dx11AdapterIndex, SettingsManager.Dx11MonitorIndex, SettingsManager.Dx11ImageScalingFactor, SettingsManager.Dx11MaxFps, SettingsManager.Dx11FrameCaptureTimeout); break; default: throw new NotImplementedException($"The capture method {SettingsManager.CaptureMethod} is not supported yet"); } LOG.Info("Screen capture initialized"); } catch (Exception ex) { throw new Exception("Failed to initialize screen capture: " + ex.Message, ex); } }
private void InitScreenCapture() { if (_screenCapture != null && !_screenCapture.IsDisposed()) { // Screen capture already initialized. Ignoring request. return; } try { LOG.Info($"{this}: Initializing screen capture"); _screenCapture.Initialize(); LOG.Info($"{this}: Screen capture initialized"); } catch (Exception ex) { _screenCapture?.Dispose(); throw new Exception("Failed to initialize screen capture: " + ex.Message, ex); } }