Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/winegstreamer/gstdemux.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/dlls/winegstreamer/gstdemux.c b/dlls/winegstreamer/gstdemux.c index e85e54c2e34..56b8225c3df 100644 --- a/dlls/winegstreamer/gstdemux.c +++ b/dlls/winegstreamer/gstdemux.c @@ -1398,7 +1398,8 @@ static gboolean activate_mode(GstPad *pad, GstObject *parent, GstPadMode mode, g static void no_more_pads(GstElement *decodebin, gpointer user) { struct parser *filter = user; - TRACE("filter %p.\n", filter); + + GST_DEBUG("filter %p.", filter);
pthread_mutex_lock(&filter->mutex); filter->no_more_pads = true;
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/winegstreamer/gst_cbs.c | 10 ---------- dlls/winegstreamer/gst_cbs.h | 2 -- dlls/winegstreamer/gstdemux.c | 10 ++-------- 3 files changed, 2 insertions(+), 20 deletions(-)
diff --git a/dlls/winegstreamer/gst_cbs.c b/dlls/winegstreamer/gst_cbs.c index b9effe73a5b..ebef533779d 100644 --- a/dlls/winegstreamer/gst_cbs.c +++ b/dlls/winegstreamer/gst_cbs.c @@ -174,16 +174,6 @@ gboolean activate_mode_wrapper(GstPad *pad, GstObject *parent, GstPadMode mode, return cbdata.u.activate_mode_data.ret; }
-void no_more_pads_wrapper(GstElement *element, gpointer user) -{ - struct cb_data cbdata = { NO_MORE_PADS }; - - cbdata.u.no_more_pads_data.element = element; - cbdata.u.no_more_pads_data.user = user; - - call_cb(&cbdata); -} - GstFlowReturn request_buffer_src_wrapper(GstPad *pad, GstObject *parent, guint64 ofs, guint len, GstBuffer **buf) { diff --git a/dlls/winegstreamer/gst_cbs.h b/dlls/winegstreamer/gst_cbs.h index 0e262c12db8..ce74e76edae 100644 --- a/dlls/winegstreamer/gst_cbs.h +++ b/dlls/winegstreamer/gst_cbs.h @@ -33,7 +33,6 @@ enum CB_TYPE { EXISTING_NEW_PAD, QUERY_FUNCTION, ACTIVATE_MODE, - NO_MORE_PADS, REQUEST_BUFFER_SRC, EVENT_SRC, EVENT_SINK, @@ -135,7 +134,6 @@ void perform_cb_media_source(struct cb_data *data) DECLSPEC_HIDDEN; void existing_new_pad_wrapper(GstElement *bin, GstPad *pad, gpointer user) DECLSPEC_HIDDEN; gboolean query_function_wrapper(GstPad *pad, GstObject *parent, GstQuery *query) DECLSPEC_HIDDEN; gboolean activate_mode_wrapper(GstPad *pad, GstObject *parent, GstPadMode mode, gboolean activate) DECLSPEC_HIDDEN; -void no_more_pads_wrapper(GstElement *decodebin, gpointer user) DECLSPEC_HIDDEN; GstFlowReturn request_buffer_src_wrapper(GstPad *pad, GstObject *parent, guint64 ofs, guint len, GstBuffer **buf) DECLSPEC_HIDDEN; gboolean event_src_wrapper(GstPad *pad, GstObject *parent, GstEvent *event) DECLSPEC_HIDDEN; gboolean event_sink_wrapper(GstPad *pad, GstObject *parent, GstEvent *event) DECLSPEC_HIDDEN; diff --git a/dlls/winegstreamer/gstdemux.c b/dlls/winegstreamer/gstdemux.c index 56b8225c3df..22df838e4df 100644 --- a/dlls/winegstreamer/gstdemux.c +++ b/dlls/winegstreamer/gstdemux.c @@ -1765,7 +1765,7 @@ static BOOL decodebin_parser_init_gst(struct parser *filter) g_signal_connect(element, "pad-added", G_CALLBACK(existing_new_pad_wrapper), filter); g_signal_connect(element, "pad-removed", G_CALLBACK(removed_decoded_pad_wrapper), filter); g_signal_connect(element, "autoplug-select", G_CALLBACK(autoplug_blacklist), filter); - g_signal_connect(element, "no-more-pads", G_CALLBACK(no_more_pads_wrapper), filter); + g_signal_connect(element, "no-more-pads", G_CALLBACK(no_more_pads), filter);
filter->their_sink = gst_element_get_static_pad(element, "sink");
@@ -2443,12 +2443,6 @@ void perform_cb_gstdemux(struct cb_data *cbdata) cbdata->u.activate_mode_data.ret = activate_mode(data->pad, data->parent, data->mode, data->activate); break; } - case NO_MORE_PADS: - { - struct no_more_pads_data *data = &cbdata->u.no_more_pads_data; - no_more_pads(data->element, data->user); - break; - } case REQUEST_BUFFER_SRC: { struct getrange_data *data = &cbdata->u.getrange_data; @@ -2645,7 +2639,7 @@ static BOOL avi_splitter_init_gst(struct parser *filter)
g_signal_connect(element, "pad-added", G_CALLBACK(existing_new_pad_wrapper), filter); g_signal_connect(element, "pad-removed", G_CALLBACK(removed_decoded_pad_wrapper), filter); - g_signal_connect(element, "no-more-pads", G_CALLBACK(no_more_pads_wrapper), filter); + g_signal_connect(element, "no-more-pads", G_CALLBACK(no_more_pads), filter);
filter->their_sink = gst_element_get_static_pad(element, "sink");
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/winegstreamer/gstdemux.c | 73 +++++++++++++++++------------------ 1 file changed, 35 insertions(+), 38 deletions(-)
diff --git a/dlls/winegstreamer/gstdemux.c b/dlls/winegstreamer/gstdemux.c index 22df838e4df..d16a8d28dd4 100644 --- a/dlls/winegstreamer/gstdemux.c +++ b/dlls/winegstreamer/gstdemux.c @@ -60,8 +60,6 @@ struct parser
LONGLONG filesize;
- CRITICAL_SECTION cs; - /* FIXME: It would be nice to avoid duplicating these with strmbase. * However, synchronization is tricky; we need access to be protected by a * separate lock. */ @@ -117,7 +115,7 @@ struct parser_source SourceSeeking seek;
CRITICAL_SECTION flushing_cs; - CONDITION_VARIABLE event_cv, event_empty_cv; + pthread_cond_t event_cond, event_empty_cond; bool flushing, eos; struct parser_event event; HANDLE thread; @@ -686,18 +684,18 @@ static GstFlowReturn queue_stream_event(struct parser_source *pin, const struct { struct parser *filter = impl_from_strmbase_filter(pin->pin.pin.filter);
- EnterCriticalSection(&filter->cs); + pthread_mutex_lock(&filter->mutex); while (!pin->flushing && pin->event.type != PARSER_EVENT_NONE) - SleepConditionVariableCS(&pin->event_empty_cv, &filter->cs, INFINITE); + pthread_cond_wait(&pin->event_empty_cond, &filter->mutex); if (pin->flushing) { - LeaveCriticalSection(&filter->cs); + pthread_mutex_unlock(&filter->mutex); TRACE("Filter is flushing; discarding event.\n"); return GST_FLOW_FLUSHING; } pin->event = *event; - LeaveCriticalSection(&filter->cs); - WakeConditionVariable(&pin->event_cv); + pthread_mutex_unlock(&filter->mutex); + pthread_cond_signal(&pin->event_cond); TRACE("Event queued.\n"); return GST_FLOW_OK; } @@ -755,10 +753,10 @@ static gboolean event_sink(GstPad *pad, GstObject *parent, GstEvent *event) case GST_EVENT_FLUSH_START: if (pin->pin.pin.peer) { - EnterCriticalSection(&filter->cs); + pthread_mutex_lock(&filter->mutex);
pin->flushing = true; - WakeConditionVariable(&pin->event_empty_cv); + pthread_cond_signal(&pin->event_empty_cond);
switch (pin->event.type) { @@ -773,7 +771,7 @@ static gboolean event_sink(GstPad *pad, GstObject *parent, GstEvent *event) } pin->event.type = PARSER_EVENT_NONE;
- LeaveCriticalSection(&filter->cs); + pthread_mutex_unlock(&filter->mutex); } break;
@@ -781,9 +779,9 @@ static gboolean event_sink(GstPad *pad, GstObject *parent, GstEvent *event) gst_segment_init(pin->segment, GST_FORMAT_TIME); if (pin->pin.pin.peer) { - EnterCriticalSection(&filter->cs); + pthread_mutex_lock(&filter->mutex); pin->flushing = false; - LeaveCriticalSection(&filter->cs); + pthread_mutex_unlock(&filter->mutex); } break;
@@ -1037,14 +1035,14 @@ static DWORD CALLBACK stream_thread(void *arg) struct parser_event event;
EnterCriticalSection(&pin->flushing_cs); - EnterCriticalSection(&filter->cs); + pthread_mutex_lock(&filter->mutex);
while (!filter->flushing && pin->event.type == PARSER_EVENT_NONE) - SleepConditionVariableCS(&pin->event_cv, &filter->cs, INFINITE); + pthread_cond_wait(&pin->event_cond, &filter->mutex);
if (filter->flushing) { - LeaveCriticalSection(&filter->cs); + pthread_mutex_unlock(&filter->mutex); LeaveCriticalSection(&pin->flushing_cs); TRACE("Filter is flushing.\n"); continue; @@ -1052,16 +1050,16 @@ static DWORD CALLBACK stream_thread(void *arg)
if (!pin->event.type) { - LeaveCriticalSection(&filter->cs); + pthread_mutex_unlock(&filter->mutex); LeaveCriticalSection(&pin->flushing_cs); continue; }
event = pin->event; pin->event.type = PARSER_EVENT_NONE; - WakeConditionVariable(&pin->event_empty_cv); + pthread_cond_signal(&pin->event_empty_cond);
- LeaveCriticalSection(&filter->cs); + pthread_mutex_unlock(&filter->mutex);
TRACE("Got event of type %#x.\n", event.type);
@@ -1598,8 +1596,6 @@ static void parser_destroy(struct strmbase_filter *iface) pthread_cond_destroy(&filter->init_cond); pthread_mutex_destroy(&filter->mutex);
- filter->cs.DebugInfo->Spare[0] = 0; - DeleteCriticalSection(&filter->cs); strmbase_sink_cleanup(&filter->sink); strmbase_filter_cleanup(&filter->filter); heap_free(filter); @@ -1616,9 +1612,9 @@ static HRESULT parser_init_stream(struct strmbase_filter *iface) return S_OK;
filter->streaming = true; - EnterCriticalSection(&filter->cs); + pthread_mutex_lock(&filter->mutex); filter->flushing = false; - LeaveCriticalSection(&filter->cs); + pthread_mutex_unlock(&filter->mutex);
/* DirectShow retains the old seek positions, but resets to them every time * it transitions from stopped -> paused. */ @@ -1656,9 +1652,9 @@ static HRESULT parser_cleanup_stream(struct strmbase_filter *iface) return S_OK;
filter->streaming = false; - EnterCriticalSection(&filter->cs); + pthread_mutex_lock(&filter->mutex); filter->flushing = true; - LeaveCriticalSection(&filter->cs); + pthread_mutex_unlock(&filter->mutex);
for (i = 0; i < filter->source_count; ++i) { @@ -1667,7 +1663,7 @@ static HRESULT parser_cleanup_stream(struct strmbase_filter *iface) if (!pin->pin.pin.peer) continue;
- WakeConditionVariable(&pin->event_cv); + pthread_cond_signal(&pin->event_cond); }
for (i = 0; i < filter->source_count; ++i) @@ -1893,8 +1889,6 @@ static void parser_init_common(struct parser *object) { pthread_mutex_init(&object->mutex, NULL); pthread_cond_init(&object->init_cond, NULL); - InitializeCriticalSection(&object->cs); - object->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": parser.cs"); object->flushing = true; }
@@ -2044,15 +2038,15 @@ static HRESULT WINAPI GST_Seeking_SetPositions(IMediaSeeking *iface,
if (!(current_flags & AM_SEEKING_NoFlush)) { - EnterCriticalSection(&filter->cs); + pthread_mutex_lock(&filter->mutex); filter->flushing = true; - LeaveCriticalSection(&filter->cs); + pthread_mutex_unlock(&filter->mutex);
for (i = 0; i < filter->source_count; ++i) { if (filter->sources[i]->pin.pin.peer) { - WakeConditionVariable(&pin->event_cv); + pthread_cond_signal(&pin->event_cond); IPin_BeginFlush(filter->sources[i]->pin.pin.peer); } } @@ -2093,9 +2087,9 @@ static HRESULT WINAPI GST_Seeking_SetPositions(IMediaSeeking *iface,
if (!(current_flags & AM_SEEKING_NoFlush)) { - EnterCriticalSection(&filter->cs); + pthread_mutex_lock(&filter->mutex); filter->flushing = false; - LeaveCriticalSection(&filter->cs); + pthread_mutex_unlock(&filter->mutex);
for (i = 0; i < filter->source_count; ++i) { @@ -2329,6 +2323,9 @@ static void free_source_pin(struct parser_source *pin) gst_object_unref(pin->my_sink); gst_segment_free(pin->segment);
+ pthread_cond_destroy(&pin->event_cond); + pthread_cond_destroy(&pin->event_empty_cond); + pin->flushing_cs.DebugInfo->Spare[0] = 0; DeleteCriticalSection(&pin->flushing_cs);
@@ -2365,8 +2362,8 @@ static struct parser_source *create_pin(struct parser *filter, const WCHAR *name pin->IQualityControl_iface.lpVtbl = &GSTOutPin_QualityControl_Vtbl; strmbase_seeking_init(&pin->seek, &GST_Seeking_Vtbl, GST_ChangeStop, GST_ChangeCurrent, GST_ChangeRate); - InitializeConditionVariable(&pin->event_cv); - InitializeConditionVariable(&pin->event_empty_cv); + pthread_cond_init(&pin->event_cond, NULL); + pthread_cond_init(&pin->event_empty_cond, NULL); BaseFilterImpl_IncrementPinVersion(&filter->filter);
InitializeCriticalSection(&pin->flushing_cs); @@ -2394,13 +2391,13 @@ static HRESULT GST_RemoveOutputPins(struct parser *This) return S_OK;
/* Unblock all of our streams. */ - EnterCriticalSection(&This->cs); + pthread_mutex_lock(&This->mutex); for (i = 0; i < This->source_count; ++i) { This->sources[i]->flushing = true; - WakeConditionVariable(&This->sources[i]->event_empty_cv); + pthread_cond_signal(&This->sources[i]->event_empty_cond); } - LeaveCriticalSection(&This->cs); + pthread_mutex_unlock(&This->mutex);
gst_element_set_state(This->container, GST_STATE_NULL); gst_pad_unlink(This->my_src, This->their_sink);
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/winegstreamer/gstdemux.c | 46 ++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 20 deletions(-)
diff --git a/dlls/winegstreamer/gstdemux.c b/dlls/winegstreamer/gstdemux.c index d16a8d28dd4..ea1268ef0dd 100644 --- a/dlls/winegstreamer/gstdemux.c +++ b/dlls/winegstreamer/gstdemux.c @@ -1023,6 +1023,31 @@ static void send_buffer(struct parser_source *pin, GstBuffer *buf) gst_buffer_unref(buf); }
+static bool get_stream_event(struct parser_source *pin, struct parser_event *event) +{ + struct parser *filter = impl_from_strmbase_filter(pin->pin.pin.filter); + + pthread_mutex_lock(&filter->mutex); + + while (!filter->flushing && pin->event.type == PARSER_EVENT_NONE) + pthread_cond_wait(&pin->event_cond, &filter->mutex); + + if (filter->flushing) + { + pthread_mutex_unlock(&filter->mutex); + TRACE("Filter is flushing.\n"); + return false; + } + + *event = pin->event; + pin->event.type = PARSER_EVENT_NONE; + + pthread_mutex_unlock(&filter->mutex); + pthread_cond_signal(&pin->event_empty_cond); + + return true; +} + static DWORD CALLBACK stream_thread(void *arg) { struct parser_source *pin = arg; @@ -1035,32 +1060,13 @@ static DWORD CALLBACK stream_thread(void *arg) struct parser_event event;
EnterCriticalSection(&pin->flushing_cs); - pthread_mutex_lock(&filter->mutex);
- while (!filter->flushing && pin->event.type == PARSER_EVENT_NONE) - pthread_cond_wait(&pin->event_cond, &filter->mutex); - - if (filter->flushing) + if (!get_stream_event(pin, &event)) { - pthread_mutex_unlock(&filter->mutex); LeaveCriticalSection(&pin->flushing_cs); - TRACE("Filter is flushing.\n"); continue; }
- if (!pin->event.type) - { - pthread_mutex_unlock(&filter->mutex); - LeaveCriticalSection(&pin->flushing_cs); - continue; - } - - event = pin->event; - pin->event.type = PARSER_EVENT_NONE; - pthread_cond_signal(&pin->event_empty_cond); - - pthread_mutex_unlock(&filter->mutex); - TRACE("Got event of type %#x.\n", event.type);
switch (event.type)
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/winegstreamer/gstdemux.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/dlls/winegstreamer/gstdemux.c b/dlls/winegstreamer/gstdemux.c index ea1268ef0dd..f51137344f9 100644 --- a/dlls/winegstreamer/gstdemux.c +++ b/dlls/winegstreamer/gstdemux.c @@ -690,13 +690,13 @@ static GstFlowReturn queue_stream_event(struct parser_source *pin, const struct if (pin->flushing) { pthread_mutex_unlock(&filter->mutex); - TRACE("Filter is flushing; discarding event.\n"); + GST_DEBUG("Filter is flushing; discarding event."); return GST_FLOW_FLUSHING; } pin->event = *event; pthread_mutex_unlock(&filter->mutex); pthread_cond_signal(&pin->event_cond); - TRACE("Event queued.\n"); + GST_LOG("Event queued."); return GST_FLOW_OK; }
@@ -880,7 +880,7 @@ static GstFlowReturn got_data_sink(GstPad *pad, GstObject *parent, GstBuffer *bu struct parser_event stream_event; GstFlowReturn ret;
- TRACE("pad %p, pin %p, buffer %p.\n", pad, pin, buffer); + GST_LOG("pin %p, buffer %p.", pin, buffer);
if (!pin->pin.pin.peer) {
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/winegstreamer/gst_cbs.c | 13 ------------- dlls/winegstreamer/gst_cbs.h | 8 -------- dlls/winegstreamer/gstdemux.c | 8 +------- 3 files changed, 1 insertion(+), 28 deletions(-)
diff --git a/dlls/winegstreamer/gst_cbs.c b/dlls/winegstreamer/gst_cbs.c index ebef533779d..5b163e40201 100644 --- a/dlls/winegstreamer/gst_cbs.c +++ b/dlls/winegstreamer/gst_cbs.c @@ -216,19 +216,6 @@ gboolean event_sink_wrapper(GstPad *pad, GstObject *parent, GstEvent *event) return cbdata.u.event_sink_data.ret; }
-GstFlowReturn got_data_sink_wrapper(GstPad *pad, GstObject *parent, GstBuffer *buf) -{ - struct cb_data cbdata = { GOT_DATA_SINK }; - - cbdata.u.got_data_sink_data.pad = pad; - cbdata.u.got_data_sink_data.parent = parent; - cbdata.u.got_data_sink_data.buf = buf; - - call_cb(&cbdata); - - return cbdata.u.got_data_sink_data.ret; -} - void removed_decoded_pad_wrapper(GstElement *bin, GstPad *pad, gpointer user) { struct cb_data cbdata = { REMOVED_DECODED_PAD }; diff --git a/dlls/winegstreamer/gst_cbs.h b/dlls/winegstreamer/gst_cbs.h index ce74e76edae..2de829f72e3 100644 --- a/dlls/winegstreamer/gst_cbs.h +++ b/dlls/winegstreamer/gst_cbs.h @@ -36,7 +36,6 @@ enum CB_TYPE { REQUEST_BUFFER_SRC, EVENT_SRC, EVENT_SINK, - GOT_DATA_SINK, REMOVED_DECODED_PAD, QUERY_SINK, GSTDEMUX_MAX, @@ -102,12 +101,6 @@ struct cb_data { GstEvent *event; gboolean ret; } event_sink_data; - struct got_data_sink_data { - GstPad *pad; - GstObject *parent; - GstBuffer *buf; - GstFlowReturn ret; - } got_data_sink_data; struct pad_removed_data { GstElement *element; GstPad *pad; @@ -137,7 +130,6 @@ gboolean activate_mode_wrapper(GstPad *pad, GstObject *parent, GstPadMode mode, GstFlowReturn request_buffer_src_wrapper(GstPad *pad, GstObject *parent, guint64 ofs, guint len, GstBuffer **buf) DECLSPEC_HIDDEN; gboolean event_src_wrapper(GstPad *pad, GstObject *parent, GstEvent *event) DECLSPEC_HIDDEN; gboolean event_sink_wrapper(GstPad *pad, GstObject *parent, GstEvent *event) DECLSPEC_HIDDEN; -GstFlowReturn got_data_sink_wrapper(GstPad *pad, GstObject *parent, GstBuffer *buf) DECLSPEC_HIDDEN; GstFlowReturn got_data_wrapper(GstPad *pad, GstObject *parent, GstBuffer *buf) DECLSPEC_HIDDEN; void removed_decoded_pad_wrapper(GstElement *bin, GstPad *pad, gpointer user) DECLSPEC_HIDDEN; void Gstreamer_transform_pad_added_wrapper(GstElement *filter, GstPad *pad, gpointer user) DECLSPEC_HIDDEN; diff --git a/dlls/winegstreamer/gstdemux.c b/dlls/winegstreamer/gstdemux.c index f51137344f9..5401d942a41 100644 --- a/dlls/winegstreamer/gstdemux.c +++ b/dlls/winegstreamer/gstdemux.c @@ -2378,7 +2378,7 @@ static struct parser_source *create_pin(struct parser *filter, const WCHAR *name sprintf(pad_name, "qz_sink_%u", filter->source_count); pin->my_sink = gst_pad_new(pad_name, GST_PAD_SINK); gst_pad_set_element_private(pin->my_sink, pin); - gst_pad_set_chain_function(pin->my_sink, got_data_sink_wrapper); + gst_pad_set_chain_function(pin->my_sink, got_data_sink); gst_pad_set_event_function(pin->my_sink, event_sink_wrapper); gst_pad_set_query_function(pin->my_sink, query_sink_wrapper);
@@ -2465,12 +2465,6 @@ void perform_cb_gstdemux(struct cb_data *cbdata) cbdata->u.event_sink_data.ret = event_sink(data->pad, data->parent, data->event); break; } - case GOT_DATA_SINK: - { - struct got_data_sink_data *data = &cbdata->u.got_data_sink_data; - cbdata->u.got_data_sink_data.ret = got_data_sink(data->pad, data->parent, data->buf); - break; - } case REMOVED_DECODED_PAD: { struct pad_removed_data *data = &cbdata->u.pad_removed_data;