From 7e046aa49e70f97aac2adacc5c0bc5f55e52b2a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Bernon?= Date: Tue, 5 Jul 2022 09:53:25 +0200 Subject: [PATCH] winegstreamer: Release requested samples if they are too small. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: RĂ©mi Bernon --- dlls/winegstreamer/wg_allocator.c | 8 +++++++- dlls/winegstreamer/wg_transform.c | 7 +------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/dlls/winegstreamer/wg_allocator.c b/dlls/winegstreamer/wg_allocator.c index c31751ce83f..5b2c48dcf77 100644 --- a/dlls/winegstreamer/wg_allocator.c +++ b/dlls/winegstreamer/wg_allocator.c @@ -150,6 +150,7 @@ static GstMemory *wg_allocator_alloc(GstAllocator *gst_allocator, gsize size, GstAllocationParams *params) { WgAllocator *allocator = (WgAllocator *)gst_allocator; + struct wg_sample *sample; WgMemory *memory; GST_LOG("allocator %p, size %#zx, params %p", allocator, size, params); @@ -162,7 +163,12 @@ static GstMemory *wg_allocator_alloc(GstAllocator *gst_allocator, gsize size, pthread_mutex_lock(&allocator->mutex); - memory->sample = allocator->request_sample(size, allocator->request_sample_context); + sample = allocator->request_sample(size, allocator->request_sample_context); + if (sample->max_size < size) + InterlockedDecrement(&sample->refcount); + else + memory->sample = sample; + list_add_tail(&allocator->memory_list, &memory->entry); pthread_mutex_unlock(&allocator->mutex); diff --git a/dlls/winegstreamer/wg_transform.c b/dlls/winegstreamer/wg_transform.c index e05432f6ac7..adefd16c787 100644 --- a/dlls/winegstreamer/wg_transform.c +++ b/dlls/winegstreamer/wg_transform.c @@ -310,15 +310,10 @@ static bool transform_append_element(struct wg_transform *transform, GstElement static struct wg_sample *transform_request_sample(gsize size, void *context) { struct wg_transform *transform = context; - struct wg_sample *sample; GST_LOG("size %#zx, context %p", size, transform); - sample = InterlockedExchangePointer((void **)&transform->output_wg_sample, NULL); - if (!sample || sample->max_size < size) - return NULL; - - return sample; + return InterlockedExchangePointer((void **)&transform->output_wg_sample, NULL); } NTSTATUS wg_transform_create(void *args)