X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=bmusb.h;h=bf1f51fb60eb65b77a40d26da003787b88414ded;hb=76a878cbab84d8c3c2859b28a2363085d6a2fcb1;hp=9ee6617a6e7874164a8a53603a47d974acf01694;hpb=a5e46ba4b478f7fae63f3032e574208c0e69cc11;p=bmusb diff --git a/bmusb.h b/bmusb.h index 9ee6617..bf1f51f 100644 --- 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 owned_video_frame_allocator; + std::unique_ptr owned_audio_frame_allocator; frame_callback_t frame_callback = nullptr; std::thread dequeue_thread;