]> git.sesse.net Git - bmusb/blobdiff - bmusb.h
Add an is_connected member to VideoFormat, for use with fake cards in Nageru.
[bmusb] / bmusb.h
diff --git a/bmusb.h b/bmusb.h
index 9ee6617a6e7874164a8a53603a47d974acf01694..bf1f51fb60eb65b77a40d26da003787b88414ded 100644 (file)
--- a/bmusb.h
+++ b/bmusb.h
@@ -97,6 +97,7 @@ struct VideoFormat {
        unsigned frame_rate_nom = 0, frame_rate_den = 0;
        bool interlaced = false;
        bool has_signal = false;
+       bool is_connected = true;  // If false, then has_signal makes no sense.
 };
 
 struct AudioFormat {
@@ -177,6 +178,9 @@ class BMUSBCapture : public CaptureInterface {
        void set_video_frame_allocator(FrameAllocator *allocator) override
        {
                video_frame_allocator = allocator;
+               if (owned_video_frame_allocator.get() != allocator) {
+                       owned_video_frame_allocator.reset();
+               }
        }
 
        FrameAllocator *get_video_frame_allocator() override
@@ -188,6 +192,9 @@ class BMUSBCapture : public CaptureInterface {
        void set_audio_frame_allocator(FrameAllocator *allocator) override
        {
                audio_frame_allocator = allocator;
+               if (owned_audio_frame_allocator.get() != allocator) {
+                       owned_audio_frame_allocator.reset();
+               }
        }
 
        FrameAllocator *get_audio_frame_allocator() override
@@ -251,6 +258,8 @@ class BMUSBCapture : public CaptureInterface {
 
        FrameAllocator *video_frame_allocator = nullptr;
        FrameAllocator *audio_frame_allocator = nullptr;
+       std::unique_ptr<FrameAllocator> owned_video_frame_allocator;
+       std::unique_ptr<FrameAllocator> owned_audio_frame_allocator;
        frame_callback_t frame_callback = nullptr;
 
        std::thread dequeue_thread;