datetime: change internal implementation to mini object

And move type stuff from GstValue to GstDateTime.
This commit is contained in:
Tim-Philipp Müller 2014-06-03 23:38:28 +01:00
parent f446280740
commit 8998cf840d
4 changed files with 24 additions and 27 deletions

View file

@ -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));
}

View file

@ -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);

View file

@ -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,

View file

@ -272,16 +272,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:
*
@ -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);