]> git.sesse.net Git - casparcg/blobdiff - modules/decklink/consumer/blocking_decklink_consumer.cpp
* Created custom decklink allocator for reducing memory footprint.
[casparcg] / modules / decklink / consumer / blocking_decklink_consumer.cpp
index 573c171b20114b3b6a872eb0454a3798dc84f858..b12ec63ca40c5c4f55964db951fdf91e2e558bc6 100644 (file)
@@ -24,6 +24,7 @@
 #include "decklink_consumer.h"
 
 #include "../util/util.h"
+#include "../util/decklink_allocator.h"
 
 #include "../interop/DeckLinkAPI_h.h"
 
@@ -59,6 +60,7 @@ struct blocking_decklink_consumer : boost::noncopyable
        const int                                                               channel_index_;
        const configuration                                             config_;
 
+       std::unique_ptr<thread_safe_decklink_allocator> allocator_;
        CComPtr<IDeckLink>                                              decklink_;
        CComQIPtr<IDeckLinkOutput>                              output_;
        CComQIPtr<IDeckLinkKeyer>                               keyer_;
@@ -142,6 +144,16 @@ public:
 
        void enable_video(BMDDisplayMode display_mode)
        {
+               if (config_.custom_allocator)
+               {
+                       allocator_.reset(new thread_safe_decklink_allocator(print()));
+
+                       if (FAILED(output_->SetVideoOutputFrameMemoryAllocator(allocator_.get())))
+                               BOOST_THROW_EXCEPTION(caspar_exception() << msg_info(narrow(print()) + " Could not set custom memory allocator."));
+
+                       CASPAR_LOG(info) << print() << L" Using custom allocator.";
+               }
+
                if(FAILED(output_->EnableVideoOutput(display_mode, bmdVideoOutputFlagDefault))) 
                        BOOST_THROW_EXCEPTION(caspar_exception() << msg_info(narrow(print()) + " Could not enable video output."));
        }