]> git.sesse.net Git - nageru/blobdiff - decklink_capture.cpp
Write 1.4.0 changelog.
[nageru] / decklink_capture.cpp
index 956c546e6f93a9b8d823e1e7475917466befb83f..505083ff056a72018069ec2e3ae9e2573e5ab51a 100644 (file)
@@ -1,25 +1,28 @@
 #include "decklink_capture.h"
 
+#include <DeckLinkAPI.h>
+#include <DeckLinkAPIConfiguration.h>
+#include <DeckLinkAPIDiscovery.h>
+#include <DeckLinkAPIModes.h>
 #include <assert.h>
+#ifdef __SSE2__
+#include <immintrin.h>
+#endif
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <cstddef>
-#ifdef __SSE2__
-#include <immintrin.h>
-#endif
+#include <cstdint>
+#include <utility>
+#include <vector>
 
-#include <DeckLinkAPI.h>
-#include <DeckLinkAPIConfiguration.h>
-#include <DeckLinkAPIDiscovery.h>
-#include <DeckLinkAPIModes.h>
 #include "bmusb/bmusb.h"
 
 #define FRAME_SIZE (8 << 20)  // 8 MB.
 
 using namespace std;
 using namespace std::placeholders;
+using namespace bmusb;
 
 namespace {
 
@@ -58,7 +61,7 @@ size_t memcpy_interleaved_fastpath(uint8_t *dest1, uint8_t *dest2, const uint8_t
                memcpy_interleaved(dest1, dest2, src, n2);
                dest1 += n2 / 2;
                dest2 += n2 / 2;
-               if (n2 % 1) {
+               if (n2 % 2) {
                        swap(dest1, dest2);
                }
                src = aligned_src;
@@ -134,7 +137,7 @@ size_t memcpy_interleaved_fastpath(uint8_t *dest1, uint8_t *dest2, const uint8_t
 }  // namespace
 
 DeckLinkCapture::DeckLinkCapture(IDeckLink *card, int card_index)
-       : card_index(card_index)
+       : card_index(card_index), card(card)
 {
        {
                const char *model_name;
@@ -262,6 +265,9 @@ DeckLinkCapture::~DeckLinkCapture()
        if (has_dequeue_callbacks) {
                dequeue_cleanup_callback();
        }
+       input->Release();
+       config->Release();
+       card->Release();
 }
 
 HRESULT STDMETHODCALLTYPE DeckLinkCapture::QueryInterface(REFIID, LPVOID *)
@@ -381,10 +387,12 @@ HRESULT STDMETHODCALLTYPE DeckLinkCapture::VideoInputFrameArrived(
 void DeckLinkCapture::configure_card()
 {
        if (video_frame_allocator == nullptr) {
-               set_video_frame_allocator(new MallocFrameAllocator(FRAME_SIZE, NUM_QUEUED_VIDEO_FRAMES));  // FIXME: leak.
+               owned_video_frame_allocator.reset(new MallocFrameAllocator(FRAME_SIZE, NUM_QUEUED_VIDEO_FRAMES));
+               set_video_frame_allocator(owned_video_frame_allocator.get());
        }
        if (audio_frame_allocator == nullptr) {
-               set_audio_frame_allocator(new MallocFrameAllocator(65536, NUM_QUEUED_AUDIO_FRAMES));  // FIXME: leak.
+               owned_audio_frame_allocator.reset(new MallocFrameAllocator(65536, NUM_QUEUED_AUDIO_FRAMES));
+               set_audio_frame_allocator(owned_audio_frame_allocator.get());
        }
 }