refactor: DeckLinkReceiver readability and error handling

DeckLinkReceiver:
- Group private members with section comments (SDK objects / sync / frame state)
- Change wait_for_format timeout param from uint64_t to int (matches
  std::chrono::milliseconds and all call sites)

decklinkin main.cpp:
- Wrap start_capture in try/catch — logs error and returns cleanly on
  device init failure (consistent with NDIInNode pattern)
- Remove redundant zero-init on frame_buf (vector<uint8_t> zero-inits anyway)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
JohannesItten
2026-07-06 01:38:13 +03:00
parent 640271384e
commit e335461aac
2 changed files with 19 additions and 12 deletions
+13 -9
View File
@@ -8,15 +8,19 @@
class DeckLinkInNode : public dmf::NodeBase {
void run() override {
dmf::DeckLinkReceiver receiver;
log("Available DeckLink devices:");
for (const auto& d : receiver.devices)
log(" %u) %s", d.index, d.name.c_str());
const uint32_t device_index = config().value("device_index", 0u);
receiver.start_capture(device_index);
log("Capturing from: %s", receiver.devices[device_index].name.c_str());
dmf::DeckLinkReceiver receiver;
try {
log("Available DeckLink devices:");
for (const auto& d : receiver.devices)
log(" %u) %s", d.index, d.name.c_str());
receiver.start_capture(device_index);
log("Capturing from: %s", receiver.devices[device_index].name.c_str());
} catch (const std::runtime_error& e) {
log("DeckLink init error: %s", e.what());
return;
}
if (!receiver.wait_for_format(5000)) {
log("Timeout waiting for format detection");
@@ -55,7 +59,7 @@ class DeckLinkInNode : public dmf::NodeBase {
uint64_t video_index = mxlGetCurrentIndex(&video_rate);
log("start video_index=%llu", video_index);
std::vector<uint8_t> frame_buf(static_cast<size_t>(video_stride) * static_cast<size_t>(height), 0);
std::vector<uint8_t> frame_buf(static_cast<size_t>(video_stride) * static_cast<size_t>(height));
while (dmf::g_running.load(std::memory_order_relaxed)) {
if (!receiver.wait_for_frame(frame_buf.data(), video_stride, width, height)) break;