diff --git a/source/filters/filter-color-grade.cpp b/source/filters/filter-color-grade.cpp index 35daec38..c03e0d99 100644 --- a/source/filters/filter-color-grade.cpp +++ b/source/filters/filter-color-grade.cpp @@ -74,13 +74,17 @@ #define MODE_LOG Log #define MODE_LOG10 Log10 -const char* get_name(void*) -{ +static const char* get_name(void*) noexcept try { return D_TRANSLATE(ST); +} catch (const std::exception& ex) { + P_LOG_ERROR("Unexpected exception in function '%s': %s.", __FUNCTION_NAME__, ex.what()); + return ""; +} catch (...) { + P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); + return ""; } -void get_defaults(obs_data_t* data) -{ +static void get_defaults(obs_data_t* data) noexcept try { obs_data_set_default_string(data, ST_TOOL, ST_CORRECTION); obs_data_set_default_double(data, ST_LIFT_(RED), 0); obs_data_set_default_double(data, ST_LIFT_(GREEN), 0); @@ -115,10 +119,13 @@ void get_defaults(obs_data_t* data) obs_data_set_default_double(data, ST_CORRECTION_(SATURATION), 100.0); obs_data_set_default_double(data, ST_CORRECTION_(LIGHTNESS), 100.0); obs_data_set_default_double(data, ST_CORRECTION_(CONTRAST), 100.0); +} catch (const std::exception& ex) { + P_LOG_ERROR("Unexpected exception in function '%s': %s.", __FUNCTION_NAME__, ex.what()); +} catch (...) { + P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); } -bool tool_modified(obs_properties_t* props, obs_property_t* property, obs_data_t* settings) -{ +static bool tool_modified(obs_properties_t* props, obs_property_t* property, obs_data_t* settings) noexcept try { const std::string mode{obs_data_get_string(settings, ST_TOOL)}; std::vector>> tool_to_property{ @@ -163,10 +170,15 @@ bool tool_modified(obs_properties_t* props, obs_property_t* property, obs_data_t } return true; +} catch (const std::exception& ex) { + P_LOG_ERROR("Unexpected exception in function '%s': %s.", __FUNCTION_NAME__, ex.what()); + return false; +} catch (...) { + P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); + return false; } -obs_properties_t* get_properties(void*) -{ +static obs_properties_t* get_properties(void*) noexcept try { obs_properties_t* pr = obs_properties_create(); if (util::are_property_groups_broken()) { @@ -316,72 +328,70 @@ obs_properties_t* get_properties(void*) } return pr; -} - -void* create(obs_data_t* data, obs_source_t* source) -try { - return new filter::color_grade::color_grade_instance(data, source); -} catch (std::exception& ex) { - P_LOG_ERROR(" Failed to create: %s", obs_source_get_name(source), ex.what()); +} catch (const std::exception& ex) { + P_LOG_ERROR("Unexpected exception in function '%s': %s.", __FUNCTION_NAME__, ex.what()); + return nullptr; +} catch (...) { + P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); return nullptr; } -void destroy(void* ptr) -try { +static void* create(obs_data_t* data, obs_source_t* source) noexcept try { + return new filter::color_grade::color_grade_instance(data, source); +} catch (const std::exception& ex) { + P_LOG_ERROR("Unexpected exception in function '%s': %s.", __FUNCTION_NAME__, ex.what()); + return nullptr; +} catch (...) { + P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); + return nullptr; +} + +static void destroy(void* ptr) noexcept try { delete reinterpret_cast(ptr); -} catch (std::exception& ex) { - P_LOG_ERROR(" Failed to destroy: %s", ex.what()); +} catch (const std::exception& ex) { + P_LOG_ERROR("Unexpected exception in function '%s': %s.", __FUNCTION_NAME__, ex.what()); +} catch (...) { + P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); } -uint32_t get_width(void* ptr) -try { - return reinterpret_cast(ptr)->get_width(); -} catch (std::exception& ex) { - P_LOG_ERROR(" Failed to get width: %s", ex.what()); - return 0; -} - -uint32_t get_height(void* ptr) -try { - return reinterpret_cast(ptr)->get_height(); -} catch (std::exception& ex) { - P_LOG_ERROR(" Failed to get height: %s", ex.what()); - return 0; -} - -void update(void* ptr, obs_data_t* data) -try { +static void update(void* ptr, obs_data_t* data) try { reinterpret_cast(ptr)->update(data); -} catch (std::exception& ex) { - P_LOG_ERROR(" Failed to update: %s", ex.what()); +} catch (const std::exception& ex) { + P_LOG_ERROR("Unexpected exception in function '%s': %s.", __FUNCTION_NAME__, ex.what()); +} catch (...) { + P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); } -void activate(void* ptr) -try { +static void activate(void* ptr) try { reinterpret_cast(ptr)->activate(); -} catch (std::exception& ex) { - P_LOG_ERROR(" Failed to activate: %s", ex.what()); +} catch (const std::exception& ex) { + P_LOG_ERROR("Unexpected exception in function '%s': %s.", __FUNCTION_NAME__, ex.what()); +} catch (...) { + P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); } -void deactivate(void* ptr) -try { +static void deactivate(void* ptr) try { reinterpret_cast(ptr)->deactivate(); -} catch (std::exception& ex) { - P_LOG_ERROR(" Failed to deactivate: %s", ex.what()); +} catch (const std::exception& ex) { + P_LOG_ERROR("Unexpected exception in function '%s': %s.", __FUNCTION_NAME__, ex.what()); +} catch (...) { + P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); } -void video_tick(void* ptr, float time) -try { +static void video_tick(void* ptr, float time) try { reinterpret_cast(ptr)->video_tick(time); -} catch (std::exception& ex) { - P_LOG_ERROR(" Failed to tick video: %s", ex.what()); +} catch (const std::exception& ex) { + P_LOG_ERROR("Unexpected exception in function '%s': %s.", __FUNCTION_NAME__, ex.what()); +} catch (...) { + P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); } -void video_render(void* ptr, gs_effect_t* effect) -try { +static void video_render(void* ptr, gs_effect_t* effect) try { reinterpret_cast(ptr)->video_render(effect); -} catch (std::exception& ex) { - P_LOG_ERROR(" Failed to render video: %s", ex.what()); +} catch (const std::exception& ex) { + P_LOG_ERROR("Unexpected exception in function '%s': %s.", __FUNCTION_NAME__, ex.what()); +} catch (...) { + P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); } static std::shared_ptr factory_instance = nullptr;