screencopy: Release front buffer on screencopy_stop()

pull/58/head
Andri Yngvason 2020-07-19 14:37:48 +00:00
parent c79eb98e68
commit 4a5838c180
1 changed files with 13 additions and 4 deletions

View File

@ -35,7 +35,7 @@
#define DELAY_SMOOTHER_TIME_CONSTANT 0.5 // s #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); 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, static void screencopy_linux_dmabuf(void* data,
struct zwlr_screencopy_frame_v1* frame, struct zwlr_screencopy_frame_v1* frame,
uint32_t format, uint32_t width, uint32_t height) 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); struct wv_buffer* buffer = wv_buffer_pool_acquire(self->pool);
if (!buffer) { if (!buffer) {
screencopy_stop(self); screencopy__stop(self);
self->status = SCREENCOPY_FATAL; self->status = SCREENCOPY_FATAL;
self->on_done(self); self->on_done(self);
return; return;
@ -145,7 +154,7 @@ static void screencopy_ready(void* data,
DTRACE_PROBE1(wayvnc, screencopy_ready, self); DTRACE_PROBE1(wayvnc, screencopy_ready, self);
screencopy_stop(self); screencopy__stop(self);
self->last_time = gettime_us(); self->last_time = gettime_us();
@ -173,7 +182,7 @@ static void screencopy_failed(void* data,
DTRACE_PROBE1(wayvnc, screencopy_failed, self); DTRACE_PROBE1(wayvnc, screencopy_failed, self);
screencopy_stop(self); screencopy__stop(self);
wv_buffer_pool_release(self->pool, self->front); wv_buffer_pool_release(self->pool, self->front);
self->front = NULL; self->front = NULL;