private void DeckLinkInput_CaptureChanged(bool formatChanged) { logger.Debug("DeckLinkInput_StateChanged(...) " + deckLinkInput.State + " " + formatChanged); var state = deckLinkInput.State; if (formatChanged) { if (state == MediaToolkit.DeckLink.CaptureState.Starting) {// new format... InitRenderSession(); } else if (state == MediaToolkit.DeckLink.CaptureState.Capturing) {// new format, restart media renderers... CloseRenderSession(); InitRenderSession(); renderSession?.Start(); } } else { if (state == MediaToolkit.DeckLink.CaptureState.Capturing) { renderSession?.Start(); } else if (state == MediaToolkit.DeckLink.CaptureState.Stopped) { deckLinkInput.Shutdown(); CloseRenderSession(); syncContext.Send(_ => { var errorCode = deckLinkInput.ErrorCode; if (errorCode != 0) { var dialogResult = MessageBox.Show("Device stopped with error: " + errorCode, "", MessageBoxButtons.RetryCancel); if (dialogResult == DialogResult.Retry) { deckLinkInput.StartCapture(currentDevice, currentDisplayMode); return; } } OnCaptureStopped(); }, null); } GC.Collect(); } }
private void DeckLinkInput_CaptureChanged(bool formatChanged) { logger.Debug("DeckLinkInput_StateChanged(...) " + deckLinkInput.State + " " + formatChanged); var state = deckLinkInput.State; if (formatChanged) { if (state == DeckLink.CaptureState.Starting) {// new format... AudioRendererArgs audioArgs = GetAudioRenderArgs(); VideoRendererArgs videoArgs = GetVideoRenderArgs(); renderSession?.Setup(videoArgs, audioArgs); OnCaptureInitialized(); } else if (state == DeckLink.CaptureState.Capturing) {// new format, restart media renderers... if (renderSession != null) { renderSession.Close(); AudioRendererArgs audioArgs = GetAudioRenderArgs(); VideoRendererArgs videoArgs = GetVideoRenderArgs(); renderSession.Setup(videoArgs, audioArgs); OnCaptureInitialized(); renderSession.Start(); } } } else { if (state == DeckLink.CaptureState.Capturing) { renderSession?.Start(); OnCaptureStarted(); } else if (state == DeckLink.CaptureState.Stopped) { errorCode = deckLinkInput.ErrorCode; deckLinkInput.Shutdown(); renderSession?.Close(); OnCaptureStopped(); } } }