5050#include < cassert>
5151#include < cctype> // for isdigit
5252#include < chrono>
53+ #include < cinttypes> // for PRId64
5354#include < climits>
5455#include < condition_variable>
5556#include < cstdint> // for int64_t, uint32_t, int32_t
@@ -1138,6 +1139,39 @@ void device_state::check_attributes(struct vidcap_decklink_state *s)
11381139 }
11391140}
11401141
1142+ static bool
1143+ supports_autodetect (IDeckLinkProfileAttributes *deckLinkAttributes)
1144+ {
1145+ BMD_BOOL autodetection{};
1146+ BMD_CHECK (deckLinkAttributes->GetFlag (
1147+ BMDDeckLinkSupportsInputFormatDetection, &autodetection),
1148+ " Could not verify if device supports autodetection" ,
1149+ return false );
1150+ if (autodetection == BMD_FALSE) {
1151+ MSG (ERROR, " Device doesn't support format autodetection, you "
1152+ " must set it manually or try \" -t "
1153+ " decklink:detect-format[:connection=<in>]\"\n " );
1154+ }
1155+ return autodetection;
1156+ }
1157+
1158+ static void autodetect_fmt_n_found_msg (IDeckLinkProfileAttributes *deckLinkAttributes) {
1159+ MSG (ERROR, " Cannot set initial format for autodetection - perhaps "
1160+ " impossible combinations of parameters were set.\n " );
1161+
1162+ // print hint for 8K Pro to set profile...
1163+ int64_t val = 0 ;
1164+ // clang-format off
1165+ if (deckLinkAttributes->GetInt (BMDDeckLinkNumberOfSubDevices, &val) == S_OK && val > 1 &&
1166+ deckLinkAttributes->GetInt (BMDDeckLinkSubDeviceIndex, &val) == S_OK && val > 0 ) {
1167+ // clang-format on
1168+ MSG (WARNING,
1169+ " Did you set ':half-duplex' for multiple sub-device "
1170+ " card? Using sub-device index %" PRId64 " ...\n " ,
1171+ val);
1172+ }
1173+ }
1174+
11411175#define INIT_ERR () do { RELEASE_IF_NOT_NULL (displayMode); RELEASE_IF_NOT_NULL (displayModeIterator); return false ; } while (0 )
11421176bool device_state::init (struct vidcap_decklink_state *s, struct tile *t, BMDAudioConnection audioConnection)
11431177{
@@ -1315,9 +1349,7 @@ bool device_state::init(struct vidcap_decklink_state *s, struct tile *t, BMDAudi
13151349 } else if (mode_idx >= 0 ) {
13161350 MSG (ERROR, " Desired mode index %s is out of bounds.\n " , s->mode .c_str ());
13171351 } else if (mode_idx == MODE_SPEC_AUTODETECT) {
1318- MSG (ERROR, " Cannot set initial format for "
1319- " autodetection - perhaps impossible "
1320- " combinations of parameters were set.\n " );
1352+ autodetect_fmt_n_found_msg (deckLinkAttributes);
13211353 } else {
13221354 assert (" Invalid mode spec." && 0 );
13231355 }
@@ -1332,13 +1364,7 @@ bool device_state::init(struct vidcap_decklink_state *s, struct tile *t, BMDAudi
13321364
13331365 if (mode_idx == MODE_SPEC_AUTODETECT) {
13341366 MSG (INFO, " Trying to autodetect format.\n " );
1335- BMD_BOOL autodetection;
1336- BMD_CHECK (deckLinkAttributes->GetFlag (BMDDeckLinkSupportsInputFormatDetection, &autodetection), " Could not verify if device supports autodetection" , INIT_ERR ());
1337- if (autodetection == BMD_FALSE) {
1338- MSG (ERROR,
1339- " Device doesn't support format autodetection, you "
1340- " must set it manually or try \" -t "
1341- " decklink:detect-format[:connection=<in>]\"\n " );
1367+ if (!supports_autodetect (deckLinkAttributes)) {
13421368 INIT_ERR ();
13431369 }
13441370 s->enable_flags |= bmdVideoInputEnableFormatDetection;
0 commit comments