trace: rework alloc tracing
[platform/upstream/gstreamer.git] / gst / gstclock.c
index b167238..be24d9f 100644 (file)
 #include "gstclock.h"
 #include "gstinfo.h"
 #include "gstutils.h"
+#include "glib-compat-private.h"
 
 #ifndef GST_DISABLE_TRACE
 /* #define GST_WITH_ALLOC_TRACE */
@@ -140,13 +141,13 @@ struct _GstClockPrivate
 
 /* seqlocks */
 #define read_seqbegin(clock)                                   \
-  g_atomic_int_get (&clock->ABI.priv->post_count);
+  g_atomic_int_get (&clock->priv->post_count);
 
 static inline gboolean
 read_seqretry (GstClock * clock, gint seq)
 {
   /* no retry if the seqnum did not change */
-  if (G_LIKELY (seq == g_atomic_int_get (&clock->ABI.priv->pre_count)))
+  if (G_LIKELY (seq == g_atomic_int_get (&clock->priv->pre_count)))
     return FALSE;
 
   /* wait for the writer to finish and retry */
@@ -158,12 +159,12 @@ read_seqretry (GstClock * clock, gint seq)
 #define write_seqlock(clock)                      \
 G_STMT_START {                                    \
   GST_OBJECT_LOCK (clock);                        \
-  g_atomic_int_inc (&clock->ABI.priv->pre_count);     \
+  g_atomic_int_inc (&clock->priv->pre_count);     \
 } G_STMT_END;
 
 #define write_sequnlock(clock)                    \
 G_STMT_START {                                    \
-  g_atomic_int_inc (&clock->ABI.priv->post_count);    \
+  g_atomic_int_inc (&clock->priv->post_count);    \
   GST_OBJECT_UNLOCK (clock);                      \
 } G_STMT_END;
 
@@ -177,8 +178,6 @@ static void gst_clock_get_property (GObject * object, guint prop_id,
 static void gst_clock_update_stats (GstClock * clock);
 
 
-static GstObjectClass *parent_class = NULL;
-
 /* static guint gst_clock_signals[LAST_SIGNAL] = { 0 }; */
 
 static GstClockID
@@ -189,7 +188,7 @@ gst_clock_entry_new (GstClock * clock, GstClockTime time,
 
   entry = g_slice_new (GstClockEntry);
 #ifndef GST_DISABLE_TRACE
-  gst_alloc_trace_new (_gst_clock_entry_trace, entry);
+  _gst_alloc_trace_new (_gst_clock_entry_trace, entry);
 #endif
   GST_CAT_DEBUG_OBJECT (GST_CAT_CLOCK, clock,
       "created entry %p, time %" GST_TIME_FORMAT, entry, GST_TIME_ARGS (time));
@@ -306,7 +305,7 @@ _gst_clock_id_free (GstClockID id)
     entry->destroy_data (entry->user_data);
 
 #ifndef GST_DISABLE_TRACE
-  gst_alloc_trace_free (_gst_clock_entry_trace, id);
+  _gst_alloc_trace_free (_gst_clock_entry_trace, id);
 #endif
   g_slice_free (GstClockEntry, id);
 }
@@ -649,6 +648,7 @@ gst_clock_id_unschedule (GstClockID id)
 /*
  * GstClock abstract base class implementation
  */
+#define gst_clock_parent_class parent_class
 G_DEFINE_TYPE (GstClock, gst_clock, GST_TYPE_OBJECT);
 
 static void
@@ -656,11 +656,9 @@ gst_clock_class_init (GstClockClass * klass)
 {
   GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
 
-  parent_class = g_type_class_peek_parent (klass);
-
 #ifndef GST_DISABLE_TRACE
   _gst_clock_entry_trace =
-      gst_alloc_trace_register (GST_CLOCK_ENTRY_TRACE_NAME);
+      _gst_alloc_trace_register (GST_CLOCK_ENTRY_TRACE_NAME, -1);
 #endif
 
   gobject_class->dispose = gst_clock_dispose;
@@ -695,10 +693,10 @@ gst_clock_init (GstClock * clock)
 {
   clock->last_time = 0;
   clock->entries = NULL;
-  clock->entries_changed = g_cond_new ();
+  g_cond_init (&clock->entries_changed);
   clock->stats = FALSE;
 
-  clock->ABI.priv =
+  clock->priv =
       G_TYPE_INSTANCE_GET_PRIVATE (clock, GST_TYPE_CLOCK, GstClockPrivate);
 
   clock->internal_calibration = 0;
@@ -706,7 +704,7 @@ gst_clock_init (GstClock * clock)
   clock->rate_numerator = 1;
   clock->rate_denominator = 1;
 
-  clock->slave_lock = g_mutex_new ();
+  g_mutex_init (&clock->slave_lock);
   clock->window_size = DEFAULT_WINDOW_SIZE;
   clock->window_threshold = DEFAULT_WINDOW_THRESHOLD;
   clock->filling = TRUE;
@@ -744,8 +742,8 @@ gst_clock_finalize (GObject * object)
   clock->times = NULL;
   GST_CLOCK_SLAVE_UNLOCK (clock);
 
-  g_cond_free (clock->entries_changed);
-  g_mutex_free (clock->slave_lock);
+  g_cond_clear (&clock->entries_changed);
+  g_mutex_clear (&clock->slave_lock);
 
   G_OBJECT_CLASS (parent_class)->finalize (object);
 }