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 630440 - ringbuffer: use g_once for type-init
ringbuffer: use g_once for type-init
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
unspecified
Other All
: Normal normal
: 0.10.31
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2010-09-23 17:29 UTC by Håvard Graff (hgr)
Modified: 2010-09-23 22:03 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch (1.50 KB, patch)
2010-09-23 17:29 UTC, Håvard Graff (hgr)
needs-work Details | Review

Description Håvard Graff (hgr) 2010-09-23 17:29:35 UTC
Created attachment 170938 [details] [review]
patch

...
Comment 1 Sebastian Dröge (slomo) 2010-09-23 19:22:18 UTC
Instead of calling g_once_init_{enter,leave} by hand could you use G_DEFINE_ABSTRACT_TYPE for defining the get_type() function and everything else.

The debug category initialization can be moved to class_init or you could use G_DEFINE_ABSTRACT_TYPE_WITH_CODE.
Comment 2 Håvard Graff (hgr) 2010-09-23 21:47:55 UTC
Feel free to change it, but the patch fixes a serious problem, where a src and a sink might be created at the same time, and you get a crash, something we have observed with several customers. (callstacks coming back from the field)

I simply copied the g_once code from a different element.
Comment 3 Sebastian Dröge (slomo) 2010-09-23 22:00:17 UTC
Yes, using g_once_init_{enter,leave} is definitely important in the _get_type() functions. If you see more GStreamer code that doesn't use it please file more bugs :)

The advantage of using the G_DEFINE_TYPE macros is, that it saves quite some code that you otherwise copy from one source file to another.

commit 550d59354f149a4c3bcaf4ffa567609a6ba1c909
Author: Sebastian Dröge <sebastian.droege@collabora.co.uk>
Date:   Thu Sep 23 23:57:50 2010 +0200

    ringbuffer: Use G_DEFINE_ABSTRACT_TYPE instead of manual GObject boilerplate
    
    This also makes the _get_type() function threadsafe.
    
    Fixes bug #630440.