Sophie

Sophie

distrib > Mandriva > 2010.1 > i586 > media > main-testing-src > by-pkgid > 863d6bb7085bef9decfd3ec6b01c8cbe > files > 5

gstreamer0.10-plugins-good-0.10.22-1.1.4mdv2010.1.src.rpm

From 864a52d8aa938fbc308a5bf027cbc4bd8a23d45e Mon Sep 17 00:00:00 2001
From: Philippe Normand <pnormand@igalia.com>
Date: Thu, 15 Jul 2010 10:10:31 +0200
Subject: [PATCH] pulsesink: use G_TYPE_DEFINE to define ring buffer type

The existing get_type() implementation is racy, and the
g_type_class_ref() workaround didn't actually work because
it was in the wrong function. Since class creation in GObject
is thread-safe these days (since 2.16), the class_ref workaround
is no longer needed and it is sufficient to ensure the _get_type()
function is thread-safe, which G_TYPE_DEFINE does.

https://bugzilla.gnome.org/show_bug.cgi?id=624338
---
 ext/pulse/pulsesink.c |   38 +++-----------------------------------
 1 files changed, 3 insertions(+), 35 deletions(-)

diff --git a/ext/pulse/pulsesink.c b/ext/pulse/pulsesink.c
index 9feaed3..3f6f7ba 100644
--- a/ext/pulse/pulsesink.c
+++ b/ext/pulse/pulsesink.c
@@ -131,9 +131,7 @@ struct _GstPulseRingBufferClass
   GstRingBufferClass parent_class;
 };
 
-static void gst_pulseringbuffer_class_init (GstPulseRingBufferClass * klass);
-static void gst_pulseringbuffer_init (GstPulseRingBuffer * ringbuffer,
-    GstPulseRingBufferClass * klass);
+static GType gst_pulseringbuffer_get_type (void);
 static void gst_pulseringbuffer_finalize (GObject * object);
 
 static GstRingBufferClass *ring_parent_class = NULL;
@@ -151,32 +149,7 @@ static guint gst_pulseringbuffer_commit (GstRingBuffer * buf,
     guint64 * sample, guchar * data, gint in_samples, gint out_samples,
     gint * accum);
 
-/* ringbuffer abstract base class */
-static GType
-gst_pulseringbuffer_get_type (void)
-{
-  static GType ringbuffer_type = 0;
-
-  if (!ringbuffer_type) {
-    static const GTypeInfo ringbuffer_info = {
-      sizeof (GstPulseRingBufferClass),
-      NULL,
-      NULL,
-      (GClassInitFunc) gst_pulseringbuffer_class_init,
-      NULL,
-      NULL,
-      sizeof (GstPulseRingBuffer),
-      0,
-      (GInstanceInitFunc) gst_pulseringbuffer_init,
-      NULL
-    };
-
-    ringbuffer_type =
-        g_type_register_static (GST_TYPE_RING_BUFFER, "GstPulseSinkRingBuffer",
-        &ringbuffer_info, 0);
-  }
-  return ringbuffer_type;
-}
+G_DEFINE_TYPE (GstPulseRingBuffer, gst_pulseringbuffer, GST_TYPE_RING_BUFFER);
 
 static void
 gst_pulseringbuffer_class_init (GstPulseRingBufferClass * klass)
@@ -207,15 +180,10 @@ gst_pulseringbuffer_class_init (GstPulseRingBufferClass * klass)
       GST_DEBUG_FUNCPTR (gst_pulseringbuffer_clear);
 
   gstringbuffer_class->commit = GST_DEBUG_FUNCPTR (gst_pulseringbuffer_commit);
-
-  /* ref class from a thread-safe context to work around missing bit of
-   * thread-safety in GObject */
-  g_type_class_ref (GST_TYPE_PULSERING_BUFFER);
 }
 
 static void
-gst_pulseringbuffer_init (GstPulseRingBuffer * pbuf,
-    GstPulseRingBufferClass * g_class)
+gst_pulseringbuffer_init (GstPulseRingBuffer * pbuf)
 {
   pbuf->stream_name = NULL;
   pbuf->context = NULL;
-- 
1.7.2.1