fix(decklink-bridge): prevent redundant fc_writer_open loops via last_format tracking
This commit is contained in:
parent
d957ce74ae
commit
5b72ee167d
1 changed files with 20 additions and 10 deletions
|
|
@ -107,6 +107,10 @@ struct DeviceState {
|
|||
int height = 0;
|
||||
int fps_num = 0;
|
||||
int fps_den = 1;
|
||||
int last_width = 0;
|
||||
int last_height = 0;
|
||||
int last_fps_num = 0;
|
||||
int last_fps_den = 1;
|
||||
bool interlaced = false;
|
||||
std::atomic<bool> signal_reported{false};
|
||||
|
||||
|
|
@ -362,16 +366,17 @@ private:
|
|||
pthread_mutex_lock(&m_ds->fc_lock);
|
||||
|
||||
// If already open with same format, do nothing.
|
||||
if (m_ds->fc_writer &&
|
||||
m_ds->width == m_ds->last_width &&
|
||||
m_ds->height == m_ds->last_height &&
|
||||
m_ds->fps_num == m_ds->last_fps_num &&
|
||||
m_ds->fps_den == m_ds->last_fps_den)
|
||||
{
|
||||
pthread_mutex_unlock(&m_ds->fc_lock);
|
||||
return;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
@ -382,7 +387,12 @@ private:
|
|||
m_ds->slot_id.c_str(),
|
||||
(uint32_t)m_ds->width, (uint32_t)m_ds->height,
|
||||
(uint32_t)m_ds->fps_num, (uint32_t)m_ds->fps_den);
|
||||
if (!m_ds->fc_writer) {
|
||||
if (m_ds->fc_writer) {
|
||||
m_ds->last_width = m_ds->width;
|
||||
m_ds->last_height = m_ds->height;
|
||||
m_ds->last_fps_num = m_ds->fps_num;
|
||||
m_ds->last_fps_den = m_ds->fps_den;
|
||||
} else {
|
||||
fprintf(stderr, "[decklink:%d] framecache unavailable\n",
|
||||
m_ds->device_idx);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue