code review

Original commit message from CVS:
code review
This commit is contained in:
Thomas Vander Stichele 2002-04-12 09:38:47 +00:00
parent 848e686664
commit 5a6cf24c16
8 changed files with 40 additions and 18 deletions

View file

@ -439,7 +439,8 @@ gst_buffer_copy (GstBuffer *buffer)
* @buf1: first source buffer * @buf1: first source buffer
* @buf2: second source buffer * @buf2: second source buffer
* *
* Determines whether a gst_buffer_span is free, or requires a memcpy. * Determines whether a gst_buffer_span is free (as in free beer),
* or requires a memcpy.
* *
* Returns: TRUE if the buffers are contiguous, FALSE if a copy would be required. * Returns: TRUE if the buffers are contiguous, FALSE if a copy would be required.
*/ */

View file

@ -113,7 +113,7 @@ struct _GstBuffer {
#endif #endif
/* flags */ /* flags */
guint16 flags; guint16 flags; /* boolean properties of buffer */
/* pointer to data, its size, and offset in original source if known */ /* pointer to data, its size, and offset in original source if known */
guchar *data; guchar *data;
@ -122,8 +122,8 @@ struct _GstBuffer {
guint32 offset; guint32 offset;
/* timestamp */ /* timestamp */
gint64 timestamp; gint64 timestamp; /* nanoseconds since zero */
gint64 maxage; gint64 maxage; /* FIXME: not used yet */
/* subbuffer support, who's my parent? */ /* subbuffer support, who's my parent? */
GstBuffer *parent; GstBuffer *parent;
@ -132,7 +132,7 @@ struct _GstBuffer {
GstBufferPool *pool; GstBufferPool *pool;
gpointer pool_private; gpointer pool_private;
/* utility function pointers */ /* utility function pointers, can override default */
GstBufferFreeFunc free; /* free the data associated with the buffer */ GstBufferFreeFunc free; /* free the data associated with the buffer */
GstBufferCopyFunc copy; /* copy the data from one buffer to another */ GstBufferCopyFunc copy; /* copy the data from one buffer to another */
}; };

View file

@ -45,18 +45,23 @@ extern GType _gst_caps_type;
#define GST_CAPS_IS_FIXED(caps) ((caps)->fixed) #define GST_CAPS_IS_FIXED(caps) ((caps)->fixed)
#define GST_CAPS_IS_CHAINED(caps) ((caps)->next) #define GST_CAPS_IS_CHAINED(caps) ((caps)->next)
/* CR1: id is an int corresponding to the quark for the mime type because
* it's really fast when doing a first-pass check for caps compatibility */
struct _GstCaps { struct _GstCaps {
gchar *name; /* the name of this caps */ gchar *name; /* the name of this caps */
guint16 id; /* type id (major type) */ guint16 id; /* type id (major type) representing
the mime type */
guint refcount; guint refcount;
gboolean fixed; /* this caps doesn't contain variable properties */ gboolean fixed; /* this caps doesn't contain variable properties */
GstProps *properties; /* properties for this capability */ GstProps *properties; /* properties for this capability */
GstCaps *next; GstCaps *next; /* not with a GList for efficiency */
}; };
/* factory macros which make it easier for plugins to instantiate */
#define GST_CAPS_NEW(name, type, a...) \ #define GST_CAPS_NEW(name, type, a...) \
gst_caps_new ( \ gst_caps_new ( \
name, \ name, \
@ -92,7 +97,7 @@ void gst_caps_destroy (GstCaps *caps);
void gst_caps_debug (GstCaps *caps, const gchar *label); void gst_caps_debug (GstCaps *caps, const gchar *label);
GstCaps* gst_caps_copy (GstCaps *caps); GstCaps* gst_caps_copy (GstCaps *caps);
GstCaps* gst_caps_copy_1 (GstCaps *caps); GstCaps* gst_caps_copy_first (GstCaps *caps);
GstCaps* gst_caps_copy_on_write (GstCaps *caps); GstCaps* gst_caps_copy_on_write (GstCaps *caps);
const gchar* gst_caps_get_name (GstCaps *caps); const gchar* gst_caps_get_name (GstCaps *caps);

View file

@ -109,6 +109,9 @@ gst_object_class_init (GstObjectClass *klass)
gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_object_set_property); gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_object_set_property);
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_object_get_property); gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_object_get_property);
/* CR1: we override the signal property so that an object can propagate the
* signal to the parent object */
gobject_class->dispatch_properties_changed = GST_DEBUG_FUNCPTR (gst_object_dispatch_properties_changed); gobject_class->dispatch_properties_changed = GST_DEBUG_FUNCPTR (gst_object_dispatch_properties_changed);
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NAME, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NAME,
@ -202,6 +205,7 @@ gst_object_unref (GstObject *object)
* Removes floating reference on an object. Any newly created object has * Removes floating reference on an object. Any newly created object has
* a refcount of 1 and is FLOATING. This function should be used when * a refcount of 1 and is FLOATING. This function should be used when
* creating a new object to symbolically 'take ownership of' the object. * creating a new object to symbolically 'take ownership of' the object.
* Use #gst_object_set_parent to have this done for you.
*/ */
void void
gst_object_sink (GstObject *object) gst_object_sink (GstObject *object)
@ -222,6 +226,7 @@ gst_object_sink (GstObject *object)
* @object: GstObject to destroy * @object: GstObject to destroy
* *
* Destroy the object. * Destroy the object.
*
*/ */
void void
gst_object_destroy (GstObject *object) gst_object_destroy (GstObject *object)
@ -330,7 +335,8 @@ gst_object_set_name (GstObject *object, const gchar *name)
const gchar* const gchar*
gst_object_get_name (GstObject *object) gst_object_get_name (GstObject *object)
{ {
g_return_val_if_fail (object != NULL, NULL); /* CR1: GLib checks for NULL */
//FIXME: _REDUNDANT g_return_val_if_fail (object != NULL, NULL);
g_return_val_if_fail (GST_IS_OBJECT (object), NULL); g_return_val_if_fail (GST_IS_OBJECT (object), NULL);
return object->name; return object->name;
@ -503,9 +509,9 @@ gst_object_check_uniqueness (GList *list, const gchar *name)
while (list) { while (list) {
GstObject *child = GST_OBJECT (list->data); GstObject *child = GST_OBJECT (list->data);
list = g_list_next(list); list = g_list_next (list);
if (strcmp(GST_OBJECT_NAME(child), name) == 0) if (strcmp (GST_OBJECT_NAME (child), name) == 0)
return FALSE; return FALSE;
} }
@ -615,6 +621,10 @@ gst_object_get_property (GObject* object, guint prop_id,
break; break;
} }
} }
/* CR1: the GObject changing a property emits signals to it's parents
* so that the app can connect a listener to the top-level bin */
static void static void
gst_object_dispatch_properties_changed (GObject *object, gst_object_dispatch_properties_changed (GObject *object,
guint n_pspecs, guint n_pspecs,
@ -644,7 +654,7 @@ gst_object_dispatch_properties_changed (GObject *object,
* @object: GstObject to get the path from * @object: GstObject to get the path from
* *
* Generates a string describing the path of the object in * Generates a string describing the path of the object in
* the object hierarchy. Usefull for debugging * the object hierarchy. Only useful (or used) for debugging
* *
* Returns: a string describing the path of the object * Returns: a string describing the path of the object
*/ */

View file

@ -90,6 +90,7 @@ struct _GstObject {
guint32 flags; guint32 flags;
}; };
/* signal_object is used to signal to the whole class */
struct _GstObjectClass { struct _GstObjectClass {
GObjectClass parent_class; GObjectClass parent_class;
@ -123,7 +124,7 @@ struct _GstObjectClass {
#define GST_OBJECT_DESTROYED(obj) (GST_FLAG_IS_SET (obj, GST_DESTROYED)) #define GST_OBJECT_DESTROYED(obj) (GST_FLAG_IS_SET (obj, GST_DESTROYED))
#define GST_OBJECT_FLOATING(obj) (GST_FLAG_IS_SET (obj, GST_FLOATING)) #define GST_OBJECT_FLOATING(obj) (GST_FLAG_IS_SET (obj, GST_FLOATING))
/* object locking */ /* CR1: object locking - GObject 2.0 doesn't have threadsafe locking */
#define GST_LOCK(obj) (g_mutex_lock(GST_OBJECT_CAST(obj)->lock)) #define GST_LOCK(obj) (g_mutex_lock(GST_OBJECT_CAST(obj)->lock))
#define GST_TRYLOCK(obj) (g_mutex_trylock(GST_OBJECT_CAST(obj)->lock)) #define GST_TRYLOCK(obj) (g_mutex_trylock(GST_OBJECT_CAST(obj)->lock))
#define GST_UNLOCK(obj) (g_mutex_unlock(GST_OBJECT_CAST(obj)->lock)) #define GST_UNLOCK(obj) (g_mutex_unlock(GST_OBJECT_CAST(obj)->lock))

View file

@ -178,6 +178,7 @@ struct _GstRealPad {
GstRealPad *peer; GstRealPad *peer;
GstBuffer *bufpen; GstBuffer *bufpen;
//CR1: FIXME: regiontype should go away
GstRegionType regiontype; GstRegionType regiontype;
guint64 offset; guint64 offset;
guint64 len; guint64 len;
@ -311,6 +312,7 @@ struct _GstPadTemplateClass {
void (*pad_created) (GstPadTemplate *templ, GstPad *pad); void (*pad_created) (GstPadTemplate *templ, GstPad *pad);
}; };
/* CR1: the space after 'a' is necessary because of preprocessing in gcc */
#define GST_PAD_TEMPLATE_NEW(padname, dir, pres, a...) \ #define GST_PAD_TEMPLATE_NEW(padname, dir, pres, a...) \
gst_pad_template_new ( \ gst_pad_template_new ( \
padname, \ padname, \

View file

@ -139,6 +139,7 @@ gst_thread_init (GstThread *thread)
GST_DEBUG (GST_CAT_THREAD, "initializing thread"); GST_DEBUG (GST_CAT_THREAD, "initializing thread");
/* we're a manager by default */ /* we're a manager by default */
/* CR1: the GstBin code checks these flags */
GST_FLAG_SET (thread, GST_BIN_FLAG_MANAGER); GST_FLAG_SET (thread, GST_BIN_FLAG_MANAGER);
GST_FLAG_SET (thread, GST_BIN_SELF_SCHEDULABLE); GST_FLAG_SET (thread, GST_BIN_SELF_SCHEDULABLE);
@ -434,7 +435,7 @@ gst_thread_change_state (GstElement * element)
* @arg: the thread to start * @arg: the thread to start
* *
* The main loop of the thread. The thread will iterate * The main loop of the thread. The thread will iterate
* while the state is GST_THREAD_STATE_SPINNING * while the state is GST_THREAD_STATE_SPINNING.
*/ */
static void * static void *
gst_thread_main_loop (void *arg) gst_thread_main_loop (void *arg)
@ -467,6 +468,8 @@ gst_thread_main_loop (void *arg)
/***** THREAD IS NOW IN READY STATE *****/ /***** THREAD IS NOW IN READY STATE *****/
/* CR1: most of this code is handshaking */
/* do this while the thread lives */
while (!GST_FLAG_IS_SET (thread, GST_THREAD_STATE_REAPING)) { while (!GST_FLAG_IS_SET (thread, GST_THREAD_STATE_REAPING)) {
/* NOTE we hold the thread lock at this point */ /* NOTE we hold the thread lock at this point */
/* what we do depends on what state we're in */ /* what we do depends on what state we're in */
@ -503,7 +506,7 @@ gst_thread_main_loop (void *arg)
gst_element_statename (GST_STATE_PAUSED), gst_element_statename (GST_STATE_PAUSED),
gst_element_statename (GST_STATE_READY), gst_element_statename (GST_STATE_READY),
gst_element_statename (GST_STATE_PLAYING)); gst_element_statename (GST_STATE_PLAYING));
g_cond_wait (thread->cond,thread->lock); g_cond_wait (thread->cond, thread->lock);
/* this must have happened by a state change in the thread context */ /* this must have happened by a state change in the thread context */
if (GST_STATE_PENDING (thread) != GST_STATE_READY && if (GST_STATE_PENDING (thread) != GST_STATE_READY &&
@ -568,7 +571,7 @@ gst_thread_main_loop (void *arg)
break; break;
} }
} }
/* we need to destroy the scheduler here bacause it has mapped it's /* we need to destroy the scheduler here because it has mapped it's
* stack into the threads stack space */ * stack into the threads stack space */
gst_scheduler_reset (GST_ELEMENT_SCHED (thread)); gst_scheduler_reset (GST_ELEMENT_SCHED (thread));

View file

@ -67,8 +67,8 @@ struct _GstThread {
pthread_t thread_id; /* id of the thread, if any */ pthread_t thread_id; /* id of the thread, if any */
gint pid; /* the pid of the thread */ gint pid; /* the pid of the thread */
gint ppid; /* the pid of the thread's parent process */ gint ppid; /* the pid of the thread's parent process */
GMutex *lock; /* thread lock/condititon pair... */ GMutex *lock; /* thread lock/condititon pair ... */
GCond *cond; /* used to control the thread */ GCond *cond; /* .... used to control the thread */
gint transition; /* the current state transition */ gint transition; /* the current state transition */
}; };