From 8998cf840d7d9aad47a52ff0ef80a86134cde819 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim-Philipp=20M=C3=BCller?= Date: Tue, 3 Jun 2014 23:38:28 +0100 Subject: [PATCH] datetime: change internal implementation to mini object And move type stuff from GstValue to GstDateTime. --- gst/gstdatetime.c | 24 ++++++++++++------------ gst/gstdatetime.h | 12 ++++++++++++ gst/gstvalue.c | 3 --- gst/gstvalue.h | 12 ------------ 4 files changed, 24 insertions(+), 27 deletions(-) diff --git a/gst/gstdatetime.c b/gst/gstdatetime.c index 083b5da..94ae262 100644 --- a/gst/gstdatetime.c +++ b/gst/gstdatetime.c @@ -56,12 +56,17 @@ typedef enum struct _GstDateTime { + GstMiniObject mini_object; + GDateTime *datetime; GstDateTimeFields fields; - volatile gint ref_count; }; +GST_DEFINE_MINI_OBJECT_TYPE (GstDateTime, gst_date_time); + +static void gst_date_time_free (GstDateTime * datetime); + /** * gst_date_time_new_from_g_date_time: * @dt: (transfer full): the #GDateTime. The new #GstDateTime takes ownership. @@ -81,9 +86,12 @@ gst_date_time_new_from_g_date_time (GDateTime * dt) return NULL; gst_dt = g_slice_new (GstDateTime); + + gst_mini_object_init (GST_MINI_OBJECT_CAST (gst_dt), 0, GST_TYPE_DATE_TIME, + NULL, NULL, (GstMiniObjectFreeFunction) gst_date_time_free); + gst_dt->datetime = dt; gst_dt->fields = GST_DATE_TIME_FIELDS_YMD_HMS; - gst_dt->ref_count = 1; return gst_dt; } @@ -868,7 +876,6 @@ ymd: return gst_date_time_new_ymd (year, month, day); } - static void gst_date_time_free (GstDateTime * datetime) { @@ -887,10 +894,7 @@ gst_date_time_free (GstDateTime * datetime) GstDateTime * gst_date_time_ref (GstDateTime * datetime) { - g_return_val_if_fail (datetime != NULL, NULL); - g_return_val_if_fail (datetime->ref_count > 0, NULL); - g_atomic_int_inc (&datetime->ref_count); - return datetime; + return (GstDateTime *) gst_mini_object_ref (GST_MINI_OBJECT_CAST (datetime)); } /** @@ -903,9 +907,5 @@ gst_date_time_ref (GstDateTime * datetime) void gst_date_time_unref (GstDateTime * datetime) { - g_return_if_fail (datetime != NULL); - g_return_if_fail (datetime->ref_count > 0); - - if (g_atomic_int_dec_and_test (&datetime->ref_count)) - gst_date_time_free (datetime); + gst_mini_object_unref (GST_MINI_OBJECT_CAST (datetime)); } diff --git a/gst/gstdatetime.h b/gst/gstdatetime.h index e0d3c5b..879ab4a 100644 --- a/gst/gstdatetime.h +++ b/gst/gstdatetime.h @@ -36,6 +36,18 @@ G_BEGIN_DECLS */ typedef struct _GstDateTime GstDateTime; +/** + * GST_TYPE_DATE_TIME: + * + * a boxed #GValue type for #GstDateTime that represents a date and time. + * + * Returns: the #GType of GstDateTime + */ + +#define GST_TYPE_DATE_TIME gst_date_time_get_type() + +GType gst_date_time_get_type (void); + /* query which fields are set */ gboolean gst_date_time_has_year (const GstDateTime * datetime); diff --git a/gst/gstvalue.c b/gst/gstvalue.c index a38cce0..e4932bc 100644 --- a/gst/gstvalue.c +++ b/gst/gstvalue.c @@ -6029,9 +6029,6 @@ static const GTypeValueTable _gst_fraction_value_table = { FUNC_VALUE_GET_TYPE (fraction, "GstFraction"); -G_DEFINE_BOXED_TYPE (GstDateTime, gst_date_time, - (GBoxedCopyFunc) gst_date_time_ref, (GBoxedFreeFunc) gst_date_time_unref); - static const GTypeValueTable _gst_bitmask_value_table = { gst_value_init_bitmask, NULL, diff --git a/gst/gstvalue.h b/gst/gstvalue.h index bdd0bce..52baef5 100644 --- a/gst/gstvalue.h +++ b/gst/gstvalue.h @@ -273,16 +273,6 @@ G_BEGIN_DECLS #define GST_TYPE_FRACTION gst_fraction_get_type () /** - * GST_TYPE_DATE_TIME: - * - * a boxed #GValue type for #GstDateTime that represents a date and time. - * - * Returns: the #GType of GstDateTime - */ - -#define GST_TYPE_DATE_TIME gst_date_time_get_type () - -/** * GST_TYPE_BITMASK: * * a #GValue type that represents a 64-bit bitmask. @@ -405,8 +395,6 @@ GType gst_bitmask_get_type (void); GType gst_g_thread_get_type (void); #endif -GType gst_date_time_get_type (void); - void gst_value_register (const GstValueTable *table); void gst_value_init_and_copy (GValue *dest, const GValue *src); -- 2.7.4