X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=gst%2Fgstsystemclock.c;h=73dbfb42439b55740d2bfc3e57796c9fc0056d28;hb=94ba1cea88788fd3ad72fadcc2ceb7884ed6df50;hp=dbdecff6fc4547a0ef4e9656e0b864b3228dc5ec;hpb=149127b755088a1bbc1982cdbf60a2c73aaa0f6c;p=platform%2Fupstream%2Fgstreamer.git diff --git a/gst/gstsystemclock.c b/gst/gstsystemclock.c index dbdecff..73dbfb4 100644 --- a/gst/gstsystemclock.c +++ b/gst/gstsystemclock.c @@ -22,6 +22,7 @@ /** * SECTION:gstsystemclock + * @title: GstSystemClock * @short_description: Default clock that uses the current system time * @see_also: #GstClock * @@ -88,16 +89,13 @@ struct _GstSystemClockPrivate #ifdef G_OS_WIN32 LARGE_INTEGER start; LARGE_INTEGER frequency; + guint64 ratio; #endif /* G_OS_WIN32 */ #ifdef __APPLE__ struct mach_timebase_info mach_timebase; #endif }; -#define GST_SYSTEM_CLOCK_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GST_TYPE_SYSTEM_CLOCK, \ - GstSystemClockPrivate)) - #ifdef HAVE_POSIX_TIMERS # ifdef HAVE_MONOTONIC_CLOCK # define DEFAULT_CLOCK_TYPE GST_CLOCK_TYPE_MONOTONIC @@ -145,7 +143,7 @@ static GMutex _gst_sysclock_mutex; /* 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); +G_DEFINE_TYPE_WITH_PRIVATE (GstSystemClock, gst_system_clock, GST_TYPE_CLOCK); static void gst_system_clock_class_init (GstSystemClockClass * klass) @@ -156,8 +154,6 @@ gst_system_clock_class_init (GstSystemClockClass * klass) gobject_class = (GObjectClass *) klass; gstclock_class = (GstClockClass *) klass; - g_type_class_add_private (klass, sizeof (GstSystemClockPrivate)); - gobject_class->dispose = gst_system_clock_dispose; gobject_class->set_property = gst_system_clock_set_property; gobject_class->get_property = gst_system_clock_get_property; @@ -186,7 +182,7 @@ gst_system_clock_init (GstSystemClock * clock) GST_CLOCK_FLAG_CAN_DO_PERIODIC_SYNC | GST_CLOCK_FLAG_CAN_DO_PERIODIC_ASYNC); - clock->priv = priv = GST_SYSTEM_CLOCK_GET_PRIVATE (clock); + clock->priv = priv = gst_system_clock_get_instance_private (clock); priv->clock_type = DEFAULT_CLOCK_TYPE; priv->timer = gst_poll_new_timer (); @@ -200,6 +196,7 @@ gst_system_clock_init (GstSystemClock * clock) if (priv->frequency.QuadPart != 0) /* we take a base time so that time starts from 0 to ease debugging */ QueryPerformanceCounter (&priv->start); + priv->ratio = GST_SECOND / priv->frequency.QuadPart; #endif /* G_OS_WIN32 */ #ifdef __APPLE__ @@ -292,7 +289,7 @@ gst_system_clock_get_property (GObject * object, guint prop_id, GValue * value, /** * gst_system_clock_set_default: - * @new_clock: a #GstClock + * @new_clock: (allow-none): a #GstClock * * Sets the default system clock that can be obtained with * gst_system_clock_obtain(). @@ -354,8 +351,8 @@ gst_system_clock_obtain (void) clock = g_object_new (GST_TYPE_SYSTEM_CLOCK, "name", "GstSystemClock", NULL); - g_assert (!g_object_is_floating (G_OBJECT (clock))); - + /* Clear floating flag */ + gst_object_ref_sink (clock); _the_system_clock = clock; g_mutex_unlock (&_gst_sysclock_mutex); } else { @@ -585,8 +582,8 @@ gst_system_clock_get_internal_time (GstClock * clock) /* we prefer the highly accurate performance counters on windows */ QueryPerformanceCounter (&now); - return gst_util_uint64_scale (now.QuadPart - sysclock->priv->start.QuadPart, - GST_SECOND, sysclock->priv->frequency.QuadPart); + return ((now.QuadPart - + sysclock->priv->start.QuadPart) * sysclock->priv->ratio); } else #endif /* G_OS_WIN32 */ #if !defined HAVE_POSIX_TIMERS || !defined HAVE_CLOCK_GETTIME