From: James Wise Date: Tue, 7 Feb 2017 02:48:48 +0000 (+1100) Subject: more refinements to code due to move to RAII X-Git-Tag: 2.1.0_Beta2~48^2^2~13 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=40e90ea271946f7e7df6e378b252c22b1d09fe4e;p=casparcg more refinements to code due to move to RAII --- diff --git a/modules/bluefish/bluefish.cpp b/modules/bluefish/bluefish.cpp index 0c2957ebc..cf50a7b24 100644 --- a/modules/bluefish/bluefish.cpp +++ b/modules/bluefish/bluefish.cpp @@ -42,7 +42,7 @@ std::wstring version() { try { - bvc_wrapper blue = bvc_wrapper(); + bvc_wrapper blue; return u16(blue.get_version()); } catch(...) @@ -57,7 +57,7 @@ std::vector device_list() try { - bvc_wrapper blue = bvc_wrapper(); + bvc_wrapper blue; int numCards = 0; blue.enumerate(numCards); @@ -77,10 +77,9 @@ void init(core::module_dependencies dependencies) { try { - bvc_wrapper blue = bvc_wrapper(); + bvc_wrapper blue; int num_cards = 0; blue.enumerate(num_cards); - } catch(...){} diff --git a/modules/bluefish/util/blue_velvet.cpp b/modules/bluefish/util/blue_velvet.cpp index 86b6178e6..5440a28c9 100644 --- a/modules/bluefish/util/blue_velvet.cpp +++ b/modules/bluefish/util/blue_velvet.cpp @@ -40,9 +40,9 @@ namespace caspar { namespace bluefish { bvc_wrapper::bvc_wrapper() { - bvc_ = nullptr; - h_module_ = nullptr; - init_function_pointers(); + if(!init_function_pointers()) + CASPAR_THROW_EXCEPTION(not_supported() << msg_info("Bluefish drivers not found. Unable to init Funcion Pointers")); + bvc_ = std::shared_ptr(bfcFactory(), bfcDestroy); if (!bvc_) @@ -150,10 +150,7 @@ namespace caspar { namespace bluefish { BLUE_UINT32 bvc_wrapper::get_card_property32(const int iProperty, unsigned int & nValue) { - if (bvc_) - return (BLUE_UINT32)bfcQueryCardProperty32((BLUEVELVETC_HANDLE)bvc_.get(), iProperty, nValue); - else - return 0; + return (BLUE_UINT32)bfcQueryCardProperty32((BLUEVELVETC_HANDLE)bvc_.get(), iProperty, nValue); } BLUE_UINT32 bvc_wrapper::set_card_property32(const int iProperty, const unsigned int nValue)