Commit af0d087b authored by Sebastian Dröge's avatar Sebastian Dröge 🍵

basesrc: Fix automatic-eos=false mode if a segment.stop is given

If segment.stop was given, and the subclass provides a size that might be
smaller than segment.stop and also smaller than the actual size, we would
already stop there.

Instead try reading up to segment.stop, the goal is to ignore the (possibly
inaccurate) size the subclass gives and finish until segment.stop or when the
subclass tells us to stop.
parent 30ebde7b
......@@ -2363,21 +2363,26 @@ gst_base_src_update_length (GstBaseSrc * src, guint64 offset, guint * length,
if (!bclass->get_size (src, &size))
size = -1;
/* make sure we don't exceed the configured segment stop
* if it was set */
if (stop != -1)
maxsize = MIN (size, stop);
/* when not doing automatic EOS, just use the stop position. We don't use
* the size to check for EOS */
if (!g_atomic_int_get (&src->priv->automatic_eos))
maxsize = stop;
/* Otherwise, the max amount of bytes to read is the total
* size or up to the segment.stop if present. */
else if (stop != -1)
maxsize = size != -1 ? MIN (size, stop) : stop;
else
maxsize = size;
/* if we are at or past the end, EOS */
if (G_UNLIKELY (offset >= maxsize))
goto unexpected_length;
/* else we can clip to the end */
if (G_UNLIKELY (offset + *length >= maxsize))
*length = maxsize - offset;
if (maxsize != -1) {
/* if we are at or past the end, EOS */
if (G_UNLIKELY (offset >= maxsize))
goto unexpected_length;
/* else we can clip to the end */
if (G_UNLIKELY (offset + *length >= maxsize))
*length = maxsize - offset;
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment