From b3c2e74d0f294ce17655c11f6d6d0effdebeb049 Mon Sep 17 00:00:00 2001 From: James Park Date: Sun, 3 Mar 2019 10:05:09 -0800 Subject: [PATCH] win-dshow: Fix "Highest FPS" algorithm MatcherClosestFrameRateSelector updates best_match as a side effect of visiting every VideoInfo instance, but CapsMatch uses std::any_of, which will stop iterating prematurely on first match. This means that the highest FPS is not selected. This change switches to a for loop that doesn't exit early. --- plugins/win-dshow/win-dshow.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/win-dshow/win-dshow.cpp b/plugins/win-dshow/win-dshow.cpp index 03bdbba91..804a393a7 100644 --- a/plugins/win-dshow/win-dshow.cpp +++ b/plugins/win-dshow/win-dshow.cpp @@ -671,12 +671,12 @@ static inline bool CapsMatch(const VideoInfo &info, F&& f, Fs ... fs) template static bool CapsMatch(const VideoDevice &dev, F ... fs) { - auto matcher = [&](const VideoInfo &info) - { - return CapsMatch(info, fs ...); - }; - - return any_of(begin(dev.caps), end(dev.caps), matcher); + // no early exit, trigger all side effects. + bool match = false; + for (const VideoInfo &info : dev.caps) + if (CapsMatch(info, fs ...)) + match = true; + return match; } static inline bool MatcherMatchVideoFormat(VideoFormat format,