From 853c201f96fc8a5454811f1fd15ab01831b83dcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9drik=20Fuoco?= Date: Wed, 17 Dec 2025 10:20:44 -0500 Subject: [PATCH 1/2] fix logs in multithread env MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Cédrik Fuoco --- src/lib/image/MovieFFMpeg/MovieFFMpeg.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/lib/image/MovieFFMpeg/MovieFFMpeg.cpp b/src/lib/image/MovieFFMpeg/MovieFFMpeg.cpp index 99969a1a5..43ca6c259 100644 --- a/src/lib/image/MovieFFMpeg/MovieFFMpeg.cpp +++ b/src/lib/image/MovieFFMpeg/MovieFFMpeg.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -1420,14 +1421,12 @@ namespace TwkMovie { if (!videoToolboxInit(avCodec, avCodecContext, hardwareContext)) { - static bool hasDisplayedError = false; - if (!hasDisplayedError) - { + static std::once_flag warnOnce; + std::call_once(warnOnce, []() { std::cout << "WARNING: Hardware decoder is not available " "or failed to intialize." << std::endl; - hasDisplayedError = true; - } + }); } } #endif @@ -3785,14 +3784,12 @@ namespace TwkMovie const AVPixFmtDescriptor* desc = av_pix_fmt_desc_get(nativeFormat); if (!desc && nativeFormat == AV_PIX_FMT_NONE) { - static bool warned = false; - if (!warned) - { + static std::once_flag warnOnce; + std::call_once(warnOnce, [this]() { std::cout << "WARNING: FFmpeg detected pixel format " "AV_PIX_FMT_NONE for frames in " << m_filename << ". Using fallback pixel format: " << av_get_pix_fmt_name(m_pxlFormatOnOpen) << std::endl; - warned = true; - } + }); // Use the pixel format detected when the file was opened as a // fallback. Assumes that m_pxlFormatOnOpen is set because the file // was opened. From bf0a501c3babc3c6325a201cc1534bcc90a32e42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9drik=20Fuoco?= Date: Fri, 9 Jan 2026 09:03:26 -0500 Subject: [PATCH 2/2] pre-commit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Cédrik Fuoco --- src/lib/image/MovieFFMpeg/MovieFFMpeg.cpp | 25 ++++++++++++++--------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/lib/image/MovieFFMpeg/MovieFFMpeg.cpp b/src/lib/image/MovieFFMpeg/MovieFFMpeg.cpp index 43ca6c259..febc326e1 100644 --- a/src/lib/image/MovieFFMpeg/MovieFFMpeg.cpp +++ b/src/lib/image/MovieFFMpeg/MovieFFMpeg.cpp @@ -1422,11 +1422,13 @@ namespace TwkMovie if (!videoToolboxInit(avCodec, avCodecContext, hardwareContext)) { static std::once_flag warnOnce; - std::call_once(warnOnce, []() { - std::cout << "WARNING: Hardware decoder is not available " - "or failed to intialize." - << std::endl; - }); + std::call_once(warnOnce, + []() + { + std::cout << "WARNING: Hardware decoder is not available " + "or failed to intialize." + << std::endl; + }); } } #endif @@ -3785,11 +3787,14 @@ namespace TwkMovie if (!desc && nativeFormat == AV_PIX_FMT_NONE) { static std::once_flag warnOnce; - std::call_once(warnOnce, [this]() { - std::cout << "WARNING: FFmpeg detected pixel format " - "AV_PIX_FMT_NONE for frames in " - << m_filename << ". Using fallback pixel format: " << av_get_pix_fmt_name(m_pxlFormatOnOpen) << std::endl; - }); + std::call_once(warnOnce, + [this]() + { + std::cout << "WARNING: FFmpeg detected pixel format " + "AV_PIX_FMT_NONE for frames in " + << m_filename << ". Using fallback pixel format: " << av_get_pix_fmt_name(m_pxlFormatOnOpen) + << std::endl; + }); // Use the pixel format detected when the file was opened as a // fallback. Assumes that m_pxlFormatOnOpen is set because the file // was opened.