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;
+ }
}
}