]> git.sesse.net Git - nageru/blobdiff - nageru/decklink_output.h
Fix DeckLink capture using the 11.7 or newer drivers.
[nageru] / nageru / decklink_output.h
index 44eb86dea9860e6480c4552aeaf352a5990bf979..8213f498a9d0677df7fe77b928acc7dce8951825 100644 (file)
@@ -7,6 +7,7 @@
 #include <atomic>
 #include <chrono>
 #include <condition_variable>
+#include <deque>
 #include <memory>
 #include <mutex>
 #include <queue>
 #include "DeckLinkAPITypes.h"
 #include "LinuxCOM.h"
 
-#include "context.h"
+#include "shared/context.h"
 #include "print_latency.h"
 #include "quittable_sleeper.h"
 #include "ref_counted_frame.h"
-#include "ref_counted_gl_sync.h"
+#include "shared/ref_counted_gl_sync.h"
 
 namespace movit {
 
@@ -38,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();
 
@@ -133,7 +138,8 @@ private:
        std::mutex frame_queue_mutex;
        std::queue<std::unique_ptr<Frame>> pending_video_frames;  // Under <frame_queue_mutex>.
        std::queue<std::unique_ptr<Frame>> frame_freelist;  // Under <frame_queue_mutex>.
-       int num_frames_in_flight = 0;  // Number of frames allocated but not on the freelist. Under <frame_queue_mutex>.
+       std::deque<Frame *> scheduled_frames;  // Owned by the driver, so no unique_ptr. Under <frame_queue_mutex>.
+
        std::condition_variable frame_queues_changed;
        bool playback_initiated = false, playback_started = false;
        int64_t base_pts, frame_duration;
@@ -141,6 +147,7 @@ private:
        bool last_frame_had_mode_mismatch = false;
 
        movit::ResourcePool *resource_pool;
+       IDeckLinkInput *input = nullptr;
        IDeckLinkOutput *output = nullptr;
        BMDVideoConnection video_connection;
        QSurface *surface;