Commit 7e046aa4 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

winegstreamer: Release requested samples if they are too small.

parent 7187965a
......@@ -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);
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment