#include "decklink_consumer.h"\r
\r
#include "../util/util.h"\r
+#include "../util/decklink_allocator.h"\r
\r
#include "../interop/DeckLinkAPI_h.h"\r
\r
#include <common/concurrency/future_util.h>\r
#include <common/diagnostics/graph.h>\r
#include <common/exception/exceptions.h>\r
+#include <common/exception/win32_exception.h>\r
#include <common/utility/assert.h>\r
\r
#include <core/parameters/parameters.h>\r
namespace caspar { namespace decklink { \r
\r
struct decklink_consumer : public IDeckLinkVideoOutputCallback, public IDeckLinkAudioOutputCallback, boost::noncopyable\r
-{ \r
+{\r
const int channel_index_;\r
const configuration config_;\r
\r
+ std::unique_ptr<thread_safe_decklink_allocator> allocator_;\r
CComPtr<IDeckLink> decklink_;\r
CComQIPtr<IDeckLinkOutput> output_;\r
CComQIPtr<IDeckLinkKeyer> keyer_;\r
\r
void enable_video(BMDDisplayMode display_mode)\r
{\r
+ if (config_.custom_allocator)\r
+ {\r
+ allocator_.reset(new thread_safe_decklink_allocator(print()));\r
+\r
+ if (FAILED(output_->SetVideoOutputFrameMemoryAllocator(allocator_.get())))\r
+ BOOST_THROW_EXCEPTION(caspar_exception() << msg_info(narrow(print()) + " Could not set custom memory allocator."));\r
+\r
+ CASPAR_LOG(info) << print() << L" Using custom allocator.";\r
+ }\r
+\r
if(FAILED(output_->EnableVideoOutput(display_mode, bmdVideoOutputFlagDefault))) \r
BOOST_THROW_EXCEPTION(caspar_exception() << msg_info(narrow(print()) + " Could not enable video output."));\r
\r
\r
STDMETHOD(ScheduledFrameCompleted(IDeckLinkVideoFrame* completed_frame, BMDOutputFrameCompletionResult result))\r
{\r
+ win32_exception::ensure_handler_installed_for_thread("decklink-ScheduledFrameCompleted");\r
if(!is_running_)\r
return E_FAIL;\r
\r
\r
STDMETHOD(RenderAudioSamples(BOOL preroll))\r
{\r
+ win32_exception::ensure_handler_installed_for_thread("decklink-RenderAudioSamples");\r
+\r
if(!is_running_)\r
return E_FAIL;\r
\r
else if(latency == L"normal")\r
config.latency = configuration::normal_latency;\r
\r
- config.key_only = ptree.get(L"key-only", config.key_only);\r
- config.device_index = ptree.get(L"device", config.device_index);\r
- config.embedded_audio = ptree.get(L"embedded-audio", config.embedded_audio);\r
- config.base_buffer_depth = ptree.get(L"buffer-depth", config.base_buffer_depth);\r
+ config.key_only = ptree.get(L"key-only", config.key_only);\r
+ config.device_index = ptree.get(L"device", config.device_index);\r
+ config.embedded_audio = ptree.get(L"embedded-audio", config.embedded_audio);\r
+ config.base_buffer_depth = ptree.get(L"buffer-depth", config.base_buffer_depth);\r
+ config.custom_allocator = ptree.get(L"custom-allocator", config.custom_allocator);\r
config.audio_layout =\r
core::default_channel_layout_repository().get_by_name(\r
boost::to_upper_copy(ptree.get(L"channel-layout", L"STEREO")));\r