From 4a5838c1804492f5773afe9e7873b6080ee4a34a Mon Sep 17 00:00:00 2001 From: Andri Yngvason Date: Sun, 19 Jul 2020 14:37:48 +0000 Subject: [PATCH] screencopy: Release front buffer on screencopy_stop() --- src/screencopy.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/screencopy.c b/src/screencopy.c index cdacdf6..d8015c3 100644 --- a/src/screencopy.c +++ b/src/screencopy.c @@ -35,7 +35,7 @@ #define DELAY_SMOOTHER_TIME_CONSTANT 0.5 // s -void screencopy_stop(struct screencopy* self) +static void screencopy__stop(struct screencopy* self) { aml_stop(aml_get_default(), self->timer); @@ -47,6 +47,15 @@ void screencopy_stop(struct screencopy* self) } } +void screencopy_stop(struct screencopy* self) +{ + if (self->front) + wv_buffer_pool_release(self->pool, self->front); + self->front = NULL; + + return screencopy__stop(self); +} + static void screencopy_linux_dmabuf(void* data, struct zwlr_screencopy_frame_v1* frame, uint32_t format, uint32_t width, uint32_t height) @@ -86,7 +95,7 @@ static void screencopy_buffer_done(void* data, struct wv_buffer* buffer = wv_buffer_pool_acquire(self->pool); if (!buffer) { - screencopy_stop(self); + screencopy__stop(self); self->status = SCREENCOPY_FATAL; self->on_done(self); return; @@ -145,7 +154,7 @@ static void screencopy_ready(void* data, DTRACE_PROBE1(wayvnc, screencopy_ready, self); - screencopy_stop(self); + screencopy__stop(self); self->last_time = gettime_us(); @@ -173,7 +182,7 @@ static void screencopy_failed(void* data, DTRACE_PROBE1(wayvnc, screencopy_failed, self); - screencopy_stop(self); + screencopy__stop(self); wv_buffer_pool_release(self->pool, self->front); self->front = NULL;