[PATCH v6 2/3] winegstreamer: Release requested samples if they are too small.

Rémi Bernon wine at gitlab.winehq.org
Tue Jul 5 03:33:34 CDT 2022


From: Rémi Bernon <rbernon at codeweavers.com>

Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---
 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)
-- 
GitLab


https://gitlab.winehq.org/wine/wine/-/merge_requests/302



More information about the wine-devel mailing list