]> git.sesse.net Git - nageru/commitdiff
Skip DeckLink cards marked as inactive.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 3 Jun 2020 21:45:02 +0000 (23:45 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 3 Jun 2020 21:45:52 +0000 (23:45 +0200)
This prevents a crash on startup with e.g. Duo 2 in the default mode,
which disables connectors 3 and 4 by default (well, uses them for dual link).

nageru/decklink_util.cpp
nageru/decklink_util.h
nageru/mixer.cpp

index 33a7933a033e26c08d91d59e1f4919a0717d55b6..c2ebd575b073cb1743d6a2cc3c1ea418c415d126 100644 (file)
@@ -90,3 +90,22 @@ BMDVideoConnection pick_default_video_connection(IDeckLink *card, BMDDeckLinkAtt
                return connection_mask & (-connection_mask);
        }
 }
+
+bool decklink_card_is_active(IDeckLink *card, unsigned card_index)
+{
+       IDeckLinkStatus *status;
+       if (card->QueryInterface(IID_IDeckLinkStatus, (void**)&status) != S_OK) {
+               fprintf(stderr, "Card %u has no status interface\n", card_index);
+               abort();
+       }
+
+       int64_t duplex_mode;
+       if (status->GetInt(bmdDeckLinkStatusDuplexMode, &duplex_mode) != S_OK) {
+               fprintf(stderr, "Could not query duplex mode for card %u\n", card_index);
+               abort();
+       }
+
+       status->Release();
+
+       return (duplex_mode != bmdDuplexStatusInactive);
+}
index 2850a21cd9ec71000e918e62ea89f0f9fa517887..cbc012a6a4031a5f38b8982d554a42c1c5ad7f3d 100644 (file)
@@ -14,4 +14,6 @@ std::map<uint32_t, bmusb::VideoMode> summarize_video_modes(IDeckLinkDisplayModeI
 // Picks a video connection that the card supports. Priority list: HDMI, SDI, anything else.
 BMDVideoConnection pick_default_video_connection(IDeckLink *card, BMDDeckLinkAttributeID attribute_id, unsigned card_index);
 
+bool decklink_card_is_active(IDeckLink *card, unsigned card_index);
+
 #endif  // !defined(_DECKLINK_UTIL)
index 5df80dfba0c2923820e014df5572284d9f6ed8b3..80fcb64a054bf3c2c3c8047dfb28de321e4e3604 100644 (file)
@@ -41,6 +41,7 @@
 #include "shared/context.h"
 #include "decklink_capture.h"
 #include "decklink_output.h"
+#include "decklink_util.h"
 #include "defs.h"
 #include "shared/disk_space_estimator.h"
 #include "ffmpeg_capture.h"
@@ -410,6 +411,12 @@ Mixer::Mixer(const QSurfaceFormat &format)
                                        break;
                                }
 
+                               if (!decklink_card_is_active(decklink, card_index)) {
+                                       fprintf(stderr, "DeckLink card %u is inactive in current profile, skipping (try changing it in Desktop Video Setup)\n", card_index);
+                                       decklink->Release();
+                                       continue;
+                               }
+
                                DeckLinkCapture *capture = new DeckLinkCapture(decklink, card_index);
                                DeckLinkOutput *output = new DeckLinkOutput(resource_pool.get(), decklink_output_surface, global_flags.width, global_flags.height, card_index);
                                if (!output->set_device(decklink)) {