From 40e90ea271946f7e7df6e378b252c22b1d09fe4e Mon Sep 17 00:00:00 2001 From: James Wise Date: Tue, 7 Feb 2017 13:48:48 +1100 Subject: [PATCH 1/1] more refinements to code due to move to RAII --- modules/bluefish/bluefish.cpp | 7 +++---- modules/bluefish/util/blue_velvet.cpp | 11 ++++------- 2 files changed, 7 insertions(+), 11 deletions(-) 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) -- 2.39.2