ges: Add guards to all API calls in GESTimelineObject

And reindent the .h file
This commit is contained in:
Thibault Saunier 2011-12-07 20:50:13 -03:00
parent 714a7bf886
commit c0d60b9d17
2 changed files with 66 additions and 29 deletions

View file

@ -406,6 +406,9 @@ ges_timeline_object_create_track_object (GESTimelineObject * object,
GESTimelineObjectClass *class; GESTimelineObjectClass *class;
GESTrackObject *res; GESTrackObject *res;
g_return_val_if_fail (GES_IS_TIMELINE_OBJECT (object), NULL);
g_return_val_if_fail (GES_IS_TRACK (track), NULL);
class = GES_TIMELINE_OBJECT_GET_CLASS (object); class = GES_TIMELINE_OBJECT_GET_CLASS (object);
if (G_UNLIKELY (class->create_track_object == NULL)) { if (G_UNLIKELY (class->create_track_object == NULL)) {
@ -438,6 +441,9 @@ ges_timeline_object_create_track_objects (GESTimelineObject * object,
{ {
GESTimelineObjectClass *klass; GESTimelineObjectClass *klass;
g_return_val_if_fail (GES_IS_TIMELINE_OBJECT (object), FALSE);
g_return_val_if_fail (GES_IS_TRACK (track), FALSE);
klass = GES_TIMELINE_OBJECT_GET_CLASS (object); klass = GES_TIMELINE_OBJECT_GET_CLASS (object);
if (!(klass->create_track_objects)) { if (!(klass->create_track_objects)) {
@ -492,6 +498,9 @@ ges_timeline_object_add_track_object (GESTimelineObject * object, GESTrackObject
gboolean is_effect = GES_IS_TRACK_EFFECT (trobj); gboolean is_effect = GES_IS_TRACK_EFFECT (trobj);
GESTimelineObjectClass *klass = GES_TIMELINE_OBJECT_GET_CLASS (object); GESTimelineObjectClass *klass = GES_TIMELINE_OBJECT_GET_CLASS (object);
g_return_val_if_fail (GES_IS_TIMELINE_OBJECT (object), FALSE);
g_return_val_if_fail (GES_IS_TRACK_OBJECT (trobj), FALSE);
GST_LOG ("Got a TrackObject : %p , setting the timeline object as its" GST_LOG ("Got a TrackObject : %p , setting the timeline object as its"
"creator. Is a TrackEffect %i", trobj, is_effect); "creator. Is a TrackEffect %i", trobj, is_effect);
@ -601,6 +610,9 @@ ges_timeline_object_release_track_object (GESTimelineObject * object,
ObjectMapping *mapping = NULL; ObjectMapping *mapping = NULL;
GESTimelineObjectClass *klass = GES_TIMELINE_OBJECT_GET_CLASS (object); GESTimelineObjectClass *klass = GES_TIMELINE_OBJECT_GET_CLASS (object);
g_return_val_if_fail (GES_IS_TIMELINE_OBJECT (object), FALSE);
g_return_val_if_fail (GES_IS_TRACK_OBJECT (trackobject), FALSE);
GST_DEBUG ("object:%p, trackobject:%p", object, trackobject); GST_DEBUG ("object:%p, trackobject:%p", object, trackobject);
if (!(g_list_find (object->priv->trackobjects, trackobject))) { if (!(g_list_find (object->priv->trackobjects, trackobject))) {
@ -720,6 +732,8 @@ ges_timeline_object_set_start_internal (GESTimelineObject * object,
GESTrackObject *tr; GESTrackObject *tr;
ObjectMapping *map; ObjectMapping *map;
g_return_val_if_fail (GES_IS_TIMELINE_OBJECT (object), FALSE);
GST_DEBUG ("object:%p, start:%" GST_TIME_FORMAT, GST_DEBUG ("object:%p, start:%" GST_TIME_FORMAT,
object, GST_TIME_ARGS (start)); object, GST_TIME_ARGS (start));
@ -769,6 +783,8 @@ ges_timeline_object_set_inpoint_internal (GESTimelineObject * object,
GList *tmp; GList *tmp;
GESTrackObject *tr; GESTrackObject *tr;
g_return_val_if_fail (GES_IS_TIMELINE_OBJECT (object), FALSE);
GST_DEBUG ("object:%p, inpoint:%" GST_TIME_FORMAT, GST_DEBUG ("object:%p, inpoint:%" GST_TIME_FORMAT,
object, GST_TIME_ARGS (inpoint)); object, GST_TIME_ARGS (inpoint));
@ -810,6 +826,8 @@ ges_timeline_object_set_duration_internal (GESTimelineObject * object,
GList *tmp; GList *tmp;
GESTrackObject *tr; GESTrackObject *tr;
g_return_val_if_fail (GES_IS_TIMELINE_OBJECT (object), FALSE);
GST_DEBUG ("object:%p, duration:%" GST_TIME_FORMAT, GST_DEBUG ("object:%p, duration:%" GST_TIME_FORMAT,
object, GST_TIME_ARGS (duration)); object, GST_TIME_ARGS (duration));
@ -850,11 +868,14 @@ ges_timeline_object_set_priority_internal (GESTimelineObject * object,
GList *tmp; GList *tmp;
GESTrackObject *tr; GESTrackObject *tr;
ObjectMapping *map; ObjectMapping *map;
GESTimelineObjectPrivate *priv = object->priv; GESTimelineObjectPrivate *priv;
guint32 layer_min_gnl_prio, layer_max_gnl_prio; guint32 layer_min_gnl_prio, layer_max_gnl_prio;
g_return_val_if_fail (GES_IS_TIMELINE_OBJECT (object), FALSE);
GST_DEBUG ("object:%p, priority:%" G_GUINT32_FORMAT, object, priority); GST_DEBUG ("object:%p, priority:%" G_GUINT32_FORMAT, object, priority);
priv = object->priv;
priv->ignore_notifies = TRUE; priv->ignore_notifies = TRUE;
object->priv->ignore_notifies = TRUE; object->priv->ignore_notifies = TRUE;
@ -909,6 +930,8 @@ void
ges_timeline_object_set_moving_from_layer (GESTimelineObject * object, ges_timeline_object_set_moving_from_layer (GESTimelineObject * object,
gboolean is_moving) gboolean is_moving)
{ {
g_return_if_fail (GES_IS_TRACK_OBJECT (object));
object->priv->is_moving = is_moving; object->priv->is_moving = is_moving;
} }
@ -945,7 +968,12 @@ ges_timeline_object_move_to_layer (GESTimelineObject * object, GESTimelineLayer
* layer) * layer)
{ {
gboolean ret; gboolean ret;
GESTimelineLayer *current_layer = object->priv->layer; GESTimelineLayer *current_layer;
g_return_val_if_fail (GES_IS_TIMELINE_OBJECT (object), FALSE);
g_return_val_if_fail (GES_IS_TIMELINE_LAYER (layer), FALSE);
current_layer = object->priv->layer;
if (current_layer == NULL) { if (current_layer == NULL) {
GST_DEBUG ("Not moving %p, only adding it to %p", object, layer); GST_DEBUG ("Not moving %p, only adding it to %p", object, layer);
@ -1125,6 +1153,8 @@ ges_timeline_object_get_top_effects (GESTimelineObject * object)
GList *tmp, *ret; GList *tmp, *ret;
guint i; guint i;
g_return_val_if_fail (GES_IS_TIMELINE_OBJECT (object), NULL);
ret = NULL; ret = NULL;
for (tmp = object->priv->trackobjects, i = 0; i < object->priv->nb_effects; for (tmp = object->priv->trackobjects, i = 0; i < object->priv->nb_effects;
@ -1151,6 +1181,8 @@ gint
ges_timeline_object_get_top_effect_position (GESTimelineObject * object, ges_timeline_object_get_top_effect_position (GESTimelineObject * object,
GESTrackEffect * effect) GESTrackEffect * effect)
{ {
g_return_val_if_fail (GES_IS_TIMELINE_OBJECT (object), -1);
return find_object_mapping (object, return find_object_mapping (object,
GES_TRACK_OBJECT (effect))->priority_offset; GES_TRACK_OBJECT (effect))->priority_offset;
} }
@ -1172,12 +1204,18 @@ gboolean
ges_timeline_object_set_top_effect_priority (GESTimelineObject * object, ges_timeline_object_set_top_effect_priority (GESTimelineObject * object,
GESTrackEffect * effect, guint newpriority) GESTrackEffect * effect, guint newpriority)
{ {
GList *tmp;
gint inc; gint inc;
GESTrackObject *tck_obj = GES_TRACK_OBJECT (effect); GList *tmp;
GESTimelineObjectPrivate *priv = object->priv; guint current_prio;
GESTrackObject *tck_obj;
GESTimelineObjectPrivate *priv;
g_return_val_if_fail (GES_IS_TIMELINE_OBJECT (object), FALSE);
tck_obj = GES_TRACK_OBJECT (effect);
priv = object->priv;
current_prio = ges_track_object_get_priority (tck_obj);
guint current_prio = ges_track_object_get_priority (tck_obj);
/* We don't change the priority */ /* We don't change the priority */
if (current_prio == newpriority || if (current_prio == newpriority ||
(G_UNLIKELY (ges_track_object_get_timeline_object (tck_obj) != object))) (G_UNLIKELY (ges_track_object_get_timeline_object (tck_obj) != object)))

View file

@ -211,68 +211,67 @@ struct _GESTimelineObjectClass {
gpointer _ges_reserved[GES_PADDING - 2]; gpointer _ges_reserved[GES_PADDING - 2];
}; };
GType ges_timeline_object_get_type (void); GType ges_timeline_object_get_type (void);
/* Setters */ /* Setters */
void ges_timeline_object_set_start (GESTimelineObject * object, void ges_timeline_object_set_start (GESTimelineObject * object,
guint64 start); guint64 start);
void ges_timeline_object_set_inpoint (GESTimelineObject * object, void ges_timeline_object_set_inpoint (GESTimelineObject * object,
guint64 inpoint); guint64 inpoint);
void ges_timeline_object_set_duration (GESTimelineObject * object, void ges_timeline_object_set_duration (GESTimelineObject * object,
guint64 duration); guint64 duration);
void ges_timeline_object_set_priority (GESTimelineObject * object, void ges_timeline_object_set_priority (GESTimelineObject * object,
guint priority); guint priority);
void ges_timeline_object_set_layer (GESTimelineObject * object, void ges_timeline_object_set_layer (GESTimelineObject * object,
GESTimelineLayer * layer); GESTimelineLayer * layer);
/* TrackObject handling */ /* TrackObject handling */
GESTrackObject * GESTrackObject *
ges_timeline_object_create_track_object (GESTimelineObject * object, ges_timeline_object_create_track_object (GESTimelineObject * object,
GESTrack * track); GESTrack * track);
gboolean gboolean
ges_timeline_object_create_track_objects (GESTimelineObject * object, ges_timeline_object_create_track_objects (GESTimelineObject * object,
GESTrack * track); GESTrack * track);
gboolean gboolean
ges_timeline_object_release_track_object (GESTimelineObject * object, ges_timeline_object_release_track_object (GESTimelineObject * object,
GESTrackObject * trackobject); GESTrackObject * trackobject);
gboolean gboolean
ges_timeline_object_fill_track_object (GESTimelineObject * object, ges_timeline_object_fill_track_object (GESTimelineObject * object,
GESTrackObject * trackobj, GESTrackObject * trackobj, GstElement * gnlobj);
GstElement * gnlobj);
GESTrackObject * GESTrackObject *
ges_timeline_object_find_track_object (GESTimelineObject * object, ges_timeline_object_find_track_object (GESTimelineObject * object,
GESTrack * track, GType type); GESTrack * track, GType type);
GList * GList *
ges_timeline_object_get_track_objects (GESTimelineObject *object); ges_timeline_object_get_track_objects (GESTimelineObject *object);
gboolean gboolean
ges_timeline_object_add_track_object (GESTimelineObject *object, ges_timeline_object_add_track_object (GESTimelineObject *object,
GESTrackObject *trobj); GESTrackObject *trobj);
/* Layer */ /* Layer */
GESTimelineLayer * GESTimelineLayer *
ges_timeline_object_get_layer (GESTimelineObject *object); ges_timeline_object_get_layer (GESTimelineObject *object);
gboolean gboolean
ges_timeline_object_move_to_layer (GESTimelineObject *object, ges_timeline_object_move_to_layer (GESTimelineObject *object,
GESTimelineLayer *layer); GESTimelineLayer *layer);
gboolean gboolean
ges_timeline_object_is_moving_from_layer (GESTimelineObject *object); ges_timeline_object_is_moving_from_layer (GESTimelineObject *object);
void void
ges_timeline_object_set_moving_from_layer (GESTimelineObject * object, ges_timeline_object_set_moving_from_layer (GESTimelineObject * object,
gboolean is_moving); gboolean is_moving);
/* Effects */ /* Effects */
GList * GList *
ges_timeline_object_get_top_effects (GESTimelineObject *object); ges_timeline_object_get_top_effects (GESTimelineObject *object);
gint gint
ges_timeline_object_get_top_effect_position (GESTimelineObject *object, ges_timeline_object_get_top_effect_position (GESTimelineObject *object,
@ -284,14 +283,14 @@ ges_timeline_object_set_top_effect_priority (GESTimelineObject *object,
guint newpriority); guint newpriority);
GESTrackType GESTrackType
ges_timeline_object_get_supported_formats (GESTimelineObject * self); ges_timeline_object_get_supported_formats (GESTimelineObject * object);
void void
ges_timeline_object_set_supported_formats (GESTimelineObject * self, ges_timeline_object_set_supported_formats (GESTimelineObject * object,
GESTrackType supportedformats); GESTrackType supportedformats);
GESTimelineObject * GESTimelineObject *
ges_timeline_object_split(GESTimelineObject * self, gint64 position); ges_timeline_object_split (GESTimelineObject * object, gint64 position);
void void
ges_timeline_object_objects_set_locked (GESTimelineObject * object, gboolean locked); ges_timeline_object_objects_set_locked (GESTimelineObject * object, gboolean locked);