Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51931 Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52391 Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/winegstreamer/wg_transform.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)
diff --git a/dlls/winegstreamer/wg_transform.c b/dlls/winegstreamer/wg_transform.c index a4a4d886865..ed4f95afde3 100644 --- a/dlls/winegstreamer/wg_transform.c +++ b/dlls/winegstreamer/wg_transform.c @@ -39,23 +39,44 @@
#include "unix_private.h"
+#include "wine/list.h" + GST_DEBUG_CATEGORY_EXTERN(wine); #define GST_CAT_DEFAULT wine
+struct sample_entry +{ + struct list entry; + GstSample *sample; +}; + struct wg_transform { GstElement *container; GstPad *my_src, *my_sink; GstPad *their_sink, *their_src; GstSegment segment; + pthread_mutex_t mutex; + struct list samples; };
static GstFlowReturn transform_sink_chain_cb(GstPad *pad, GstObject *parent, GstBuffer *buffer) { struct wg_transform *transform = gst_pad_get_element_private(pad); + struct sample_entry *entry;
GST_INFO("transform %p, buffer %p.", transform, buffer);
+ if (!(entry = calloc(1, sizeof(*entry)))) + GST_ERROR("Failed to allocate sample entry"); + else + { + pthread_mutex_lock(&transform->mutex); + entry->sample = gst_sample_new(buffer, NULL, NULL, NULL); + list_add_tail(&transform->samples, &entry->entry); + pthread_mutex_unlock(&transform->mutex); + } + gst_buffer_unref(buffer);
return GST_FLOW_OK; @@ -64,8 +85,14 @@ static GstFlowReturn transform_sink_chain_cb(GstPad *pad, GstObject *parent, Gst NTSTATUS wg_transform_destroy(void *args) { struct wg_transform *transform = args; + struct sample_entry *entry, *next;
gst_element_set_state(transform->container, GST_STATE_NULL); + LIST_FOR_EACH_ENTRY_SAFE(entry, next, &transform->samples, struct sample_entry, entry) + { + gst_sample_unref(entry->sample); + free(entry); + } gst_pad_unlink(transform->their_src, transform->my_sink); gst_pad_unlink(transform->my_src, transform->their_sink); g_object_unref(transform->their_sink); @@ -73,6 +100,7 @@ NTSTATUS wg_transform_destroy(void *args) g_object_unref(transform->container); g_object_unref(transform->my_sink); g_object_unref(transform->my_src); + pthread_mutex_destroy(&transform->mutex); free(transform);
return STATUS_SUCCESS; @@ -281,6 +309,9 @@ NTSTATUS wg_transform_create(void *args) gst_caps_unref(sink_caps); gst_caps_unref(src_caps);
+ pthread_mutex_init(&transform->mutex, NULL); + list_init(&transform->samples); + GST_INFO("Created winegstreamer transform %p.", transform); params->transform = transform; return STATUS_SUCCESS;