From ccc2b89c9cf879ccbd948e169a029917cc16f0ee Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sun, 15 Aug 2021 15:06:34 +0200 Subject: [PATCH] Fix DeckLink capture using the 11.7 or newer drivers. Reported by Marcus Nilsen. --- nageru/bmusb | 2 +- nageru/decklink_capture.h | 2 ++ nageru/decklink_output.cpp | 6 ++---- nageru/decklink_output.h | 6 +++++- nageru/mixer.cpp | 2 +- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/nageru/bmusb b/nageru/bmusb index 0c0182f..327dca2 160000 --- a/nageru/bmusb +++ b/nageru/bmusb @@ -1 +1 @@ -Subproject commit 0c0182f453e8bc26e630615ea6d2a2f05e868fde +Subproject commit 327dca2d848e4c4656be1bfb54a2edf2e6587a71 diff --git a/nageru/decklink_capture.h b/nageru/decklink_capture.h index f940241..a2e25c8 100644 --- a/nageru/decklink_capture.h +++ b/nageru/decklink_capture.h @@ -26,6 +26,8 @@ public: DeckLinkCapture(IDeckLink *card, int card_index); // Takes ownership of . ~DeckLinkCapture(); + IDeckLinkInput *get_input() const { return input; } + // IDeckLinkInputCallback. HRESULT STDMETHODCALLTYPE QueryInterface(REFIID, LPVOID *) override; ULONG STDMETHODCALLTYPE AddRef() override; diff --git a/nageru/decklink_output.cpp b/nageru/decklink_output.cpp index da172af..20de922 100644 --- a/nageru/decklink_output.cpp +++ b/nageru/decklink_output.cpp @@ -82,11 +82,9 @@ DeckLinkOutput::DeckLinkOutput(ResourcePool *resource_pool, QSurface *surface, u }); } -bool DeckLinkOutput::set_device(IDeckLink *decklink) +bool DeckLinkOutput::set_device(IDeckLink *decklink, IDeckLinkInput *input_arg) { - if (decklink->QueryInterface(IID_IDeckLinkInput, (void**)&input) != S_OK) { - input = nullptr; - } + input_arg = input; if (decklink->QueryInterface(IID_IDeckLinkOutput, (void**)&output) != S_OK) { fprintf(stderr, "Warning: Card %u has no outputs\n", card_index); return false; diff --git a/nageru/decklink_output.h b/nageru/decklink_output.h index f1b40f4..8213f49 100644 --- a/nageru/decklink_output.h +++ b/nageru/decklink_output.h @@ -39,7 +39,11 @@ class DeckLinkOutput : public IDeckLinkVideoOutputCallback { public: DeckLinkOutput(movit::ResourcePool *resource_pool, QSurface *surface, unsigned width, unsigned height, unsigned card_index); - bool set_device(IDeckLink *output); + // The IDecklinkInput argument is to work around a bug + // in the 11.7 and newer drivers against older SDKs, + // where you get a freeze if querying an IDeckLinkInput interface + // on an already-started card. + bool set_device(IDeckLink *decklink, IDeckLinkInput *input_arg); void start_output(uint32_t mode, int64_t base_pts); // Mode comes from get_available_video_modes(). void end_output(); diff --git a/nageru/mixer.cpp b/nageru/mixer.cpp index ce8a732..3a137d6 100644 --- a/nageru/mixer.cpp +++ b/nageru/mixer.cpp @@ -429,7 +429,7 @@ Mixer::Mixer(const QSurfaceFormat &format) 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)) { + if (!output->set_device(decklink, capture->get_input())) { delete output; output = nullptr; } -- 2.39.2