X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fdecklink%2Fdecklink_api.h;h=10561e3e2901e19a2d7c1b7edf00399ae3caa7c9;hb=e54e9fb019a185d9516b99d33d4c8aa8e44ccd7e;hp=9fd27b9ed1fe3e246f420f092c7328ece1cf9f76;hpb=9180bfb89f6c118382e373d475eabbd6f8e78b58;p=casparcg diff --git a/modules/decklink/decklink_api.h b/modules/decklink/decklink_api.h index 9fd27b9ed..10561e3e2 100644 --- a/modules/decklink/decklink_api.h +++ b/modules/decklink/decklink_api.h @@ -61,20 +61,8 @@ struct co_init template using com_ptr = CComPtr; -// MSVC 2013 crashes when this alias template is instantiated -/*template -using com_iface_ptr = CComQIPtr;*/ - template -class com_iface_ptr : public CComQIPtr -{ -public: - template - com_iface_ptr(const com_ptr& lp) - : CComQIPtr(lp) - { - } -}; +using com_iface_ptr = CComQIPtr; template class P, typename T> static P wrap_raw(T* ptr, bool already_referenced = false) @@ -93,14 +81,19 @@ static com_ptr create_iterator() { CComPtr pDecklinkIterator; if(FAILED(pDecklinkIterator.CoCreateInstance(CLSID_CDeckLinkIterator))) - CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info("Decklink drivers not found.")); + CASPAR_THROW_EXCEPTION(not_supported() << msg_info("Decklink drivers not found.")); return pDecklinkIterator; } template -static com_iface_ptr iface_cast(const com_ptr& ptr) +static com_iface_ptr iface_cast(const com_ptr& ptr, bool optional = false) { - return com_iface_ptr(ptr); + com_iface_ptr result = ptr; + + if (!optional && !result) + CASPAR_THROW_EXCEPTION(not_supported() << msg_info(std::string("Could not cast from ") + typeid(T).name() + " to " + typeid(I).name() + ". This is probably due to old Decklink drivers.")); + + return result; } template @@ -114,6 +107,7 @@ T* get_raw(const CComPtr& ptr) #else #include "linux_interop/DeckLinkAPI.h" +#include "linux_interop/DeckLinkAPIConfiguration_v10_2.h" #include #include @@ -167,7 +161,7 @@ static com_ptr create_iterator() IDeckLinkIterator* iterator = CreateDeckLinkIteratorInstance(); if (iterator == nullptr) - CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info("Decklink drivers not found.")); + CASPAR_THROW_EXCEPTION(not_supported() << msg_info("Decklink drivers not found.")); return wrap_raw(iterator, true); } @@ -177,12 +171,13 @@ template<> REFIID iface_id() { return IID_IDeckLink; } template<> REFIID iface_id() { return IID_IDeckLinkOutput; } template<> REFIID iface_id() { return IID_IDeckLinkAPIInformation; } template<> REFIID iface_id() { return IID_IDeckLinkConfiguration; } +template<> REFIID iface_id() { return IID_IDeckLinkConfiguration_v10_2; } template<> REFIID iface_id() { return IID_IDeckLinkKeyer; } template<> REFIID iface_id() { return IID_IDeckLinkAttributes; } template<> REFIID iface_id() { return IID_IDeckLinkInput; } template -static com_iface_ptr iface_cast(com_ptr ptr) +static com_iface_ptr iface_cast(com_ptr ptr, bool optional = false) { I* iface; ptr->QueryInterface(iface_id(), reinterpret_cast(&iface));