GNOME Bugzilla – Bug 630440
ringbuffer: use g_once for type-init
Last modified: 2010-09-23 22:03:40 UTC
Created attachment 170938 [details] [review] patch ...
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.
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.
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.