From 26d89292d72f88af411bbc7c2d95ec0895daa219 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 16 Feb 2022 14:16:46 -0500 Subject: [PATCH] Rework to remove static temp_img_buffer. Is now a class member. Must be allocated as needed. --- src/zm_stream.cpp | 6 ++---- src/zm_stream.h | 7 ++++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/zm_stream.cpp b/src/zm_stream.cpp index 084bd6754..b3b3aa120 100644 --- a/src/zm_stream.cpp +++ b/src/zm_stream.cpp @@ -31,10 +31,8 @@ constexpr Seconds StreamBase::MAX_STREAM_DELAY; constexpr Milliseconds StreamBase::MAX_SLEEP; StreamBase::~StreamBase() { - if (vid_stream) { - delete vid_stream; - vid_stream = nullptr; - } + delete vid_stream; + delete temp_img_buffer; closeComms(); } diff --git a/src/zm_stream.h b/src/zm_stream.h index d89d97e7f..de58fcf7b 100644 --- a/src/zm_stream.h +++ b/src/zm_stream.h @@ -144,6 +144,9 @@ protected: CmdMsg msg; + unsigned char *temp_img_buffer; // Used when encoding or sending file data + size_t temp_img_buffer_size; + protected: bool loadMonitor(int monitor_id); bool checkInitialised(); @@ -182,7 +185,9 @@ public: actual_fps(0.0), frame_count(0), last_frame_count(0), - frame_mod(1) + frame_mod(1), + temp_img_buffer(nullptr), + temp_img_buffer_size(0) { memset(&loc_sock_path, 0, sizeof(loc_sock_path)); memset(&loc_addr, 0, sizeof(loc_addr));