Skip to content

Commit cdf4140

Browse files
committed
DeckLink disp sync: assert sched_frm min<max
\+ moved the stuff to a separate function
1 parent 6008230 commit cdf4140

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

src/video_display/decklink.cpp

+19-13
Original file line numberDiff line numberDiff line change
@@ -1106,6 +1106,24 @@ static void display_decklink_probe(struct device_info **available_cards, int *co
11061106
decklink_uninitialize(&com_initialized);
11071107
}
11081108

1109+
static void
1110+
set_synchronized(struct state_decklink *s, const char *cfg)
1111+
{
1112+
s->low_latency = false;
1113+
if (cfg == nullptr) {
1114+
return;
1115+
}
1116+
cfg += 1;
1117+
s->delegate.m_min_sched_frames = stoi(cfg);
1118+
if (strchr(cfg, ',') != nullptr) {
1119+
s->delegate.m_max_sched_frames = stoi(strchr(cfg, ',') + 1);
1120+
} else {
1121+
s->delegate.m_max_sched_frames =
1122+
s->delegate.m_min_sched_frames + SCHED_RANGE;
1123+
}
1124+
assert(s->delegate.m_max_sched_frames > s->delegate.m_min_sched_frames);
1125+
}
1126+
11091127
static bool settings_init(struct state_decklink *s, const char *fmt,
11101128
string &cardId) {
11111129
if (strlen(fmt) == 0) {
@@ -1195,19 +1213,7 @@ static bool settings_init(struct state_decklink *s, const char *fmt,
11951213
"see option \"synchroninzed\" instead.\n";
11961214
s->low_latency = strcasecmp(ptr, "low-latency") == 0;
11971215
} else if (IS_PREFIX(ptr, "synchronized")) {
1198-
s->low_latency = false;
1199-
ptr = strchr(ptr, '=');
1200-
if (ptr != nullptr) {
1201-
ptr += 1;
1202-
s->delegate.m_max_sched_frames =
1203-
SCHED_RANGE +
1204-
(s->delegate.m_min_sched_frames =
1205-
stoi(ptr));
1206-
if (strchr(ptr, ',') != nullptr) {
1207-
s->delegate.m_max_sched_frames =
1208-
stoi(strchr(ptr, ',') + 1);
1209-
}
1210-
}
1216+
set_synchronized(s, strchr(ptr, '='));
12111217
} else if (strcasecmp(ptr, "quad-square") == 0 || strcasecmp(ptr, "no-quad-square") == 0) {
12121218
s->quad_square_division_split.set_flag(strcasecmp(ptr, "quad-square") == 0);
12131219
} else if (strncasecmp(ptr, "hdr", strlen("hdr")) == 0) {

0 commit comments

Comments
 (0)