]> git.sesse.net Git - nageru/commitdiff
Reintroduce faster DeckLink shutdown; now with a fix for the UI switcher.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 29 Mar 2020 12:33:32 +0000 (14:33 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 29 Mar 2020 12:33:32 +0000 (14:33 +0200)
nageru/decklink_capture.cpp
nageru/decklink_output.cpp
nageru/decklink_output.h

index eefb537cd1b3409d9f51593b1432e9360ff534b4..6ccbadc339791ca12816dcc57920855f049ad404 100644 (file)
@@ -350,14 +350,12 @@ void DeckLinkCapture::stop_dequeue_thread()
                fprintf(stderr, "StopStreams failed with error 0x%x\n", result);
                abort();
        }
-       if (input->DisableVideoInput() != S_OK) {
-               fprintf(stderr, "Failed to disable video input for card %d\n", card_index);
-               exit(1);
-       }
-       if (input->DisableAudioInput() != S_OK) {
-               fprintf(stderr, "Failed to disable audio input for card %d\n", card_index);
-               exit(1);
-       }
+
+       // We could call DisableVideoInput() and DisableAudioInput() here,
+       // but they seem to be taking a really long time, and we only do this
+       // during shutdown anyway (except when switching to output mode,
+       // where DeckLinkOutput does the disabling), so StopStreams() will suffice.
+
        running = false;
 }
 
index 6b21edb0c45d066ebf3d8d68a6f8ed27410f4f8d..f1e06e8902cc268f4098bf74c363698725155e1b 100644 (file)
@@ -84,6 +84,9 @@ DeckLinkOutput::DeckLinkOutput(ResourcePool *resource_pool, QSurface *surface, u
 
 bool DeckLinkOutput::set_device(IDeckLink *decklink)
 {
+       if (decklink->QueryInterface(IID_IDeckLinkInput, (void**)&input) != S_OK) {
+               input = nullptr;
+       }
        if (decklink->QueryInterface(IID_IDeckLinkOutput, (void**)&output) != S_OK) {
                fprintf(stderr, "Warning: Card %u has no outputs\n", card_index);
                return false;
@@ -193,6 +196,15 @@ void DeckLinkOutput::start_output(uint32_t mode, int64_t base_pts)
 
        display_mode->Release();
 
+       if (input != nullptr) {
+               if (input->DisableVideoInput() != S_OK) {
+                       fprintf(stderr, "Warning: Failed to disable video input for card %d\n", card_index);
+               }
+               if (input->DisableAudioInput() != S_OK) {
+                       fprintf(stderr, "Warning: Failed to disable audio input for card %d\n", card_index);
+               }
+       }
+
        HRESULT result = output->EnableVideoOutput(mode, bmdVideoOutputFlagDefault);
        if (result != S_OK) {
                fprintf(stderr, "Couldn't enable output with error 0x%x\n", result);
@@ -249,6 +261,10 @@ void DeckLinkOutput::end_output()
                }
        }
 
+       if (input != nullptr) {
+               input->Release();
+               input = nullptr;
+       }
        if (output != nullptr) {
                output->Release();
                output = nullptr;
index 90b89a22a18f1f6e0de7a9352d94d437415f79f3..2c07bc72ccae0c32c8300081d473eebaf6bc7af9 100644 (file)
@@ -141,6 +141,7 @@ private:
        bool last_frame_had_mode_mismatch = false;
 
        movit::ResourcePool *resource_pool;
+       IDeckLinkInput *input = nullptr;
        IDeckLinkOutput *output = nullptr;
        BMDVideoConnection video_connection;
        QSurface *surface;