X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=nageru%2Fdecklink_output.cpp;h=f1e06e8902cc268f4098bf74c363698725155e1b;hb=5a34f92eb0bf5fe911cb6ca72a18ad03ce9898ac;hp=f6826b51366e4a73afcfdcf0edac39179601a5ad;hpb=9ffd4f03f314cc6e0254449593def95c9bc203d6;p=nageru diff --git a/nageru/decklink_output.cpp b/nageru/decklink_output.cpp index f6826b5..f1e06e8 100644 --- a/nageru/decklink_output.cpp +++ b/nageru/decklink_output.cpp @@ -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); @@ -248,6 +260,15 @@ void DeckLinkOutput::end_output() frame_freelist.pop(); } } + + if (input != nullptr) { + input->Release(); + input = nullptr; + } + if (output != nullptr) { + output->Release(); + output = nullptr; + } } void DeckLinkOutput::send_frame(GLuint y_tex, GLuint cbcr_tex, YCbCrLumaCoefficients output_ycbcr_coefficients, const vector &input_frames, int64_t pts, int64_t duration) @@ -462,12 +483,12 @@ HRESULT DeckLinkOutput::ScheduledFrameCompleted(/* in */ IDeckLinkVideoFrame *co ++metric_decklink_output_completed_frames_late; break; case bmdOutputFrameDropped: - fprintf(stderr, "Output frame was dropped (pts=%" PRId64 "ld)\n", frame->pts); + fprintf(stderr, "Output frame was dropped (pts=%" PRId64 ")\n", frame->pts); fprintf(stderr, "Consider increasing --output-buffer-frames if this persists.\n"); ++metric_decklink_output_completed_frames_dropped; break; case bmdOutputFrameFlushed: - fprintf(stderr, "Output frame was flushed (pts=%" PRId64 "ld)\n", frame->pts); + fprintf(stderr, "Output frame was flushed (pts=%" PRId64 ")\n", frame->pts); ++metric_decklink_output_completed_frames_flushed; break; default: