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.
This commit is contained in:
Wim Taymans 2005-10-25 10:15:45 +00:00
parent 4a0802eb14
commit b204604572
4 changed files with 30 additions and 10 deletions

View file

@ -1,3 +1,11 @@
2005-10-25 Wim Taymans <wim@fluendo.com>
* 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 <wim@fluendo.com> 2005-10-24 Wim Taymans <wim@fluendo.com>
* gst/gstbus.c: * gst/gstbus.c:

View file

@ -1406,6 +1406,7 @@ gst_base_sink_get_position (GstBaseSink * basesink, GstFormat format,
GST_LOCK (basesink); GST_LOCK (basesink);
if ((clock = GST_ELEMENT_CLOCK (basesink))) { if ((clock = GST_ELEMENT_CLOCK (basesink))) {
GstClockTime now; GstClockTime now;
gint64 segment_time;
gst_object_ref (clock); gst_object_ref (clock);
GST_UNLOCK (basesink); GST_UNLOCK (basesink);
@ -1413,14 +1414,17 @@ gst_base_sink_get_position (GstBaseSink * basesink, GstFormat format,
now = gst_clock_get_time (clock); now = gst_clock_get_time (clock);
GST_LOCK (basesink); GST_LOCK (basesink);
*cur = if (GST_CLOCK_TIME_IS_VALID (basesink->segment_time))
now - GST_ELEMENT_CAST (basesink)->base_time + segment_time = basesink->segment_time;
basesink->segment_time; else
segment_time = 0;
*cur = now - GST_ELEMENT_CAST (basesink)->base_time + segment_time;
GST_DEBUG_OBJECT (basesink, GST_DEBUG_OBJECT (basesink,
"now %" GST_TIME_FORMAT " + segment_time %" GST_TIME_FORMAT " = %" "now %" GST_TIME_FORMAT " + segment_time %" GST_TIME_FORMAT " = %"
GST_TIME_FORMAT, GST_TIME_ARGS (now), 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); gst_object_unref (clock);

View file

@ -398,8 +398,9 @@ gst_event_new_eos (void)
* used intelligently by plugins to use more efficient methods of skipping * used intelligently by plugins to use more efficient methods of skipping
* unneeded packets. * unneeded packets.
* *
* The stream time of the segment is also used to convert the buffer timestamps * The stream time of the segment is used to convert the buffer timestamps
* into the stream time again. * 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 * 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. * 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", "start %lld, stop %lld, stream_time %lld",
update, rate, format, start_value, stop_value, stream_time); 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) if (start_value == -1)
g_return_val_if_fail (start_value != -1, NULL); g_return_val_if_fail (start_value != -1, NULL);

View file

@ -1406,6 +1406,7 @@ gst_base_sink_get_position (GstBaseSink * basesink, GstFormat format,
GST_LOCK (basesink); GST_LOCK (basesink);
if ((clock = GST_ELEMENT_CLOCK (basesink))) { if ((clock = GST_ELEMENT_CLOCK (basesink))) {
GstClockTime now; GstClockTime now;
gint64 segment_time;
gst_object_ref (clock); gst_object_ref (clock);
GST_UNLOCK (basesink); GST_UNLOCK (basesink);
@ -1413,14 +1414,17 @@ gst_base_sink_get_position (GstBaseSink * basesink, GstFormat format,
now = gst_clock_get_time (clock); now = gst_clock_get_time (clock);
GST_LOCK (basesink); GST_LOCK (basesink);
*cur = if (GST_CLOCK_TIME_IS_VALID (basesink->segment_time))
now - GST_ELEMENT_CAST (basesink)->base_time + segment_time = basesink->segment_time;
basesink->segment_time; else
segment_time = 0;
*cur = now - GST_ELEMENT_CAST (basesink)->base_time + segment_time;
GST_DEBUG_OBJECT (basesink, GST_DEBUG_OBJECT (basesink,
"now %" GST_TIME_FORMAT " + segment_time %" GST_TIME_FORMAT " = %" "now %" GST_TIME_FORMAT " + segment_time %" GST_TIME_FORMAT " = %"
GST_TIME_FORMAT, GST_TIME_ARGS (now), 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); gst_object_unref (clock);