Critical from GstElement missing pad template, but pad template exists in Factory?
When running under gdb with G_DEBUG="fatal-criticals", I got a breakpoint on the following message:
(buzztrax-edit:48707): GStreamer-CRITICAL **: 12:19:28.674: Element type GstTee does not have a pad template src_%u (0x555556b6a1c0)
The repro is simple:
- Add a machine.
- Connect the machine to the master sink.
The breakpoint was in bt_wire_make_internal_element:253, and it was while a wire was trying to make a "src_%u" pad for the GstTee element. This is weird because GstTee definitely has that pad template.
After iterating over the pad templates on the GstElement itself, I found that the GstPadTemplate returned from bt_gst_element_factory_get_pad_template had a different memory address to the one returned from get_element_get_pad_template_list. When I used the pad template from the GstElement rather than the GstElementFactory, then this error went away.
Also, just using gst_element_request_pad_simple also worked, although I guess you used the Factory method for speed.
Before I dig further, do you know what's going on here? Would you expect that pad templates returned from factories don't work when used to request pads on elements?
I also confirmed that the Factory used to create the GstElement and the one being used to retrieve the Template were the same, in both cases the Factory had the same memory address.
11 years ago - https://github.com/Buzztrax/buzztrax/commit/edeedf47556331f56c03aa801ea3a81077ccf06a Maybe i did something wrong or there was a subtle API change. The PadTemplate from the factory should work to get the actual Pad ...
Thank you, I'll do some more digging...
Here's a little program that reproduces the issue:
#include <stdio.h>
#include <gst/gst.h>
GstPadTemplate *
bt_gst_element_factory_get_pad_template (GstElementFactory * factory,
const gchar * name)
{
/* get pad templates */
const GList *list = gst_element_factory_get_static_pad_templates (factory);
for (; list; list = g_list_next (list)) {
GstStaticPadTemplate *t = (GstStaticPadTemplate *) list->data;
GST_INFO_OBJECT (factory, "Checking pad-template '%s'", t->name_template);
if (g_strcmp0 (t->name_template, name) == 0) {
return gst_static_pad_template_get (t);
}
}
GST_WARNING_OBJECT (factory, "No pad-template '%s'", name);
return NULL;
}
int main(int argc, char** argv) {
gst_init (&argc, &argv);
GstElementFactory* fact_tee = gst_element_factory_find("tee");
GstPadTemplate* template = bt_gst_element_factory_get_pad_template(fact_tee, "src_%u");
g_assert(template);
GstElement* tee = gst_element_factory_make("tee", NULL);
GstPad* pad = gst_element_request_pad(tee, template, NULL, NULL);
g_assert(pad);
printf("%s\n", gst_object_get_name(GST_OBJECT(pad)));
GstPad* pad2 = gst_element_request_pad(tee, template, NULL, NULL);
g_assert(pad2);
printf("%s\n", gst_object_get_name(GST_OBJECT(pad2)));
return 0;
}
Output will be:
(main:53558): GStreamer-CRITICAL **: 22:54:00.772: Element type GstTee does not have a pad template src_%u (0x55da2fceed10)
src_0
(main:53558): GStreamer-CRITICAL **: 22:54:00.772: Element type GstTee does not have a pad template src_%u (0x55da2fceed10)
src_1
Note that the pad seems to be created fine, and it even has a name as expected.
No idea what the deal is. Anyone else seeing this? Take it to gstreamer or Ubuntu?
Makefile:
PKGS = gstreamer-base-1.0 gstreamer-audio-1.0 gstreamer-plugins-base-1.0 gstreamer-controller-1.0
CFLAGS != pkg-config --cflags $(PKGS)
CFLAGS += -Wall -Wno-unused-variable
LDLIBS != pkg-config --libs $(PKGS)
main: main.o
clean:
rm main *.o || true