From 0557730fc12abd0509fdeaba006fd00357c9e474 Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Fri, 8 Mar 2024 11:24:51 +0100 Subject: [PATCH] video_compress: del state with compress_done The whole stuff with generic modules is mostly abandoned and module::deleter should not be used, anyways. --- src/video_compress.cpp | 21 ++++++++------------- src/video_compress.h | 3 ++- src/video_rxtx.cpp | 4 ++-- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/src/video_compress.cpp b/src/video_compress.cpp index 97f9d2ddde..a910559d66 100644 --- a/src/video_compress.cpp +++ b/src/video_compress.cpp @@ -6,7 +6,7 @@ * @brief Video compress functions. */ /* - * Copyright (c) 2011-2023 CESNET z.s.p.o. + * Copyright (c) 2011-2024 CESNET z.s.p.o. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -37,18 +37,13 @@ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#include "config_unix.h" -#include "config_win32.h" -#endif // HAVE_CONFIG_H #include #include +#include +#include #include -#include #include -#include #include #include @@ -111,7 +106,6 @@ struct compress_state { static shared_ptr compress_frame_tiles(struct compress_state *proxy, shared_ptr frame); -static void compress_done(struct module *mod); /// @brief Displays list of available compressions. void show_compress_help(bool full) @@ -203,7 +197,6 @@ int compress_init(struct module *parent, const char *config_string, struct compr module_init_default(&proxy->mod); proxy->mod.cls = MODULE_CLASS_COMPRESS; proxy->mod.priv_data = proxy; - proxy->mod.deleter = compress_done; try { proxy->ptr = compress_state_real::create(&proxy->mod, config_string, proxy); @@ -486,18 +479,20 @@ static shared_ptr compress_frame_tiles(struct compress_state *proxy * @brief Video compression cleanup function. * @param mod video compress module */ -static void compress_done(struct module *mod) +void +compress_done(struct compress_state *proxy) { - if(!mod) + if (proxy == nullptr) { return; + } - struct compress_state *proxy = (struct compress_state *) mod->priv_data; struct compress_state_real *s = proxy->ptr; if (!proxy->poisoned) { // pass poisoned pill if it wasn't compress_frame(proxy, {}); } delete s; + module_done(&proxy->mod); delete proxy; } diff --git a/src/video_compress.h b/src/video_compress.h index fe238787c3..08ae836b8b 100644 --- a/src/video_compress.h +++ b/src/video_compress.h @@ -8,7 +8,7 @@ * @brief API for video compress drivers. */ /* - * Copyright (c) 2009-2023 CESNET, z. s. p. o. + * Copyright (c) 2009-2024 CESNET, z. s. p. o. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -93,6 +93,7 @@ typedef struct module *(*compress_init_t)(struct module *parent, void show_compress_help(bool full); // documented at definition int compress_init(struct module *parent, const char *config_string, struct compress_state **); +void compress_done(struct compress_state *); #ifdef __cplusplus } #endif diff --git a/src/video_rxtx.cpp b/src/video_rxtx.cpp index 3262a06e11..c8c42191c5 100644 --- a/src/video_rxtx.cpp +++ b/src/video_rxtx.cpp @@ -96,7 +96,7 @@ video_rxtx::video_rxtx(map const ¶ms): m_port_id("default") } catch (...) { if (m_compression) { - module_done(CAST_MODULE(m_compression)); + compress_done(m_compression); } module_done(&m_receiver_mod); @@ -112,7 +112,7 @@ video_rxtx::~video_rxtx() { send(NULL); compress_pop(m_compression); } - module_done(CAST_MODULE(m_compression)); + compress_done(m_compression); module_done(&m_receiver_mod); module_done(&m_sender_mod); }