[gstreamer-bugs] [Bug 491501] gst_element_class_set_details should be used in class_init instead of base_init
bugzilla-daemon at bugzilla.gnome.org
Wed Jan 2 11:24:04 PST 2008
If you have any questions why you received this email, please see the text at
the end of this email. Replies to this email are NOT read, please see the text
at the end of this email. You can add comments to this bug at:
GStreamer | gstreamer (core) | Ver: HEAD CVS
------- Comment #3 from Sebastian Dröge 2008-01-02 19:24 UTC -------
Ok, as far as I understand it the difference between class_init and base_init
is the following:
class_init is only called once, that is when creating the class struct for
exactly this class.
base_init is called once for the class itself and once for each subclass.
As the class struct of subclasses is created by memcpy this means that if the
details are set in class_init they will be exactly the same (same memory
region, etc) for every subclass too, if they're in base_init every subclass
will have a copy of them.
gst_element_class_set_details() calls __gst_element_details_set() which will
for every char * in GstElementDetails set a copy of the given element details.
gst_element_base_class_init() OTOH will be called for every subclass of
GstElement and will reset the element details of the parent class to zeroes. So
currently with GstBin and GstPipeline the following happens:
GstBin base_init() sets the element details in it's class struct. Then
GstPipeline's class struct is allocated, gets GstBin's memcpy'd in and all
base_init's are called on it. gst_element_base_class_init will then reset the
element details to zeroes, GstBin's base_init() will again set the GstBin
details (well, a copy of them) and GstPipeline's base_init() overwrites them
with it's own.
So the reason the details should be set in base_init() seems to be, that this
way every subclass has it's own copy of them and subclasses will get the ones
of their parent class if they don't set them on their own.
IMHO this behaviour should be changed so that it will be called only in
class_init() and every GstElement subclass _must_ set element details and won't
inherit them from their parent class if they don't set them. It makes no sense
to have the same details for the parent and the subclass anyway.
So I would propose to move all the details setting to class_init but this might
have to wait for 0.11 as today GstElement subclasses can expect to inherit the
details from their parent class (although this doesn't make sense at all).
On another topic, the situation is similar with the pad templates, not sure yet
if it makes sense to be called in base_init too (vs. copying the pad template
list only in gst_element_base_class_init), any thoughts on this?
See http://bugzilla.gnome.org/page.cgi?id=email.html for more info about why you received
this email, why you can't respond via email, how to stop receiving
emails (or reduce the number you receive), and how to contact someone
if you are having problems with the system.
You can add comments to this bug at http://bugzilla.gnome.org/show_bug.cgi?id=491501.
More information about the Gstreamer-bugs