From 24053f4a9ccd49fb7fa64fa3983bfea527c6d8ff Mon Sep 17 00:00:00 2001 From: jp9000 Date: Thu, 19 Mar 2015 16:03:09 -0700 Subject: [PATCH] win-dshow: Fix bad settings causing frozen video If the settings are reset to defaults or if the settings are just bad, the video would get stuck on the last frame that was displayed, which feels a bit awkward. Best to make it stop video output entirely rather than get stuck on the last video frame. --- plugins/win-dshow/win-dshow.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/plugins/win-dshow/win-dshow.cpp b/plugins/win-dshow/win-dshow.cpp index 8cfe357a9..6f85680b3 100644 --- a/plugins/win-dshow/win-dshow.cpp +++ b/plugins/win-dshow/win-dshow.cpp @@ -232,7 +232,7 @@ struct DShowInput { void SetActive(bool active); inline enum video_colorspace GetColorSpace(obs_data_t *settings) const; inline enum video_range_type GetColorRange(obs_data_t *settings) const; - inline void Activate(obs_data_t *settings); + inline bool Activate(obs_data_t *settings); inline void Deactivate(); inline void SetupBuffering(obs_data_t *settings); @@ -288,7 +288,10 @@ void DShowInput::DShowLoop() { obs_data_t *settings; settings = obs_source_get_settings(source); - Activate(settings); + if (!Activate(settings)) { + obs_source_output_video(source, + nullptr); + } obs_data_release(settings); break; } @@ -863,15 +866,15 @@ inline enum video_range_type DShowInput::GetColorRange( VIDEO_RANGE_FULL : VIDEO_RANGE_PARTIAL; } -inline void DShowInput::Activate(obs_data_t *settings) +inline bool DShowInput::Activate(obs_data_t *settings) { if (!device.ResetGraph()) - return; + return false; if (!UpdateVideoConfig(settings)) { blog(LOG_WARNING, "%s: Video configuration failed", obs_source_get_name(source)); - return; + return false; } if (!UpdateAudioConfig(settings)) @@ -879,10 +882,10 @@ inline void DShowInput::Activate(obs_data_t *settings) "audio", obs_source_get_name(source)); if (!device.ConnectFilters()) - return; + return false; if (device.Start() != Result::Success) - return; + return false; enum video_colorspace cs = GetColorSpace(settings); @@ -895,6 +898,8 @@ inline void DShowInput::Activate(obs_data_t *settings) blog(LOG_ERROR, "Failed to get video format parameters for " \ "video format %u", cs); } + + return true; } inline void DShowInput::Deactivate()