Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Critical from GstElement missing pad template, but pad template exists in Factory? #116

Open
dlbeswick opened this issue Sep 19, 2023 · 4 comments

Comments

@dlbeswick
Copy link
Contributor

dlbeswick commented Sep 19, 2023

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:

  1. Add a machine.
  2. 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.

@ensonic
Copy link
Member

ensonic commented Sep 19, 2023

11 years ago - edeedf4
Maybe i did something wrong or there was a subtle API change. The PadTemplate from the factory should work to get the actual Pad ...

dlbeswick added a commit to dlbeswick/buzztrax that referenced this issue Sep 20, 2023
@dlbeswick
Copy link
Contributor Author

Thank you, I'll do some more digging...

@dlbeswick
Copy link
Contributor Author

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?

@dlbeswick
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants