Unset holdbuffer so that when we connect, we reset the shm buffer pointer. cleanup initializers in Image

This commit is contained in:
Isaac Connor 2022-01-19 15:01:37 -05:00
parent 05043a37b1
commit dec440ead1
3 changed files with 23 additions and 19 deletions

View File

@ -114,22 +114,23 @@ Image::Image() :
delta8_argb(&std_delta8_argb),
delta8_abgr(&std_delta8_abgr),
delta8_gray8(&std_delta8_gray8),
blend(&std_blend)
blend(&std_blend),
width(0),
linesize(0),
height(0),
pixels(0),
colours(0),
padding(0),
size(0),
subpixelorder(0),
allocation(0),
buffer(nullptr),
buffertype(ZM_BUFTYPE_DONTFREE),
holdbuffer(0)
{
if ( !initialised )
if (!initialised)
Initialise();
width = 0;
linesize = 0;
height = 0;
padding = 0;
pixels = 0;
colours = 0;
subpixelorder = 0;
size = 0;
allocation = 0;
buffer = 0;
buffertype = ZM_BUFTYPE_DONTFREE;
holdbuffer = 0;
// Update blend to fast function determined by Initialise, I'm sure this can be improve.
blend = fptr_blend;
}
@ -158,15 +159,15 @@ Image::Image(int p_width, int p_height, int p_colours, int p_subpixelorder, uint
colours(p_colours),
padding(p_padding),
subpixelorder(p_subpixelorder),
buffer(p_buffer) {
buffer(p_buffer),
holdbuffer(0)
{
if (!initialised)
Initialise();
pixels = width * height;
linesize = p_width * p_colours;
size = linesize * height + padding;
buffer = nullptr;
holdbuffer = 0;
if (p_buffer) {
allocation = size;
buffertype = ZM_BUFTYPE_DONTFREE;
@ -174,7 +175,7 @@ Image::Image(int p_width, int p_height, int p_colours, int p_subpixelorder, uint
} else {
AllocImgBuffer(size);
}
if (!subpixelorder and colours>1) {
if (!subpixelorder and (colours>1)) {
// Default to RGBA when no subpixelorder is specified.
subpixelorder = ZM_SUBPIX_ORDER_RGBA;
}

View File

@ -145,10 +145,12 @@ class Image {
explicit Image(const AVFrame *frame);
~Image();
static void Initialise();
static void Deinitialise();
inline void DumpImgBuffer() {
if (buffertype != ZM_BUFTYPE_DONTFREE)
DumpBuffer(buffer, buffertype);
buffertype = ZM_BUFTYPE_DONTFREE;
buffer = nullptr;

View File

@ -1153,6 +1153,7 @@ bool Monitor::disconnect() {
}
if (purpose == CAPTURE) {
alarm_image.HoldBuffer(false); /* Allow to reset buffer */
if (unlink(mem_file.c_str()) < 0) {
Warning("Can't unlink '%s': %s", mem_file.c_str(), strerror(errno));
}