winegstreamer: Release requested samples if they are too small.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
This commit is contained in:
Rémi Bernon 2022-07-05 09:53:25 +02:00 committed by Alexandre Julliard
parent 7187965a75
commit 7e046aa49e
2 changed files with 8 additions and 7 deletions

View file

@ -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);

View file

@ -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)