Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/winegstreamer/gstdemux.c | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-)
diff --git a/dlls/winegstreamer/gstdemux.c b/dlls/winegstreamer/gstdemux.c index 45bd2f9a4a9..31f0a07d93f 100644 --- a/dlls/winegstreamer/gstdemux.c +++ b/dlls/winegstreamer/gstdemux.c @@ -636,9 +636,8 @@ static gboolean query_sink(GstPad *pad, GstObject *parent, GstQuery *query) } }
-static gboolean gst_base_src_perform_seek(struct parser *This, GstEvent *event) +static gboolean gst_base_src_perform_seek(struct wg_parser *parser, GstEvent *event) { - struct wg_parser *parser = This->wg_parser; gboolean res = TRUE; gdouble rate; GstFormat seek_format; @@ -687,15 +686,15 @@ static gboolean gst_base_src_perform_seek(struct parser *This, GstEvent *event)
static gboolean event_src(GstPad *pad, GstObject *parent, GstEvent *event) { - struct parser *This = gst_pad_get_element_private(pad); + struct wg_parser *parser = gst_pad_get_element_private(pad); gboolean ret = TRUE;
- GST_LOG("filter %p, type "%s".", This, GST_EVENT_TYPE_NAME(event)); + GST_LOG("parser %p, type "%s".", parser, GST_EVENT_TYPE_NAME(event));
switch (event->type) { case GST_EVENT_SEEK: - ret = gst_base_src_perform_seek(This, event); + ret = gst_base_src_perform_seek(parser, event); break;
case GST_EVENT_FLUSH_START: @@ -848,10 +847,9 @@ static gboolean event_sink(GstPad *pad, GstObject *parent, GstEvent *event)
static GstFlowReturn request_buffer_src(GstPad *pad, GstObject *parent, guint64 offset, guint size, GstBuffer **buffer);
-static void *push_data(void *iface) +static void *push_data(void *arg) { - struct parser *This = iface; - struct wg_parser *parser = This->wg_parser; + struct wg_parser *parser = arg; GstBuffer *buffer; LONGLONG maxlen;
@@ -1125,8 +1123,7 @@ static DWORD CALLBACK stream_thread(void *arg)
static GstFlowReturn request_buffer_src(GstPad *pad, GstObject *parent, guint64 offset, guint size, GstBuffer **buffer) { - struct parser *filter = gst_pad_get_element_private(pad); - struct wg_parser *parser = filter->wg_parser; + struct wg_parser *parser = gst_pad_get_element_private(pad); GstBuffer *new_buffer = NULL; GstFlowReturn ret;
@@ -1414,11 +1411,10 @@ static void existing_new_pad(GstElement *bin, GstPad *pad, gpointer user)
static gboolean query_function(GstPad *pad, GstObject *parent, GstQuery *query) { - struct parser *This = gst_pad_get_element_private(pad); - struct wg_parser *parser = This->wg_parser; + struct wg_parser *parser = gst_pad_get_element_private(pad); GstFormat format;
- GST_LOG("filter %p, type %s.", This, GST_QUERY_TYPE_NAME(query)); + GST_LOG("parser %p, type %s.", parser, GST_QUERY_TYPE_NAME(query));
switch (GST_QUERY_TYPE(query)) { case GST_QUERY_DURATION: @@ -1456,8 +1452,7 @@ static gboolean query_function(GstPad *pad, GstObject *parent, GstQuery *query)
static gboolean activate_push(GstPad *pad, gboolean activate) { - struct parser *This = gst_pad_get_element_private(pad); - struct wg_parser *parser = This->wg_parser; + struct wg_parser *parser = gst_pad_get_element_private(pad);
if (!activate) { if (parser->push_thread) { @@ -1467,7 +1462,7 @@ static gboolean activate_push(GstPad *pad, gboolean activate) } else if (!parser->push_thread) { int ret;
- if ((ret = pthread_create(&parser->push_thread, NULL, push_data, This))) + if ((ret = pthread_create(&parser->push_thread, NULL, push_data, parser))) { GST_ERROR("Failed to create push thread: %s", strerror(errno)); parser->push_thread = 0; @@ -1479,10 +1474,10 @@ static gboolean activate_push(GstPad *pad, gboolean activate)
static gboolean activate_mode(GstPad *pad, GstObject *parent, GstPadMode mode, gboolean activate) { - struct parser *filter = gst_pad_get_element_private(pad); + struct wg_parser *parser = gst_pad_get_element_private(pad);
- GST_DEBUG("%s source pad for filter %p in %s mode.", - activate ? "Activating" : "Deactivating", filter, gst_pad_mode_get_name(mode)); + GST_DEBUG("%s source pad for parser %p in %s mode.", + activate ? "Activating" : "Deactivating", parser, gst_pad_mode_get_name(mode));
switch (mode) { case GST_PAD_MODE_PULL: @@ -1625,7 +1620,7 @@ static HRESULT GST_Connect(struct parser *This, IPin *pConnectPin) gst_pad_set_query_function(parser->my_src, query_function); gst_pad_set_activatemode_function(parser->my_src, activate_mode); gst_pad_set_event_function(parser->my_src, event_src); - gst_pad_set_element_private (parser->my_src, This); + gst_pad_set_element_private(parser->my_src, parser);
parser->start_offset = parser->next_offset = parser->stop_offset = 0; This->next_pull_offset = 0;
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/winegstreamer/gstdemux.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/dlls/winegstreamer/gstdemux.c b/dlls/winegstreamer/gstdemux.c index 31f0a07d93f..d9cc072a8c7 100644 --- a/dlls/winegstreamer/gstdemux.c +++ b/dlls/winegstreamer/gstdemux.c @@ -48,6 +48,9 @@ static const GUID MEDIASUBTYPE_CVID = {mmioFOURCC('c','v','i','d'), 0x0000, 0x00
struct wg_parser { + struct wg_parser_stream **streams; + unsigned int stream_count; + GstElement *container; GstBus *bus; GstPad *my_src, *their_sink; @@ -2505,14 +2508,20 @@ static const struct strmbase_source_ops source_ops =
static struct parser_source *create_pin(struct parser *filter, const WCHAR *name) { - struct parser_source *pin, **new_array; + struct wg_parser *parser = filter->wg_parser; struct wg_parser_stream *stream; + struct parser_source *pin; char pad_name[19]; + void *new_array;
- if (!(new_array = heap_realloc(filter->sources, (filter->source_count + 1) * sizeof(*new_array)))) + if (!(new_array = heap_realloc(filter->sources, (filter->source_count + 1) * sizeof(*filter->sources)))) return NULL; filter->sources = new_array;
+ if (!(new_array = realloc(parser->streams, (parser->stream_count + 1) * sizeof(*parser->streams)))) + return NULL; + parser->streams = new_array; + if (!(pin = heap_alloc_zero(sizeof(*pin)))) return NULL;
@@ -2544,6 +2553,7 @@ static struct parser_source *create_pin(struct parser *filter, const WCHAR *name gst_pad_set_query_function(stream->my_sink, query_sink_wrapper);
filter->sources[filter->source_count++] = pin; + parser->streams[parser->stream_count++] = stream; return pin; }
@@ -2589,6 +2599,9 @@ static HRESULT GST_RemoveOutputPins(struct parser *This) This->source_count = 0; heap_free(This->sources); This->sources = NULL; + parser->stream_count = 0; + free(parser->streams); + parser->streams = NULL; gst_element_set_bus(parser->container, NULL); gst_object_unref(parser->container); parser->container = NULL;
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/winegstreamer/gstdemux.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/dlls/winegstreamer/gstdemux.c b/dlls/winegstreamer/gstdemux.c index d9cc072a8c7..a63e91c9a65 100644 --- a/dlls/winegstreamer/gstdemux.c +++ b/dlls/winegstreamer/gstdemux.c @@ -110,6 +110,8 @@ struct wg_parser_stream struct wg_parser_event event;
bool flushing, eos, enabled; + + uint64_t duration; };
struct parser @@ -1638,7 +1640,8 @@ static HRESULT GST_Connect(struct parser *This, IPin *pConnectPin) struct parser_source *pin = This->sources[i]; struct wg_parser_stream *stream = pin->wg_stream;
- pin->seek.llDuration = pin->seek.llStop = query_duration(stream->their_src); + stream->duration = query_duration(stream->their_src); + pin->seek.llDuration = pin->seek.llStop = stream->duration; pin->seek.llCurrent = 0; while (!stream->caps && !parser->error) pthread_cond_wait(&parser->init_cond, &parser->mutex);
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/winegstreamer/gstdemux.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-)
diff --git a/dlls/winegstreamer/gstdemux.c b/dlls/winegstreamer/gstdemux.c index a63e91c9a65..fdc10f72802 100644 --- a/dlls/winegstreamer/gstdemux.c +++ b/dlls/winegstreamer/gstdemux.c @@ -1228,14 +1228,15 @@ static DWORD CALLBACK read_thread(void *arg) static void removed_decoded_pad(GstElement *bin, GstPad *pad, gpointer user) { struct parser *filter = user; + struct wg_parser *parser = filter->wg_parser; unsigned int i; char *name;
GST_LOG("filter %p, bin %p, pad %p.", filter, bin, pad);
- for (i = 0; i < filter->source_count; ++i) + for (i = 0; i < parser->stream_count; ++i) { - struct wg_parser_stream *stream = filter->sources[i]->wg_stream; + struct wg_parser_stream *stream = parser->streams[i];
if (stream->their_src == pad) { @@ -1785,14 +1786,12 @@ static HRESULT parser_cleanup_stream(struct strmbase_filter *iface) parser->flushing = true; pthread_mutex_unlock(&parser->mutex);
- for (i = 0; i < filter->source_count; ++i) + for (i = 0; i < parser->stream_count; ++i) { - struct parser_source *pin = filter->sources[i]; + struct wg_parser_stream *stream = parser->streams[i];
- if (!pin->pin.pin.peer) - continue; - - pthread_cond_signal(&pin->wg_stream->event_cond); + if (stream->enabled) + pthread_cond_signal(&stream->event_cond); }
for (i = 0; i < filter->source_count; ++i) @@ -2573,10 +2572,10 @@ static HRESULT GST_RemoveOutputPins(struct parser *This)
/* Unblock all of our streams. */ pthread_mutex_lock(&parser->mutex); - for (i = 0; i < This->source_count; ++i) + for (i = 0; i < parser->stream_count; ++i) { - This->sources[i]->wg_stream->flushing = true; - pthread_cond_signal(&This->sources[i]->wg_stream->event_empty_cond); + parser->streams[i]->flushing = true; + pthread_cond_signal(&parser->streams[i]->event_empty_cond); } pthread_mutex_unlock(&parser->mutex);
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/winegstreamer/gstdemux.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-)
diff --git a/dlls/winegstreamer/gstdemux.c b/dlls/winegstreamer/gstdemux.c index fdc10f72802..7b3a4fd48bd 100644 --- a/dlls/winegstreamer/gstdemux.c +++ b/dlls/winegstreamer/gstdemux.c @@ -2456,17 +2456,8 @@ static void source_disconnect(struct strmbase_source *iface) stream->enabled = false; }
-static void free_source_pin(struct parser_source *pin) +static void free_stream(struct wg_parser_stream *stream) { - struct wg_parser_stream *stream = pin->wg_stream; - - if (pin->pin.pin.peer) - { - if (SUCCEEDED(IMemAllocator_Decommit(pin->pin.pAllocator))) - IPin_Disconnect(pin->pin.pin.peer); - IPin_Disconnect(&pin->pin.pin.IPin_iface); - } - if (stream->their_src) { if (stream->post_sink) @@ -2488,6 +2479,18 @@ static void free_source_pin(struct parser_source *pin) pthread_cond_destroy(&stream->event_empty_cond);
free(stream); +} + +static void free_source_pin(struct parser_source *pin) +{ + if (pin->pin.pin.peer) + { + if (SUCCEEDED(IMemAllocator_Decommit(pin->pin.pAllocator))) + IPin_Disconnect(pin->pin.pin.peer); + IPin_Disconnect(&pin->pin.pin.IPin_iface); + } + + free_stream(pin->wg_stream);
pin->flushing_cs.DebugInfo->Spare[0] = 0; DeleteCriticalSection(&pin->flushing_cs);