After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 169405 - [API] GST_TYPE_EVENT and gst_event_get_type unusable before gst_init()
[API] GST_TYPE_EVENT and gst_event_get_type unusable before gst_init()
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
0.8.9
Other Linux
: Normal normal
: 0.8.10
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2005-03-06 17:00 UTC by Torsten Schoenfeld
Modified: 2005-03-12 22:38 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Moving type creation (1.38 KB, patch)
2005-03-10 18:23 UTC, Torsten Schoenfeld
none Details | Review

Description Torsten Schoenfeld 2005-03-06 17:00:35 UTC
Both, the type macro and the type accessor for GstEvent are not usable till you
call gst_init().  That's a problem for language bindings because it prevents you
from creating GstEvent objects before gst_init() has been called.  In general I
think that at least the type accessor should return a valid type at all times.
Comment 1 Ronald Bultje 2005-03-09 08:50:00 UTC
But that goes for any type, right? You need to call g_type_init() (or whatever
it's called) before doing anything anyway; gst_init() is just the same for us.
Comment 2 Torsten Schoenfeld 2005-03-09 17:03:17 UTC
Yes, you need to call g_type_init() before any of the type stuff works at all. 
Our glib bindings do this automatically, and there's no way around it.  But
other than that, for normal gobject-based libraries, nothing else needs to be
called before the type macros are usable (pango, gtk+, libgnome(ui), etc.). 
GStreamer already uses a hack to increase performance: some type macros point
directly to the global type variable, instead of to the _get_type() function --
which means the type macros are not usable till the _get_type() function has
been called at least once.  But that can be easily worked around.

Automatically calling gst_init() at startup is no real option, as it prevents
the user from deciding when to initialize GStreamer -- which may sometimes be
necessary.

Currently, I work around this issue by delaying the registration and the setup
of the GstEvent wrappers until after gst_init() has been called.  That doesn't
help other problems that mainly occur during installation, though: our
documentation generation system relies on the introspection capabilities of the
type system to create the hierarchy graphs, properties information, etc. for all
 the gobject-based libraries we wrap -- and it doesn't call any initialization
function at the moment.

Also, I don't see the reason for deviating from the usual behavior. 
Performance-wise it's just as fast as the hack used for other types.
Comment 3 Ronald Bultje 2005-03-10 15:34:21 UTC
I know it isn't faster, I'm trying to propose a practical solution.
Comment 4 Torsten Schoenfeld 2005-03-10 18:23:23 UTC
I think a pragmatic solution would be the attached patch.  It moves the type
creation into gst_event_get_type() and calls that in gst_init().  AFAICT, this
doesn't break neither API nor ABI nor the semantics of GstEvent.  `make check`
in testsuite/ passes as well (except for testsuite/threads/), and the regression
tests for the Perl bindings are happy too.
Comment 5 Torsten Schoenfeld 2005-03-10 18:23:52 UTC
Created attachment 38520 [details] [review]
Moving type creation
Comment 6 Ronald Bultje 2005-03-10 20:37:06 UTC
That looks good to me. Any heavy objections?
Comment 7 Ronald Bultje 2005-03-12 22:38:36 UTC
ok, applied that, slightly different. thanks.