[gst-devel] Possible race-condition when using g_enum_register_static

Sebastian Dröge slomo at uni-paderborn.de
Thu Oct 18 12:56:52 CEST 2007


Am Donnerstag, den 18.10.2007, 12:46 +0200 schrieb Michal Benes:
> Still a similar problem might be in other plugins and it would be very
> painful to check all GType initializations. It also seems to be
> maintenance nightmare. I will also look at the GOnce construct and how
> it could be used to solve this.

You could do:

> gst_mad_emphasis_get_type (void)
> {
>   static GType mad_emphasis_type = 0;
>   static GEnumValue mad_emphasis[] = <value omitted>;
> 
>   if (g_once_init_enter ((gsize *) &mad_emphasis_type))
>     g_once_init_leave ((gsize *) &mad_emphasis_type,
>         (gsize) g_enum_register_static ("GstMadEmphasis",
>             mad_emphasis));
> 
>   return mad_emphasis_type;
> }

Problem is, that the GOnce stuff wants values of type gsize... good news
is that GType actually is a gsize :)

Another problem is, that GOnce is GLib 2.14 stuff and thus can't be used
unless we update the requirements to that version which wasn't done in
the past already because of backward compatibility reasons.

Also GST_BOILERPLATE should probably be changed too then, no idea...





More information about the gstreamer-devel mailing list