From a3cd45cc4930e3a2022a7cece053828240be98dc Mon Sep 17 00:00:00 2001 From: Johanness Date: Sat, 30 May 2026 23:18:02 +0300 Subject: [PATCH] decklink-out: add mode support check, limit CreateVideoFrame error spam --- nodes/decklink-out/src/decklink_out_node.cpp | 27 +++++++++++++++++--- nodes/decklink-out/src/decklink_out_node.hpp | 1 + 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/nodes/decklink-out/src/decklink_out_node.cpp b/nodes/decklink-out/src/decklink_out_node.cpp index d358ad9..1374256 100644 --- a/nodes/decklink-out/src/decklink_out_node.cpp +++ b/nodes/decklink-out/src/decklink_out_node.cpp @@ -126,6 +126,20 @@ bool DeckLinkOutNode::open_device() { callback_ = std::make_unique(*this); output_->SetScheduledFrameCompletionCallback(callback_.get()); + { + BMDDisplayMode actual_mode = bmdModeUnknown; + bool supported = false; + auto hr = output_->DoesSupportVideoMode(bmdVideoConnectionUnspecified, display_mode_, bmdFormat10BitYUV, + bmdNoVideoOutputConversion, bmdSupportedVideoModeDefault, &actual_mode, &supported); + if (hr == S_OK) { + spdlog::info("DeckLink-out: mode 0x{:x} V210 supported={} actual=0x{:x}", + static_cast(display_mode_), supported, static_cast(actual_mode)); + if (!supported) { + spdlog::error("DeckLink-out: display mode not supported for V210 output"); + } + } + } + if (output_->EnableVideoOutput(display_mode_, bmdVideoOutputFlagDefault) != S_OK) { spdlog::error("DeckLink-out: failed to enable video output"); return false; @@ -189,17 +203,22 @@ void DeckLinkOutNode::schedule_frame(void* mxl_payload, long width, long height, int32_t out_row_bytes = 0; HRESULT row_hr = output_->RowBytesForPixelFormat(bmdFormat10BitYUV, width, &out_row_bytes); if (row_hr != S_OK || out_row_bytes <= 0) { - spdlog::warn("DeckLink-out: RowBytesForPixelFormat failed hr=0x{:08x}, using fallback", static_cast(row_hr)); + spdlog::warn("DeckLink-out: RowBytesForPixelFormat failed hr=0x{:08x}", static_cast(row_hr)); out_row_bytes = ((width + 5) / 6) * 16; } - spdlog::debug("DeckLink-out: creating frame {}x{} row_bytes={}", width, height, out_row_bytes); IDeckLinkMutableVideoFrame* frame = nullptr; HRESULT hr = output_->CreateVideoFrame(width, height, out_row_bytes, bmdFormat10BitYUV, bmdFrameFlagDefault, &frame); if (hr != S_OK || !frame) { - spdlog::warn("DeckLink-out: failed to create output frame {}x{} row_bytes={} hr=0x{:08x}", - width, height, out_row_bytes, static_cast(hr)); + if (create_fail_count_ < 5) { + spdlog::error("DeckLink-out: CreateVideoFrame {}x{} row_bytes={} fmt=V210 hr=0x{:08x}", + width, height, out_row_bytes, static_cast(hr)); + create_fail_count_++; + } + if (create_fail_count_ == 5) { + spdlog::error("DeckLink-out: suppressing further CreateVideoFrame errors"); + } return; } diff --git a/nodes/decklink-out/src/decklink_out_node.hpp b/nodes/decklink-out/src/decklink_out_node.hpp index 1dbcf8a..4a369db 100644 --- a/nodes/decklink-out/src/decklink_out_node.hpp +++ b/nodes/decklink-out/src/decklink_out_node.hpp @@ -57,6 +57,7 @@ private: BMDTimeScale time_scale_ = 50000; std::atomic playing_{false}; + int create_fail_count_ = 0; bool is_interlaced_ = false; long out_width_ = 1920; long out_height_ = 1080;