From: Wim Taymans Date: Tue, 25 Oct 2005 10:15:45 +0000 (+0000) Subject: gst/base/gstbasesink.c: Don't use invalid stream_time. X-Git-Tag: RELEASE-0_9_5~97 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b204604572746e636ad9dba4272e8615a738b49a;p=platform%2Fupstream%2Fgstreamer.git gst/base/gstbasesink.c: Don't use invalid stream_time. Original commit message from CVS: * gst/base/gstbasesink.c: (gst_base_sink_get_position): Don't use invalid stream_time. * gst/gstevent.c: (gst_event_new_newsegment): stream_time in newsegment cannot be undefined. --- diff --git a/ChangeLog b/ChangeLog index 67ca270e9e..832d7b4efc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2005-10-25 Wim Taymans + + * gst/base/gstbasesink.c: (gst_base_sink_get_position): + Don't use invalid stream_time. + + * gst/gstevent.c: (gst_event_new_newsegment): + stream_time in newsegment cannot be undefined. + 2005-10-24 Wim Taymans * gst/gstbus.c: diff --git a/gst/base/gstbasesink.c b/gst/base/gstbasesink.c index ccbe5701d9..9d5345abcf 100644 --- a/gst/base/gstbasesink.c +++ b/gst/base/gstbasesink.c @@ -1406,6 +1406,7 @@ gst_base_sink_get_position (GstBaseSink * basesink, GstFormat format, GST_LOCK (basesink); if ((clock = GST_ELEMENT_CLOCK (basesink))) { GstClockTime now; + gint64 segment_time; gst_object_ref (clock); GST_UNLOCK (basesink); @@ -1413,14 +1414,17 @@ gst_base_sink_get_position (GstBaseSink * basesink, GstFormat format, now = gst_clock_get_time (clock); GST_LOCK (basesink); - *cur = - now - GST_ELEMENT_CAST (basesink)->base_time + - basesink->segment_time; + if (GST_CLOCK_TIME_IS_VALID (basesink->segment_time)) + segment_time = basesink->segment_time; + else + segment_time = 0; + + *cur = now - GST_ELEMENT_CAST (basesink)->base_time + segment_time; GST_DEBUG_OBJECT (basesink, "now %" GST_TIME_FORMAT " + segment_time %" GST_TIME_FORMAT " = %" GST_TIME_FORMAT, GST_TIME_ARGS (now), - GST_TIME_ARGS (basesink->segment_time), GST_TIME_ARGS (*cur)); + GST_TIME_ARGS (segment_time), GST_TIME_ARGS (*cur)); gst_object_unref (clock); diff --git a/gst/gstevent.c b/gst/gstevent.c index cefad04063..64c252aa90 100644 --- a/gst/gstevent.c +++ b/gst/gstevent.c @@ -398,8 +398,9 @@ gst_event_new_eos (void) * used intelligently by plugins to use more efficient methods of skipping * unneeded packets. * - * The stream time of the segment is also used to convert the buffer timestamps - * into the stream time again. + * The stream time of the segment is used to convert the buffer timestamps + * into the stream time again, this is usually done in sinks to report the + * current stream_time. @stream_time cannot be -1. * * The @start_value cannot be -1, the @stop_value can be -1. If there * is a valid @stop_value given, it must be greater or equal than @start_value. @@ -429,6 +430,9 @@ gst_event_new_newsegment (gboolean update, gdouble rate, GstFormat format, "start %lld, stop %lld, stream_time %lld", update, rate, format, start_value, stop_value, stream_time); } + if (stream_time == -1) + g_return_val_if_fail (stream_time != -1, NULL); + if (start_value == -1) g_return_val_if_fail (start_value != -1, NULL); diff --git a/libs/gst/base/gstbasesink.c b/libs/gst/base/gstbasesink.c index ccbe5701d9..9d5345abcf 100644 --- a/libs/gst/base/gstbasesink.c +++ b/libs/gst/base/gstbasesink.c @@ -1406,6 +1406,7 @@ gst_base_sink_get_position (GstBaseSink * basesink, GstFormat format, GST_LOCK (basesink); if ((clock = GST_ELEMENT_CLOCK (basesink))) { GstClockTime now; + gint64 segment_time; gst_object_ref (clock); GST_UNLOCK (basesink); @@ -1413,14 +1414,17 @@ gst_base_sink_get_position (GstBaseSink * basesink, GstFormat format, now = gst_clock_get_time (clock); GST_LOCK (basesink); - *cur = - now - GST_ELEMENT_CAST (basesink)->base_time + - basesink->segment_time; + if (GST_CLOCK_TIME_IS_VALID (basesink->segment_time)) + segment_time = basesink->segment_time; + else + segment_time = 0; + + *cur = now - GST_ELEMENT_CAST (basesink)->base_time + segment_time; GST_DEBUG_OBJECT (basesink, "now %" GST_TIME_FORMAT " + segment_time %" GST_TIME_FORMAT " = %" GST_TIME_FORMAT, GST_TIME_ARGS (now), - GST_TIME_ARGS (basesink->segment_time), GST_TIME_ARGS (*cur)); + GST_TIME_ARGS (segment_time), GST_TIME_ARGS (*cur)); gst_object_unref (clock);