winks: store priv pointer instead of looking it up

This commit is contained in:
Ole André Vadla Ravnås 2009-09-07 16:09:34 +02:00
parent 00bc7860ff
commit f2b4d8990d
6 changed files with 39 additions and 23 deletions

View file

@ -24,7 +24,7 @@
GST_DEBUG_CATEGORY_EXTERN (gst_ks_debug); GST_DEBUG_CATEGORY_EXTERN (gst_ks_debug);
#define GST_CAT_DEFAULT gst_ks_debug #define GST_CAT_DEFAULT gst_ks_debug
typedef struct struct _GstKsClockPrivate
{ {
GMutex *mutex; GMutex *mutex;
GCond *client_cond; GCond *client_cond;
@ -41,11 +41,9 @@ typedef struct
gboolean worker_initialized; gboolean worker_initialized;
GstClock *master_clock; GstClock *master_clock;
} GstKsClockPrivate; };
#define GST_KS_CLOCK_GET_PRIVATE(o) \ #define GST_KS_CLOCK_GET_PRIVATE(o) ((o)->priv)
(G_TYPE_INSTANCE_GET_PRIVATE ((o), GST_TYPE_KS_CLOCK, \
GstKsClockPrivate))
#define GST_KS_CLOCK_LOCK() g_mutex_lock (priv->mutex) #define GST_KS_CLOCK_LOCK() g_mutex_lock (priv->mutex)
#define GST_KS_CLOCK_UNLOCK() g_mutex_unlock (priv->mutex) #define GST_KS_CLOCK_UNLOCK() g_mutex_unlock (priv->mutex)
@ -74,7 +72,12 @@ gst_ks_clock_class_init (GstKsClockClass * klass)
static void static void
gst_ks_clock_init (GstKsClock * self, GstKsClockClass * gclass) gst_ks_clock_init (GstKsClock * self, GstKsClockClass * gclass)
{ {
GstKsClockPrivate *priv = GST_KS_CLOCK_GET_PRIVATE (self); GstKsClockPrivate *priv;
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GST_TYPE_KS_CLOCK,
GstKsClockPrivate);
priv = GST_KS_CLOCK_GET_PRIVATE (self);
priv->mutex = g_mutex_new (); priv->mutex = g_mutex_new ();
priv->client_cond = g_cond_new (); priv->client_cond = g_cond_new ();

View file

@ -38,12 +38,15 @@ G_BEGIN_DECLS
#define GST_IS_KS_CLOCK_CLASS(klass) \ #define GST_IS_KS_CLOCK_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_KS_CLOCK)) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_KS_CLOCK))
typedef struct _GstKsClock GstKsClock; typedef struct _GstKsClock GstKsClock;
typedef struct _GstKsClockClass GstKsClockClass; typedef struct _GstKsClockClass GstKsClockClass;
typedef struct _GstKsClockPrivate GstKsClockPrivate;
struct _GstKsClock struct _GstKsClock
{ {
GObject parent; GObject parent;
GstKsClockPrivate *priv;
}; };
struct _GstKsClockClass struct _GstKsClockClass

View file

@ -57,7 +57,7 @@ typedef struct
OVERLAPPED overlapped; OVERLAPPED overlapped;
} ReadRequest; } ReadRequest;
typedef struct struct _GstKsVideoDevicePrivate
{ {
gboolean open; gboolean open;
KSSTATE state; KSSTATE state;
@ -87,9 +87,7 @@ typedef struct
GstClockTime last_timestamp; GstClockTime last_timestamp;
} GstKsVideoDevicePrivate; } GstKsVideoDevicePrivate;
#define GST_KS_VIDEO_DEVICE_GET_PRIVATE(o) \ #define GST_KS_VIDEO_DEVICE_GET_PRIVATE(o) ((o)->priv)
(G_TYPE_INSTANCE_GET_PRIVATE ((o), GST_TYPE_KS_VIDEO_DEVICE, \
GstKsVideoDevicePrivate))
static void gst_ks_video_device_dispose (GObject * object); static void gst_ks_video_device_dispose (GObject * object);
static void gst_ks_video_device_get_property (GObject * object, guint prop_id, static void gst_ks_video_device_get_property (GObject * object, guint prop_id,
@ -132,8 +130,12 @@ static void
gst_ks_video_device_init (GstKsVideoDevice * self, gst_ks_video_device_init (GstKsVideoDevice * self,
GstKsVideoDeviceClass * gclass) GstKsVideoDeviceClass * gclass)
{ {
GstKsVideoDevicePrivate *priv = GST_KS_VIDEO_DEVICE_GET_PRIVATE (self); GstKsVideoDevicePrivate *priv;
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GST_TYPE_KS_VIDEO_DEVICE,
GstKsVideoDevicePrivate);
priv = GST_KS_VIDEO_DEVICE_GET_PRIVATE (self);
priv->open = FALSE; priv->open = FALSE;
priv->state = KSSTATE_STOP; priv->state = KSSTATE_STOP;
} }

View file

@ -38,12 +38,15 @@ G_BEGIN_DECLS
#define GST_IS_KS_VIDEO_DEVICE_CLASS(klass) \ #define GST_IS_KS_VIDEO_DEVICE_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_KS_VIDEO_DEVICE)) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_KS_VIDEO_DEVICE))
typedef struct _GstKsVideoDevice GstKsVideoDevice; typedef struct _GstKsVideoDevice GstKsVideoDevice;
typedef struct _GstKsVideoDeviceClass GstKsVideoDeviceClass; typedef struct _GstKsVideoDeviceClass GstKsVideoDeviceClass;
typedef struct _GstKsVideoDevicePrivate GstKsVideoDevicePrivate;
struct _GstKsVideoDevice struct _GstKsVideoDevice
{ {
GObject parent; GObject parent;
GstKsVideoDevicePrivate *priv;
}; };
struct _GstKsVideoDeviceClass struct _GstKsVideoDeviceClass

View file

@ -84,7 +84,7 @@ typedef enum
KS_WORKER_STATE_ERROR, KS_WORKER_STATE_ERROR,
} KsWorkerState; } KsWorkerState;
typedef struct struct _GstKsVideoSrcPrivate
{ {
/* Properties */ /* Properties */
gchar *device_path; gchar *device_path;
@ -118,11 +118,9 @@ typedef struct
GstClockTime last_sampling; GstClockTime last_sampling;
guint count; guint count;
guint fps; guint fps;
} GstKsVideoSrcPrivate; };
#define GST_KS_VIDEO_SRC_GET_PRIVATE(o) \ #define GST_KS_VIDEO_SRC_GET_PRIVATE(o) ((o)->priv)
(G_TYPE_INSTANCE_GET_PRIVATE ((o), GST_TYPE_KS_VIDEO_SRC, \
GstKsVideoSrcPrivate))
static void gst_ks_video_src_init_interfaces (GType type); static void gst_ks_video_src_init_interfaces (GType type);
@ -238,8 +236,12 @@ gst_ks_video_src_class_init (GstKsVideoSrcClass * klass)
static void static void
gst_ks_video_src_init (GstKsVideoSrc * self, GstKsVideoSrcClass * gclass) gst_ks_video_src_init (GstKsVideoSrc * self, GstKsVideoSrcClass * gclass)
{ {
GstKsVideoSrcPrivate *priv = GST_KS_VIDEO_SRC_GET_PRIVATE (self);
GstBaseSrc *basesrc = GST_BASE_SRC (self); GstBaseSrc *basesrc = GST_BASE_SRC (self);
GstKsVideoSrcPrivate *priv;
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GST_TYPE_KS_VIDEO_SRC,
GstKsVideoSrcPrivate);
priv = GST_KS_VIDEO_SRC_GET_PRIVATE (self);
gst_base_src_set_live (basesrc, TRUE); gst_base_src_set_live (basesrc, TRUE);
gst_base_src_set_format (basesrc, GST_FORMAT_TIME); gst_base_src_set_format (basesrc, GST_FORMAT_TIME);

View file

@ -36,12 +36,15 @@ G_BEGIN_DECLS
#define GST_IS_KS_VIDEO_SRC_CLASS(klass) \ #define GST_IS_KS_VIDEO_SRC_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_KS_VIDEO_SRC)) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_KS_VIDEO_SRC))
typedef struct _GstKsVideoSrc GstKsVideoSrc; typedef struct _GstKsVideoSrc GstKsVideoSrc;
typedef struct _GstKsVideoSrcClass GstKsVideoSrcClass; typedef struct _GstKsVideoSrcClass GstKsVideoSrcClass;
typedef struct _GstKsVideoSrcPrivate GstKsVideoSrcPrivate;
struct _GstKsVideoSrc struct _GstKsVideoSrc
{ {
GstPushSrc push_src; GstPushSrc push_src;
GstKsVideoSrcPrivate * priv;
}; };
struct _GstKsVideoSrcClass struct _GstKsVideoSrcClass