fix(decklink-bridge): avoid redundant fc_writer_open calls in reopen_slot

This commit is contained in:
Wild Dragon Dev 2026-06-04 01:09:08 +00:00
parent 58c058b10c
commit d957ce74ae

View file

@ -360,10 +360,22 @@ private:
/* Serialize with frame writes and any concurrent reopen_slot() so we /* Serialize with frame writes and any concurrent reopen_slot() so we
* never double-free fc_writer or write to a half-closed one. */ * never double-free fc_writer or write to a half-closed one. */
pthread_mutex_lock(&m_ds->fc_lock); pthread_mutex_lock(&m_ds->fc_lock);
// If already open with same format, do nothing.
if (m_ds->fc_writer) { 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); fc_writer_close(m_ds->fc_writer);
m_ds->fc_writer = nullptr; m_ds->fc_writer = nullptr;
} }
if (m_ds->width > 0 && m_ds->height > 0 && m_ds->fps_num > 0) { if (m_ds->width > 0 && m_ds->height > 0 && m_ds->fps_num > 0) {
m_ds->fc_writer = fc_writer_open( m_ds->fc_writer = fc_writer_open(
m_ds->fc_url.c_str(), m_ds->fc_url.c_str(),