diff --git a/src/face-tracker-monitor.cpp b/src/face-tracker-monitor.cpp index 241c445..3bbceaf 100644 --- a/src/face-tracker-monitor.cpp +++ b/src/face-tracker-monitor.cpp @@ -1,6 +1,7 @@ #include #include #include "plugin-macros.generated.h" +#include "helper.hpp" #define MAX_ERROR 2 @@ -205,15 +206,12 @@ static uint32_t ftmon_get_width(void *data) if (!ph) return 0; - calldata_t cd = {0}; + CALLDATA_FIXED_DECL(cd, 128); if (proc_handler_call(ph, "get_target_size", &cd)) { long long ret; - if (calldata_get_int(&cd, "width", &ret)) { - calldata_free(&cd); - return (int32_t)ret; - } + if (calldata_get_int(&cd, "width", &ret)) + return (uint32_t)ret; } - calldata_free(&cd); } OBSSource source(get_source(s)); @@ -235,15 +233,12 @@ static uint32_t ftmon_get_height(void *data) if (!ph) return 0; - calldata_t cd = {0}; + CALLDATA_FIXED_DECL(cd, 128); if (proc_handler_call(ph, "get_target_size", &cd)) { long long ret; - if (calldata_get_int(&cd, "height", &ret)) { - calldata_free(&cd); - return (int32_t)ret; - } + if (calldata_get_int(&cd, "height", &ret)) + return (uint32_t)ret; } - calldata_free(&cd); } OBSSource source(get_source(s)); @@ -266,7 +261,7 @@ static void ftmon_video_render(void *data, gs_effect_t *) if (!ph) return; - calldata_t cd = {0}; + CALLDATA_FIXED_DECL(cd, 128); calldata_set_bool(&cd, "notrack", s->notrack); if (!s->nosource) { @@ -281,8 +276,6 @@ static void ftmon_video_render(void *data, gs_effect_t *) calldata_set_bool(&cd, "landmark_only", true); proc_handler_call(ph, "render_info", &cd); - - calldata_free(&cd); } extern "C" diff --git a/src/helper.hpp b/src/helper.hpp index f939362..0e48b1e 100644 --- a/src/helper.hpp +++ b/src/helper.hpp @@ -8,6 +8,8 @@ #define DEBUG_DATA_PATH_FILTER "Data Files (*.dat);;TSV Files (*.tsv);;All Files (*.*)" #endif +#define CALLDATA_FIXED_DECL(cd, size) calldata_t cd; uint8_t calldata_##cd##_stack[128]; calldata_init_fixed(&cd, calldata_##cd##_stack, sizeof(calldata_##cd##_stack)); + struct pointf_s { float x; diff --git a/src/obsptz-backend.cpp b/src/obsptz-backend.cpp index aa4c602..b7534dc 100644 --- a/src/obsptz-backend.cpp +++ b/src/obsptz-backend.cpp @@ -3,6 +3,7 @@ #include #include "plugin-macros.generated.h" #include "obsptz-backend.hpp" +#include "helper.hpp" #define debug(...) blog(LOG_INFO, __VA_ARGS__) @@ -43,10 +44,9 @@ proc_handler_t *obsptz_backend::get_ptz_ph() if (!ph) return NULL; - calldata_t cd = {0}; + CALLDATA_FIXED_DECL(cd, 128); proc_handler_call(ph, "ptz_get_proc_handler", &cd); calldata_get_ptr(&cd, "return", &ptz_ph); - calldata_free(&cd); return ptz_ph; } @@ -62,7 +62,7 @@ void obsptz_backend::set_pantilt_speed(int pan, int tilt) same_pantilt_cnt = 0; } - calldata_t cd = {0}; + CALLDATA_FIXED_DECL(cd, 128); calldata_set_int(&cd, "device_id", device_id); calldata_set_float(&cd, "pan", pan / 24.0f); calldata_set_float(&cd, "tilt", -tilt / 20.0f); @@ -74,7 +74,6 @@ void obsptz_backend::set_pantilt_speed(int pan, int tilt) ph = obs_get_proc_handler(); proc_handler_call(ph, "ptz_pantilt", &cd); } - calldata_free(&cd); uint64_t ns = os_gettime_ns(); available_ns = std::max(available_ns, ns) + (60*1000*1000); prev_pan = pan; @@ -96,12 +95,11 @@ void obsptz_backend::set_zoom_speed(int zoom) if (!ph) return; - calldata_t cd = {0}; + CALLDATA_FIXED_DECL(cd, 128); calldata_set_int(&cd, "device_id", device_id); calldata_set_float(&cd, "zoom", -zoom / 7.0f); proc_handler_call(ph, "ptz_move_continuous", &cd); - calldata_free(&cd); uint64_t ns = os_gettime_ns(); available_ns = std::max(available_ns, ns) + (60*1000*1000); prev_zoom = zoom;