[farsight2/master] Move initializing the sources into the first call for them, using GOnce

Olivier Crête olivier.crete at collabora.co.uk
Tue Dec 23 15:21:37 PST 2008


---
 gst/fsrtpconference/fs-rtp-discover-codecs.c |    1 -
 gst/fsrtpconference/fs-rtp-special-source.c  |   41 +++++++++++++++-----------
 gst/fsrtpconference/fs-rtp-special-source.h  |    3 --
 3 files changed, 24 insertions(+), 21 deletions(-)

diff --git a/gst/fsrtpconference/fs-rtp-discover-codecs.c b/gst/fsrtpconference/fs-rtp-discover-codecs.c
index b106699..c342940 100644
--- a/gst/fsrtpconference/fs-rtp-discover-codecs.c
+++ b/gst/fsrtpconference/fs-rtp-discover-codecs.c
@@ -312,7 +312,6 @@ create_codec_lists (FsMediaType media_type,
 
   codec_cap_list_free (duplex_list);
 
-  fs_rtp_special_sources_init ();
   list_codec_blueprints[media_type] =
     fs_rtp_special_sources_add_blueprints (list_codec_blueprints[media_type]);
 
diff --git a/gst/fsrtpconference/fs-rtp-special-source.c b/gst/fsrtpconference/fs-rtp-special-source.c
index 33eb2bc..9968334 100644
--- a/gst/fsrtpconference/fs-rtp-special-source.c
+++ b/gst/fsrtpconference/fs-rtp-special-source.c
@@ -75,31 +75,34 @@ fs_rtp_special_source_update (FsRtpSpecialSource *source,
     GList *negotiated_codecs,
     FsCodec *selected_codec);
 
-static void
-fs_rtp_special_source_class_init (FsRtpSpecialSourceClass *klass)
+static gpointer
+register_classes (gpointer data)
 {
-  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+  GList *my_classes = NULL;
 
-  parent_class = fs_rtp_special_source_parent_class;
+  my_classes = g_list_prepend (my_classes,
+      g_type_class_ref (FS_TYPE_RTP_DTMF_EVENT_SOURCE));
 
-  gobject_class->dispose = fs_rtp_special_source_dispose;
+  return classes;
 }
 
-void
+static void
 fs_rtp_special_sources_init (void)
 {
-  static gsize initialization_value = 0;
-  if (g_once_init_enter (&initialization_value))
-  {
-    gsize setup_value = 42;
-
-    classes = g_list_prepend (classes,
-        g_type_class_ref (FS_TYPE_RTP_DTMF_EVENT_SOURCE));
+  static GOnce my_once = G_ONCE_INIT;
 
-    g_once_init_leave (&initialization_value, setup_value);
-  }
+  classes = g_once (&my_once, register_classes, NULL);
 }
 
+static void
+fs_rtp_special_source_class_init (FsRtpSpecialSourceClass *klass)
+{
+  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+  parent_class = fs_rtp_special_source_parent_class;
+
+  gobject_class->dispose = fs_rtp_special_source_dispose;
+}
 
 static void
 fs_rtp_special_source_init (FsRtpSpecialSource *self)
@@ -150,6 +153,8 @@ fs_rtp_special_sources_add_blueprints (GList *blueprints)
 {
   GList *item = NULL;
 
+  fs_rtp_special_sources_init ();
+
   for (item = g_list_first (classes);
        item;
        item = g_list_next (item))
@@ -185,6 +190,8 @@ fs_rtp_special_sources_update (
 {
   GList *klass_item = NULL;
 
+  fs_rtp_special_sources_init ();
+
   for (klass_item = g_list_first (classes);
        klass_item;
        klass_item = g_list_next (klass_item))
@@ -258,7 +265,7 @@ fs_rtp_special_sources_update (
 
 static FsRtpSpecialSource *
 fs_rtp_special_source_new (FsRtpSpecialSourceClass *klass,
-    GList *negotiated_sources,
+    GList *negotiated_codecs,
     FsCodec *selected_codec,
     GstElement *bin,
     GstElement *rtpmuxer,
@@ -266,7 +273,7 @@ fs_rtp_special_source_new (FsRtpSpecialSourceClass *klass,
     GError **error)
 {
   if (klass->new)
-    return klass->new (klass, negotiated_sources, selected_codec, bin, rtpmuxer,
+    return klass->new (klass, negotiated_codecs, selected_codec, bin, rtpmuxer,
         last, error);
 
   g_set_error (error, FS_ERROR, FS_ERROR_NOT_IMPLEMENTED,
diff --git a/gst/fsrtpconference/fs-rtp-special-source.h b/gst/fsrtpconference/fs-rtp-special-source.h
index 7558176..df3a373 100644
--- a/gst/fsrtpconference/fs-rtp-special-source.h
+++ b/gst/fsrtpconference/fs-rtp-special-source.h
@@ -102,9 +102,6 @@ struct _FsRtpSpecialSource
 
 GType fs_rtp_special_source_get_type (void);
 
-void
-fs_rtp_special_sources_init (void);
-
 GList *
 fs_rtp_special_sources_update (
     GList *current_extra_sources,
-- 
1.5.6.5




More information about the farsight-commits mailing list