memory: make writability check into a method
[platform/upstream/gstreamer.git] / gst / gstsystemclock.c
index 03bae21..504cd01 100644 (file)
@@ -44,6 +44,7 @@
 #include "gstenumtypes.h"
 #include "gstpoll.h"
 #include "gstutils.h"
+#include "glib-compat-private.h"
 
 #include <errno.h>
 
 #  define EWOULDBLOCK EAGAIN    /* This is just to placate gcc */
 #endif /* G_OS_WIN32 */
 
-#define GET_ENTRY_STATUS(e)          (g_atomic_int_get(&GST_CLOCK_ENTRY_STATUS(e)))
+#define GET_ENTRY_STATUS(e)          ((GstClockReturn) g_atomic_int_get(&GST_CLOCK_ENTRY_STATUS(e)))
 #define SET_ENTRY_STATUS(e,val)      (g_atomic_int_set(&GST_CLOCK_ENTRY_STATUS(e),(val)))
-#define CAS_ENTRY_STATUS(e,old,val)  (g_atomic_int_compare_and_exchange(\
-                                       ((volatile gint *)&GST_CLOCK_ENTRY_STATUS(e)), (old), (val)))
+#define CAS_ENTRY_STATUS(e,old,val)  (G_ATOMIC_INT_COMPARE_AND_EXCHANGE(\
+                                       (&GST_CLOCK_ENTRY_STATUS(e)), (old), (val)))
 
 /* Define this to get some extra debug about jitter from each clock_wait */
 #undef WAIT_DEBUGGING
@@ -122,10 +123,9 @@ static void gst_system_clock_add_wakeup (GstSystemClock * sysclock);
 
 static GStaticMutex _gst_sysclock_mutex = G_STATIC_MUTEX_INIT;
 
-static GstClockClass *parent_class = NULL;
-
 /* static guint gst_system_clock_signals[LAST_SIGNAL] = { 0 }; */
 
+#define gst_system_clock_parent_class parent_class
 G_DEFINE_TYPE (GstSystemClock, gst_system_clock, GST_TYPE_CLOCK);
 
 static void
@@ -137,8 +137,6 @@ gst_system_clock_class_init (GstSystemClockClass * klass)
   gobject_class = (GObjectClass *) klass;
   gstclock_class = (GstClockClass *) klass;
 
-  parent_class = g_type_class_peek_parent (klass);
-
   g_type_class_add_private (klass, sizeof (GstSystemClockPrivate));
 
   gobject_class->dispose = gst_system_clock_dispose;
@@ -236,7 +234,7 @@ gst_system_clock_set_property (GObject * object, guint prop_id,
 
   switch (prop_id) {
     case PROP_CLOCK_TYPE:
-      sysclock->priv->clock_type = g_value_get_enum (value);
+      sysclock->priv->clock_type = (GstClockType) g_value_get_enum (value);
       GST_CAT_DEBUG (GST_CAT_CLOCK, "clock-type set to %d",
           sysclock->priv->clock_type);
       break;
@@ -734,8 +732,14 @@ gst_system_clock_start_async (GstSystemClock * clock)
   if (G_LIKELY (clock->thread != NULL))
     return TRUE;                /* Thread already running. Nothing to do */
 
+#if !GLIB_CHECK_VERSION (2, 31, 0)
   clock->thread = g_thread_create ((GThreadFunc) gst_system_clock_async_thread,
       clock, TRUE, &error);
+#else
+  clock->thread = g_thread_try_new ("GstSystemClock",
+      (GThreadFunc) gst_system_clock_async_thread, clock, &error);
+#endif
+
   if (G_UNLIKELY (error))
     goto no_thread;