From 3fd3a00f3f70d28377c4d876746e1a8849e422bd Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Wed, 25 Oct 2017 20:08:05 +0200 Subject: [PATCH] Add back support for input-only DeckLink cards. --- decklink_output.cpp | 11 ++++++----- decklink_output.h | 2 +- mixer.cpp | 5 ++++- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/decklink_output.cpp b/decklink_output.cpp index 091e1b7..a3d220b 100644 --- a/decklink_output.cpp +++ b/decklink_output.cpp @@ -82,17 +82,17 @@ DeckLinkOutput::DeckLinkOutput(ResourcePool *resource_pool, QSurface *surface, u }); } -void DeckLinkOutput::set_device(IDeckLink *decklink) +bool DeckLinkOutput::set_device(IDeckLink *decklink) { if (decklink->QueryInterface(IID_IDeckLinkOutput, (void**)&output) != S_OK) { - fprintf(stderr, "Card %u has no outputs\n", card_index); - exit(1); + fprintf(stderr, "Warning: Card %u has no outputs\n", card_index); + return false; } IDeckLinkDisplayModeIterator *mode_it; if (output->GetDisplayModeIterator(&mode_it) != S_OK) { - fprintf(stderr, "Failed to enumerate output display modes for card %u\n", card_index); - exit(1); + fprintf(stderr, "Warning: Failed to enumerate output display modes for card %u\n", card_index); + return false; } video_modes.clear(); @@ -118,6 +118,7 @@ void DeckLinkOutput::set_device(IDeckLink *decklink) // if they exist. We're not very likely to need analog outputs, so we don't need a way // to change beyond that. video_connection = pick_default_video_connection(decklink, BMDDeckLinkVideoOutputConnections, card_index); + return true; } void DeckLinkOutput::start_output(uint32_t mode, int64_t base_pts) diff --git a/decklink_output.h b/decklink_output.h index a295496..44eb86d 100644 --- a/decklink_output.h +++ b/decklink_output.h @@ -38,7 +38,7 @@ class DeckLinkOutput : public IDeckLinkVideoOutputCallback { public: DeckLinkOutput(movit::ResourcePool *resource_pool, QSurface *surface, unsigned width, unsigned height, unsigned card_index); - void set_device(IDeckLink *output); + bool set_device(IDeckLink *output); void start_output(uint32_t mode, int64_t base_pts); // Mode comes from get_available_video_modes(). void end_output(); diff --git a/mixer.cpp b/mixer.cpp index f1d116f..6ec12e8 100644 --- a/mixer.cpp +++ b/mixer.cpp @@ -371,7 +371,10 @@ Mixer::Mixer(const QSurfaceFormat &format, unsigned num_cards) 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); - output->set_device(decklink); + if (!output->set_device(decklink)) { + delete output; + output = nullptr; + } configure_card(card_index, capture, CardType::LIVE_CARD, output); ++num_pci_devices; } -- 2.39.2