From d957ce74ae50643bea0a6c094cc01429e362a70e Mon Sep 17 00:00:00 2001 From: Wild Dragon Dev Date: Thu, 4 Jun 2026 01:09:08 +0000 Subject: [PATCH] fix(decklink-bridge): avoid redundant fc_writer_open calls in reopen_slot --- services/capture/decklink-bridge/main.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/services/capture/decklink-bridge/main.cpp b/services/capture/decklink-bridge/main.cpp index f46cd5d..fa81867 100644 --- a/services/capture/decklink-bridge/main.cpp +++ b/services/capture/decklink-bridge/main.cpp @@ -360,10 +360,22 @@ private: /* Serialize with frame writes and any concurrent reopen_slot() so we * never double-free fc_writer or write to a half-closed one. */ pthread_mutex_lock(&m_ds->fc_lock); + + // If already open with same format, do nothing. if (m_ds->fc_writer) { + fc_hdr_t *h = (fc_hdr_t *)m_ds->fc_writer->base; + if (h->width == (uint32_t)m_ds->width && + h->height == (uint32_t)m_ds->height && + h->fps_num == (uint32_t)m_ds->fps_num && + h->fps_den == (uint32_t)m_ds->fps_den) + { + pthread_mutex_unlock(&m_ds->fc_lock); + return; + } fc_writer_close(m_ds->fc_writer); m_ds->fc_writer = nullptr; } + if (m_ds->width > 0 && m_ds->height > 0 && m_ds->fps_num > 0) { m_ds->fc_writer = fc_writer_open( m_ds->fc_url.c_str(),