Commit 10f3adfd authored by Wim Taymans's avatar Wim Taymans

clock: make abstract

Make the GstClock type abstract.
Fix a horrible hack in the clock unit test.
parent af73f3fc
......@@ -643,7 +643,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);
G_DEFINE_ABSTRACT_TYPE (GstClock, gst_clock, GST_TYPE_OBJECT);
static void
gst_clock_class_init (GstClockClass * klass)
......
......@@ -19,11 +19,27 @@
#include <gst/check/gstcheck.h>
static void
weak_notify (gpointer data, GObject * object)
typedef struct
{
*(gboolean *) data = FALSE;
}
GstClock parent;
} GstTestClock;
typedef struct
{
GstClockClass parent_class;
} GstTestClockClass;
#define GST_TYPE_TEST_CLOCK (gst_test_clock_get_type ())
#define GST_TEST_CLOCK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_TEST_CLOCK, GstTestClock))
#define GST_TEST_CLOCK_CAST(obj) ((GstTestClock *)(obj))
#define GST_IS_TEST_CLOCK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_TEST_CLOCK))
#define GST_TEST_CLOCK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_TEST_CLOCK, GstTestClockClass))
#define GST_IS_TEST_CLOCK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_TEST_CLOCK))
#define GST_TEST_CLOCK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_TEST_CLOCK, GstTestClockClass))
GType gst_test_clock_get_type (void);
G_DEFINE_TYPE (GstTestClock, gst_test_clock, GST_TYPE_CLOCK);
static GstClockReturn
fake_wait_async (GstClock * clock, GstClockEntry * entry)
......@@ -31,21 +47,38 @@ fake_wait_async (GstClock * clock, GstClockEntry * entry)
return GST_CLOCK_OK;
}
static void
gst_test_clock_class_init (GstTestClockClass * klass)
{
GstClockClass *clock_class;
clock_class = GST_CLOCK_CLASS (klass);
clock_class->wait_async = fake_wait_async;
}
static void
gst_test_clock_init (GstTestClock * clock)
{
}
static void
weak_notify (gpointer data, GObject * object)
{
*(gboolean *) data = FALSE;
}
GST_START_TEST (test_set_master_refcount)
{
GstClock *master, *slave;
GstClockClass *klass;
gboolean master_alive = TRUE;
/* create master and slave */
master = g_object_new (GST_TYPE_CLOCK, "name", "TestClockMaster", NULL);
slave = g_object_new (GST_TYPE_CLOCK, "name", "TestClockMaster", NULL);
master = g_object_new (GST_TYPE_TEST_CLOCK, "name", "TestClockMaster", NULL);
slave = g_object_new (GST_TYPE_TEST_CLOCK, "name", "TestClockMaster", NULL);
GST_OBJECT_FLAG_SET (slave, GST_CLOCK_FLAG_CAN_SET_MASTER);
/* look ma! i'm doing monkey patching in C */
klass = GST_CLOCK_GET_CLASS (master);
klass->wait_async = fake_wait_async;
fail_unless_equals_int (GST_OBJECT_REFCOUNT (master), 1);
fail_unless_equals_int (GST_OBJECT_REFCOUNT (slave), 1);
......@@ -72,8 +105,6 @@ GST_START_TEST (test_set_master_refcount)
fail_unless_equals_int (GST_OBJECT_REFCOUNT (slave), 1);
gst_object_unref (slave);
klass->wait_async = NULL;
}
GST_END_TEST;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment