gstfunnel: avoid access of freed pad
[platform/upstream/gstreamer.git] / gst / gstsegment.c
index 456bed5..0e5cc17 100644 (file)
  * normally be left to their default 0 value. The stop position is left to -1 unless
  * explicitly configured to a different value after a seek event.
  *
- * The current position in the segment should be set with the gst_segment_set_last_stop().
- * The public last_stop field contains the last set stop position in the segment.
+ * The current position in the segment should be set by changing the position
+ * member in the structure.
  *
  * For elements that perform seeks, the current segment should be updated with the
- * gst_segment_set_seek() and the values from the seek event. This method will update
- * all the segment fields. The last_stop field will contain the new playback position.
+ * gst_segment_do_seek() and the values from the seek event. This method will update
+ * all the segment fields. The position field will contain the new playback position.
  * If the cur_type was different from GST_SEEK_TYPE_NONE, playback continues from
- * the last_stop position, possibly with updated flags or rate.
+ * the position position, possibly with updated flags or rate.
  *
- * For elements that want to use #GstSegment to track the playback region, use
- * gst_segment_set_newsegment() to update the segment fields with the information from
- * the newsegment event. The gst_segment_clip() method can be used to check and clip
+ * For elements that want to use #GstSegment to track the playback region,
+ * update the segment fields with the information from the newsegment event.
+ * The gst_segment_clip() method can be used to check and clip
  * the media data to the segment boundaries.
  *
  * For elements that want to synchronize to the pipeline clock, gst_segment_to_running_time()
  * can be used to convert a timestamp to a value that can be used to synchronize
- * to the clock. This function takes into account all accumulated segments as well as
+ * to the clock. This function takes into account the base as well as
  * any rate or applied_rate conversions.
  *
  * For elements that need to perform operations on media data in stream_time,
  * gst_segment_to_stream_time() can be used to convert a timestamp and the segment
  * info to stream time (which is always between 0 and the duration of the stream).
  *
- * Last reviewed on 2007-05-17 (0.10.13)
+ * Last reviewed on 2012-03-29 (0.11.3)
  */
 
 /**
@@ -107,24 +107,21 @@ gst_segment_copy (const GstSegment * segment)
   return result;
 }
 
+/**
+ * gst_segment_copy_into:
+ * @src: (transfer none): a #GstSegment
+ * @dest: (transfer none): a #GstSegment
+ *
+ * Copy the contents of @src into @dest.
+ */
 void
 gst_segment_copy_into (const GstSegment * src, GstSegment * dest)
 {
   memcpy (dest, src, sizeof (GstSegment));
 }
 
-GType
-gst_segment_get_type (void)
-{
-  static GType gst_segment_type = 0;
-
-  if (G_UNLIKELY (gst_segment_type == 0)) {
-    gst_segment_type = g_boxed_type_register_static ("GstSegment",
-        (GBoxedCopyFunc) gst_segment_copy, (GBoxedFreeFunc) gst_segment_free);
-  }
-
-  return gst_segment_type;
-}
+G_DEFINE_BOXED_TYPE (GstSegment, gst_segment,
+    (GBoxedCopyFunc) gst_segment_copy, (GBoxedFreeFunc) gst_segment_free);
 
 /**
  * gst_segment_new:
@@ -175,7 +172,7 @@ gst_segment_init (GstSegment * segment, GstFormat format)
 {
   g_return_if_fail (segment != NULL);
 
-  segment->flags = GST_SEEK_FLAG_NONE;
+  segment->flags = GST_SEGMENT_FLAG_NONE;
   segment->rate = 1.0;
   segment->applied_rate = 1.0;
   segment->format = format;
@@ -265,16 +262,6 @@ gst_segment_do_seek (GstSegment * segment, gdouble rate,
       if (start == -1)
         start = 0;
       break;
-    case GST_SEEK_TYPE_CUR:
-    {
-      gint64 sstart = (gint64) start;
-      /* add start to currently configured segment */
-      if (sstart > 0 || segment->start > -sstart)
-        start = segment->start + start;
-      else
-        start = 0;
-      break;
-    }
     case GST_SEEK_TYPE_END:
       if (segment->duration != -1) {
         /* add start to total length */
@@ -301,16 +288,6 @@ gst_segment_do_seek (GstSegment * segment, gdouble rate,
     case GST_SEEK_TYPE_SET:
       /* stop holds required value */
       break;
-    case GST_SEEK_TYPE_CUR:
-      if (segment->stop != -1) {
-        gint64 sstop = (gint64) stop;
-        if (sstop > 0 || segment->stop > -sstop)
-          stop = segment->stop + stop;
-        else
-          stop = 0;
-      } else
-        stop = -1;
-      break;
     case GST_SEEK_TYPE_END:
       if (segment->duration != -1) {
         stop = segment->duration + stop;
@@ -592,9 +569,6 @@ gst_segment_clip (const GstSegment * segment, GstFormat format, guint64 start,
       *clip_stop = stop;
     else
       *clip_stop = MIN (stop, segment->stop);
-
-    if (segment->duration != -1 && *clip_stop != -1)
-      *clip_stop = MIN (*clip_stop, segment->duration);
   }
 
   return TRUE;