Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/winegstreamer/wg_parser.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-)
diff --git a/dlls/winegstreamer/wg_parser.c b/dlls/winegstreamer/wg_parser.c index 94f677538c7..63ba95a78cb 100644 --- a/dlls/winegstreamer/wg_parser.c +++ b/dlls/winegstreamer/wg_parser.c @@ -699,7 +699,8 @@ static void CDECL wg_parser_stream_notify_qos(struct wg_parser_stream *stream, gst_pad_push_event(stream->my_sink, event); }
-static GstAutoplugSelectResult autoplug_blacklist(GstElement *bin, GstPad *pad, GstCaps *caps, GstElementFactory *fact, gpointer user) +static GstAutoplugSelectResult autoplug_select_cb(GstElement *bin, GstPad *pad, + GstCaps *caps, GstElementFactory *fact, gpointer user) { const char *name = gst_element_factory_get_longname(fact);
@@ -865,7 +866,7 @@ static gboolean event_sink(GstPad *pad, GstObject *parent, GstEvent *event) return TRUE; }
-static GstFlowReturn got_data_sink(GstPad *pad, GstObject *parent, GstBuffer *buffer) +static GstFlowReturn sink_chain_cb(GstPad *pad, GstObject *parent, GstBuffer *buffer) { struct wg_parser_stream *stream = gst_pad_get_element_private(pad); struct wg_parser_event stream_event; @@ -978,7 +979,7 @@ static struct wg_parser_stream *create_stream(struct wg_parser *parser) sprintf(pad_name, "qz_sink_%u", parser->stream_count); stream->my_sink = gst_pad_new(pad_name, GST_PAD_SINK); gst_pad_set_element_private(stream->my_sink, stream); - gst_pad_set_chain_function(stream->my_sink, got_data_sink); + gst_pad_set_chain_function(stream->my_sink, sink_chain_cb); gst_pad_set_event_function(stream->my_sink, event_sink); gst_pad_set_query_function(stream->my_sink, query_sink);
@@ -1114,7 +1115,7 @@ out: gst_caps_unref(caps); }
-static void existing_new_pad(GstElement *element, GstPad *pad, gpointer user) +static void pad_added_cb(GstElement *element, GstPad *pad, gpointer user) { struct wg_parser *parser = user;
@@ -1126,7 +1127,7 @@ static void existing_new_pad(GstElement *element, GstPad *pad, gpointer user) init_new_decoded_pad(element, pad, parser); }
-static void removed_decoded_pad(GstElement *element, GstPad *pad, gpointer user) +static void pad_removed_cb(GstElement *element, GstPad *pad, gpointer user) { struct wg_parser *parser = user; unsigned int i; @@ -1155,7 +1156,8 @@ static void removed_decoded_pad(GstElement *element, GstPad *pad, gpointer user) g_free(name); }
-static GstFlowReturn request_buffer_src(GstPad *pad, GstObject *parent, guint64 offset, guint size, GstBuffer **buffer) +static GstFlowReturn src_getrange_cb(GstPad *pad, GstObject *parent, + guint64 offset, guint size, GstBuffer **buffer) { struct wg_parser *parser = gst_pad_get_element_private(pad); GstBuffer *new_buffer = NULL; @@ -1277,7 +1279,7 @@ static void *push_data(void *arg) break; size = min(16384, max_size - parser->next_offset);
- if ((ret = request_buffer_src(parser->my_src, NULL, parser->next_offset, size, &buffer)) < 0) + if ((ret = src_getrange_cb(parser->my_src, NULL, parser->next_offset, size, &buffer)) < 0) { GST_ERROR("Failed to read data, ret %s.", gst_flow_get_name(ret)); break; @@ -1347,7 +1349,7 @@ static gboolean activate_mode(GstPad *pad, GstObject *parent, GstPadMode mode, g return FALSE; }
-static GstBusSyncReply watch_bus(GstBus *bus, GstMessage *msg, gpointer user) +static GstBusSyncReply bus_handler_cb(GstBus *bus, GstMessage *msg, gpointer user) { struct wg_parser *parser = user; gchar *dbg_info = NULL; @@ -1498,14 +1500,14 @@ static HRESULT CDECL wg_parser_connect(struct wg_parser *parser, uint64_t file_s if (!parser->bus) { parser->bus = gst_bus_new(); - gst_bus_set_sync_handler(parser->bus, watch_bus, parser, NULL); + gst_bus_set_sync_handler(parser->bus, bus_handler_cb, parser, NULL); }
parser->container = gst_bin_new(NULL); gst_element_set_bus(parser->container, parser->bus);
parser->my_src = gst_pad_new_from_static_template(&src_template, "quartz-src"); - gst_pad_set_getrange_function(parser->my_src, request_buffer_src); + gst_pad_set_getrange_function(parser->my_src, src_getrange_cb); 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); @@ -1614,9 +1616,9 @@ static BOOL decodebin_parser_init_gst(struct wg_parser *parser) gst_bin_add(GST_BIN(parser->container), element); parser->decodebin = element;
- g_signal_connect(element, "pad-added", G_CALLBACK(existing_new_pad), parser); - g_signal_connect(element, "pad-removed", G_CALLBACK(removed_decoded_pad), parser); - g_signal_connect(element, "autoplug-select", G_CALLBACK(autoplug_blacklist), parser); + g_signal_connect(element, "pad-added", G_CALLBACK(pad_added_cb), parser); + g_signal_connect(element, "pad-removed", G_CALLBACK(pad_removed_cb), parser); + g_signal_connect(element, "autoplug-select", G_CALLBACK(autoplug_select_cb), parser); g_signal_connect(element, "no-more-pads", G_CALLBACK(no_more_pads), parser);
parser->their_sink = gst_element_get_static_pad(element, "sink"); @@ -1666,8 +1668,8 @@ static BOOL avi_parser_init_gst(struct wg_parser *parser)
gst_bin_add(GST_BIN(parser->container), element);
- g_signal_connect(element, "pad-added", G_CALLBACK(existing_new_pad), parser); - g_signal_connect(element, "pad-removed", G_CALLBACK(removed_decoded_pad), parser); + g_signal_connect(element, "pad-added", G_CALLBACK(pad_added_cb), parser); + g_signal_connect(element, "pad-removed", G_CALLBACK(pad_removed_cb), parser); g_signal_connect(element, "no-more-pads", G_CALLBACK(no_more_pads), parser);
parser->their_sink = gst_element_get_static_pad(element, "sink");
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/winegstreamer/wg_parser.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/dlls/winegstreamer/wg_parser.c b/dlls/winegstreamer/wg_parser.c index 63ba95a78cb..95e8611fb57 100644 --- a/dlls/winegstreamer/wg_parser.c +++ b/dlls/winegstreamer/wg_parser.c @@ -719,7 +719,7 @@ static GstAutoplugSelectResult autoplug_select_cb(GstElement *bin, GstPad *pad, return GST_AUTOPLUG_SELECT_TRY; }
-static void no_more_pads(GstElement *element, gpointer user) +static void no_more_pads_cb(GstElement *element, gpointer user) { struct wg_parser *parser = user;
@@ -769,7 +769,7 @@ static GstFlowReturn queue_stream_event(struct wg_parser_stream *stream, return GST_FLOW_OK; }
-static gboolean event_sink(GstPad *pad, GstObject *parent, GstEvent *event) +static gboolean sink_event_cb(GstPad *pad, GstObject *parent, GstEvent *event) { struct wg_parser_stream *stream = gst_pad_get_element_private(pad); struct wg_parser *parser = stream->parser; @@ -897,7 +897,7 @@ static GstFlowReturn sink_chain_cb(GstPad *pad, GstObject *parent, GstBuffer *bu return ret; }
-static gboolean query_sink(GstPad *pad, GstObject *parent, GstQuery *query) +static gboolean sink_query_cb(GstPad *pad, GstObject *parent, GstQuery *query) { struct wg_parser_stream *stream = gst_pad_get_element_private(pad);
@@ -980,8 +980,8 @@ static struct wg_parser_stream *create_stream(struct wg_parser *parser) stream->my_sink = gst_pad_new(pad_name, GST_PAD_SINK); gst_pad_set_element_private(stream->my_sink, stream); gst_pad_set_chain_function(stream->my_sink, sink_chain_cb); - gst_pad_set_event_function(stream->my_sink, event_sink); - gst_pad_set_query_function(stream->my_sink, query_sink); + gst_pad_set_event_function(stream->my_sink, sink_event_cb); + gst_pad_set_query_function(stream->my_sink, sink_query_cb);
parser->streams[parser->stream_count++] = stream; return stream; @@ -1209,7 +1209,7 @@ static GstFlowReturn src_getrange_cb(GstPad *pad, GstObject *parent, return ret ? GST_FLOW_OK : GST_FLOW_ERROR; }
-static gboolean query_function(GstPad *pad, GstObject *parent, GstQuery *query) +static gboolean src_query_cb(GstPad *pad, GstObject *parent, GstQuery *query) { struct wg_parser *parser = gst_pad_get_element_private(pad); GstFormat format; @@ -1330,7 +1330,7 @@ static gboolean activate_push(GstPad *pad, gboolean activate) return TRUE; }
-static gboolean activate_mode(GstPad *pad, GstObject *parent, GstPadMode mode, gboolean activate) +static gboolean src_activate_mode_cb(GstPad *pad, GstObject *parent, GstPadMode mode, gboolean activate) { struct wg_parser *parser = gst_pad_get_element_private(pad);
@@ -1440,7 +1440,7 @@ static gboolean gst_base_src_perform_seek(struct wg_parser *parser, GstEvent *ev return TRUE; }
-static gboolean event_src(GstPad *pad, GstObject *parent, GstEvent *event) +static gboolean src_event_cb(GstPad *pad, GstObject *parent, GstEvent *event) { struct wg_parser *parser = gst_pad_get_element_private(pad); gboolean ret = TRUE; @@ -1508,9 +1508,9 @@ static HRESULT CDECL wg_parser_connect(struct wg_parser *parser, uint64_t file_s
parser->my_src = gst_pad_new_from_static_template(&src_template, "quartz-src"); gst_pad_set_getrange_function(parser->my_src, src_getrange_cb); - 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_query_function(parser->my_src, src_query_cb); + gst_pad_set_activatemode_function(parser->my_src, src_activate_mode_cb); + gst_pad_set_event_function(parser->my_src, src_event_cb); gst_pad_set_element_private(parser->my_src, parser);
parser->start_offset = parser->next_offset = parser->stop_offset = 0; @@ -1619,7 +1619,7 @@ static BOOL decodebin_parser_init_gst(struct wg_parser *parser) g_signal_connect(element, "pad-added", G_CALLBACK(pad_added_cb), parser); g_signal_connect(element, "pad-removed", G_CALLBACK(pad_removed_cb), parser); g_signal_connect(element, "autoplug-select", G_CALLBACK(autoplug_select_cb), parser); - g_signal_connect(element, "no-more-pads", G_CALLBACK(no_more_pads), parser); + g_signal_connect(element, "no-more-pads", G_CALLBACK(no_more_pads_cb), parser);
parser->their_sink = gst_element_get_static_pad(element, "sink");
@@ -1670,7 +1670,7 @@ static BOOL avi_parser_init_gst(struct wg_parser *parser)
g_signal_connect(element, "pad-added", G_CALLBACK(pad_added_cb), parser); g_signal_connect(element, "pad-removed", G_CALLBACK(pad_removed_cb), parser); - g_signal_connect(element, "no-more-pads", G_CALLBACK(no_more_pads), parser); + g_signal_connect(element, "no-more-pads", G_CALLBACK(no_more_pads_cb), parser);
parser->their_sink = gst_element_get_static_pad(element, "sink");
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/winegstreamer/wg_parser.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-)
diff --git a/dlls/winegstreamer/wg_parser.c b/dlls/winegstreamer/wg_parser.c index 95e8611fb57..341ca182749 100644 --- a/dlls/winegstreamer/wg_parser.c +++ b/dlls/winegstreamer/wg_parser.c @@ -987,13 +987,19 @@ static struct wg_parser_stream *create_stream(struct wg_parser *parser) return stream; }
-static void init_new_decoded_pad(GstElement *element, GstPad *pad, struct wg_parser *parser) +static void pad_added_cb(GstElement *element, GstPad *pad, gpointer user) { + struct wg_parser *parser = user; struct wg_parser_stream *stream; const char *name; GstCaps *caps; int ret;
+ GST_LOG("parser %p, element %p, pad %p.", parser, element, pad); + + if (gst_pad_is_linked(pad)) + return; + caps = gst_caps_make_writable(gst_pad_query_caps(pad, NULL)); name = gst_structure_get_name(gst_caps_get_structure(caps, 0));
@@ -1115,18 +1121,6 @@ out: gst_caps_unref(caps); }
-static void pad_added_cb(GstElement *element, GstPad *pad, gpointer user) -{ - struct wg_parser *parser = user; - - GST_LOG("parser %p, element %p, pad %p.", parser, element, pad); - - if (gst_pad_is_linked(pad)) - return; - - init_new_decoded_pad(element, pad, parser); -} - static void pad_removed_cb(GstElement *element, GstPad *pad, gpointer user) { struct wg_parser *parser = user;
There is no need.
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/winegstreamer/wg_parser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/winegstreamer/wg_parser.c b/dlls/winegstreamer/wg_parser.c index 341ca182749..a2eaf1958d6 100644 --- a/dlls/winegstreamer/wg_parser.c +++ b/dlls/winegstreamer/wg_parser.c @@ -1000,7 +1000,7 @@ static void pad_added_cb(GstElement *element, GstPad *pad, gpointer user) if (gst_pad_is_linked(pad)) return;
- caps = gst_caps_make_writable(gst_pad_query_caps(pad, NULL)); + caps = gst_pad_query_caps(pad, NULL); name = gst_structure_get_name(gst_caps_get_structure(caps, 0));
if (!(stream = create_stream(parser)))
Avoid polluting the GStreamer namespace.
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/winegstreamer/wg_parser.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/winegstreamer/wg_parser.c b/dlls/winegstreamer/wg_parser.c index a2eaf1958d6..f76ca903b80 100644 --- a/dlls/winegstreamer/wg_parser.c +++ b/dlls/winegstreamer/wg_parser.c @@ -1387,7 +1387,7 @@ static GstBusSyncReply bus_handler_cb(GstBus *bus, GstMessage *msg, gpointer use return GST_BUS_DROP; }
-static gboolean gst_base_src_perform_seek(struct wg_parser *parser, GstEvent *event) +static gboolean src_perform_seek(struct wg_parser *parser, GstEvent *event) { BOOL thread = !!parser->push_thread; GstSeekType cur_type, stop_type; @@ -1444,7 +1444,7 @@ static gboolean src_event_cb(GstPad *pad, GstObject *parent, GstEvent *event) switch (event->type) { case GST_EVENT_SEEK: - ret = gst_base_src_perform_seek(parser, event); + ret = src_perform_seek(parser, event); break;
case GST_EVENT_FLUSH_START:
It's not clear what atexit handlers glib installs or why they cause problems. In fact, current glib source, besides including some wrapper API, has only one call to atexit(), which simply dumps leaked objects. In any case, keeping this code around does not seem worthwhile when the problem is not fully understood and may not exist anymore at all.
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/winegstreamer/gst_private.h | 2 -- dlls/winegstreamer/main.c | 26 -------------------------- dlls/winegstreamer/quartz_parser.c | 19 ------------------- 3 files changed, 47 deletions(-)
diff --git a/dlls/winegstreamer/gst_private.h b/dlls/winegstreamer/gst_private.h index 55a62361966..49b14316ea8 100644 --- a/dlls/winegstreamer/gst_private.h +++ b/dlls/winegstreamer/gst_private.h @@ -205,8 +205,6 @@ HRESULT decodebin_parser_create(IUnknown *outer, IUnknown **out) DECLSPEC_HIDDEN HRESULT mpeg_splitter_create(IUnknown *outer, IUnknown **out) DECLSPEC_HIDDEN; HRESULT wave_parser_create(IUnknown *outer, IUnknown **out) DECLSPEC_HIDDEN;
-BOOL init_gstreamer(void) DECLSPEC_HIDDEN; - void start_dispatch_thread(void) DECLSPEC_HIDDEN;
extern HRESULT mfplat_get_class_object(REFCLSID rclsid, REFIID riid, void **obj) DECLSPEC_HIDDEN; diff --git a/dlls/winegstreamer/main.c b/dlls/winegstreamer/main.c index d5c06bf3279..8e36b71ab12 100644 --- a/dlls/winegstreamer/main.c +++ b/dlls/winegstreamer/main.c @@ -139,9 +139,6 @@ HRESULT WINAPI DllGetClassObject(REFCLSID clsid, REFIID iid, void **out)
TRACE("clsid %s, iid %s, out %p.\n", debugstr_guid(clsid), debugstr_guid(iid), out);
- if (!init_gstreamer()) - return CLASS_E_CLASSNOTAVAILABLE; - if (SUCCEEDED(hr = mfplat_get_class_object(clsid, iid, out))) return hr;
@@ -162,29 +159,6 @@ HRESULT WINAPI DllGetClassObject(REFCLSID clsid, REFIID iid, void **out) return IClassFactory_QueryInterface(&factory->IClassFactory_iface, iid, out); }
-static BOOL CALLBACK init_gstreamer_proc(INIT_ONCE *once, void *param, void **ctx) -{ - HINSTANCE handle; - - /* Unloading glib is a bad idea.. it installs atexit handlers, - * so never unload the dll after loading */ - GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_PIN, - (LPCWSTR)winegstreamer_instance, &handle); - if (!handle) - ERR("Failed to pin module %p.\n", winegstreamer_instance); - - return TRUE; -} - -BOOL init_gstreamer(void) -{ - static INIT_ONCE once = INIT_ONCE_STATIC_INIT; - - InitOnceExecuteOnce(&once, init_gstreamer_proc, NULL, NULL); - - return TRUE; -} - static const REGPINTYPES reg_audio_mt = {&MEDIATYPE_Audio, &GUID_NULL}; static const REGPINTYPES reg_stream_mt = {&MEDIATYPE_Stream, &GUID_NULL}; static const REGPINTYPES reg_video_mt = {&MEDIATYPE_Video, &GUID_NULL}; diff --git a/dlls/winegstreamer/quartz_parser.c b/dlls/winegstreamer/quartz_parser.c index e9e7c3a0f9f..fd1a1e82481 100644 --- a/dlls/winegstreamer/quartz_parser.c +++ b/dlls/winegstreamer/quartz_parser.c @@ -1077,20 +1077,10 @@ static HRESULT decodebin_parser_source_get_media_type(struct parser_source *pin, return VFW_S_NO_MORE_ITEMS; }
-static BOOL parser_init_gstreamer(void) -{ - if (!init_gstreamer()) - return FALSE; - return TRUE; -} - HRESULT decodebin_parser_create(IUnknown *outer, IUnknown **out) { struct parser *object;
- if (!parser_init_gstreamer()) - return E_FAIL; - if (!(object = calloc(1, sizeof(*object)))) return E_OUTOFMEMORY;
@@ -1619,9 +1609,6 @@ HRESULT wave_parser_create(IUnknown *outer, IUnknown **out) { struct parser *object;
- if (!parser_init_gstreamer()) - return E_FAIL; - if (!(object = calloc(1, sizeof(*object)))) return E_OUTOFMEMORY;
@@ -1705,9 +1692,6 @@ HRESULT avi_splitter_create(IUnknown *outer, IUnknown **out) { struct parser *object;
- if (!parser_init_gstreamer()) - return E_FAIL; - if (!(object = calloc(1, sizeof(*object)))) return E_OUTOFMEMORY;
@@ -1812,9 +1796,6 @@ HRESULT mpeg_splitter_create(IUnknown *outer, IUnknown **out) { struct parser *object;
- if (!parser_init_gstreamer()) - return E_FAIL; - if (!(object = calloc(1, sizeof(*object)))) return E_OUTOFMEMORY;
Zebediah Figura z.figura12@gmail.com writes:
It's not clear what atexit handlers glib installs or why they cause problems. In fact, current glib source, besides including some wrapper API, has only one call to atexit(), which simply dumps leaked objects. In any case, keeping this code around does not seem worthwhile when the problem is not fully understood and may not exist anymore at all.
Famous last words ;-)
$ tools/runtest -q -P wine -T . -M mf.dll -p dlls/mf/tests/mf_test.exe mf && touch dlls/mf/tests/mf.ok (wine:1642464): GLib-GObject-WARNING **: 22:05:46.455: cannot register existing type 'GstElement'
(wine:1642464): GLib-CRITICAL **: 22:05:46.455: g_once_init_leave: assertion 'result != 0' failed
(wine:1642464): GLib-GObject-WARNING **: 22:05:46.455: cannot retrieve class for invalid (unclassed) type '<invalid>' 0108:err:ntdll:RtlpWaitForCriticalSection section 7BC63360 "dlls/ntdll/loader.c: loader_section" wait timed out in thread 0108, blocked by 0024, retrying (60 sec)
On 2/24/21 3:06 PM, Alexandre Julliard wrote:
Zebediah Figura z.figura12@gmail.com writes:
It's not clear what atexit handlers glib installs or why they cause problems. In fact, current glib source, besides including some wrapper API, has only one call to atexit(), which simply dumps leaked objects. In any case, keeping this code around does not seem worthwhile when the problem is not fully understood and may not exist anymore at all.
Famous last words ;-)
$ tools/runtest -q -P wine -T . -M mf.dll -p dlls/mf/tests/mf_test.exe mf && touch dlls/mf/tests/mf.ok (wine:1642464): GLib-GObject-WARNING **: 22:05:46.455: cannot register existing type 'GstElement'
(wine:1642464): GLib-CRITICAL **: 22:05:46.455: g_once_init_leave: assertion 'result != 0' failed
(wine:1642464): GLib-GObject-WARNING **: 22:05:46.455: cannot retrieve class for invalid (unclassed) type '<invalid>' 0108:err:ntdll:RtlpWaitForCriticalSection section 7BC63360 "dlls/ntdll/loader.c: loader_section" wait timed out in thread 0108, blocked by 0024, retrying (60 sec)
Excellent, my plan to unearth the actual problem succeeded!
I can reproduce this too, so I'll look into it. (I could have sworn I ran the mfplat tests too, but evidently not, or perhaps they were expanded since I did...)