summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e96efca)
raw | patch | inline | side by side (parent: e96efca)
author | Vincent Penquerc'h <vincent.penquerch@collabora.co.uk> | |
Mon, 12 Dec 2011 13:05:36 +0000 (13:05 +0000) | ||
committer | Tim-Philipp Müller <tim.muller@collabora.co.uk> | |
Fri, 16 Dec 2011 11:39:57 +0000 (11:39 +0000) |
While local filesystems will usually not cause short reads,
this may happen on seekable files on some remote filesystems.
Instead, loop till we get the requested amount of data, or
an actual EOS (ie, 0 bytes).
https://bugzilla.gnome.org/show_bug.cgi?id=665921
this may happen on seekable files on some remote filesystems.
Instead, loop till we get the requested amount of data, or
an actual EOS (ie, 0 bytes).
https://bugzilla.gnome.org/show_bug.cgi?id=665921
plugins/elements/gstfilesrc.c | patch | blob | history |
index f8dbfe2c4c0805111514748d3f1020041dd83ba7..d2b88c63293477dde93021cb92539f3e1966a4ce 100644 (file)
{
int ret;
GstBuffer *buf;
+ guint64 woffset;
if (G_UNLIKELY (src->read_position != offset)) {
off_t res;
}
/* No need to read anything if length is 0 */
- if (length > 0) {
+ GST_BUFFER_SIZE (buf) = 0;
+ GST_BUFFER_OFFSET (buf) = offset;
+ GST_BUFFER_OFFSET_END (buf) = offset;
+ woffset = 0;
+ while (length > 0) {
GST_LOG_OBJECT (src, "Reading %d bytes at offset 0x%" G_GINT64_MODIFIER "x",
- length, offset);
- ret = read (src->fd, GST_BUFFER_DATA (buf), length);
- if (G_UNLIKELY (ret < 0))
+ length, offset + woffset);
+ errno = 0;
+ ret = read (src->fd, GST_BUFFER_DATA (buf) + woffset, length);
+ if (G_UNLIKELY (ret < 0)) {
+ if (errno == EAGAIN || errno == EINTR)
+ continue;
goto could_not_read;
+ }
- /* seekable regular files should have given us what we expected */
- if (G_UNLIKELY ((guint) ret < length && src->seekable))
- goto unexpected_eos;
-
- /* other files should eos if they read 0 and more was requested */
- if (G_UNLIKELY (ret == 0 && length > 0))
+ /* files should eos if they read 0 and more was requested */
+ if (G_UNLIKELY (ret == 0))
goto eos;
- length = ret;
- GST_BUFFER_SIZE (buf) = length;
- GST_BUFFER_OFFSET (buf) = offset;
- GST_BUFFER_OFFSET_END (buf) = offset + length;
+ length -= ret;
+ woffset += ret;
+ GST_BUFFER_SIZE (buf) += ret;
+ GST_BUFFER_OFFSET_END (buf) += ret;
- src->read_position += length;
+ src->read_position += ret;
}
*buffer = buf;
gst_buffer_unref (buf);
return GST_FLOW_ERROR;
}
-unexpected_eos:
- {
- GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL),
- ("unexpected end of file."));
- gst_buffer_unref (buf);
- return GST_FLOW_ERROR;
- }
eos:
{
- GST_DEBUG ("non-regular file hits EOS");
+ GST_DEBUG ("EOS");
gst_buffer_unref (buf);
return GST_FLOW_UNEXPECTED;
}