From 48e7814631d65ca82034f7cc633ab35f3adeaa00 Mon Sep 17 00:00:00 2001 From: Stefan Kost Date: Tue, 29 Jul 2008 12:35:54 +0000 Subject: [PATCH] ext/gnomevfs/gstgnomevfssrc.c: Aggregate short reads and add some comments and debug logging. Original commit message from CVS: * ext/gnomevfs/gstgnomevfssrc.c: Aggregate short reads and add some comments and debug logging. Fixes #537380 --- ChangeLog | 6 +++++ ext/gnomevfs/gstgnomevfssrc.c | 47 ++++++++++++++++++++++++----------- 2 files changed, 39 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index a180b939a5..3b0f172af3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-07-29 Stefan Kost + + * ext/gnomevfs/gstgnomevfssrc.c: + Aggregate short reads and add some comments and debug logging. + Fixes #537380 + 2008-07-29 Stefan Kost * gst/playback/gstplaybasebin.c: diff --git a/ext/gnomevfs/gstgnomevfssrc.c b/ext/gnomevfs/gstgnomevfssrc.c index 84c436400e..beb323d71d 100644 --- a/ext/gnomevfs/gstgnomevfssrc.c +++ b/ext/gnomevfs/gstgnomevfssrc.c @@ -497,6 +497,13 @@ gst_gnome_vfs_src_received_headers_callback (gconstpointer in, if (!src->iradio_mode) return; + GST_DEBUG_OBJECT (src, "receiving internet radio metadata\n"); + + /* FIXME: Could we use "Accept-Ranges: bytes" + * http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.5 + * to enable pull-mode? + */ + for (i = in_args->headers; i; i = i->next) { char *data = (char *) i->data; char *key = data; @@ -510,6 +517,8 @@ gst_gnome_vfs_src_received_headers_callback (gconstpointer in, if (!strlen (value)) continue; + GST_LOG_OBJECT (src, "data %s", data); + /* Icecast stuff */ if (strncmp (data, "icy-metaint:", 12) == 0) { /* ugh */ if (sscanf (data + 12, "%d", &icy_metaint) == 1) { @@ -594,6 +603,7 @@ gst_gnome_vfs_src_create (GstBaseSrc * basesrc, guint64 offset, guint size, GstBuffer *buf; GnomeVFSFileSize readbytes; guint8 *data; + guint todo; GstGnomeVFSSrc *src; src = GST_GNOME_VFS_SRC (basesrc); @@ -605,7 +615,7 @@ gst_gnome_vfs_src_create (GstBaseSrc * basesrc, guint64 offset, guint size, if (G_UNLIKELY (src->curoffset != offset)) { GST_DEBUG ("need to seek"); if (src->seekable) { - GST_DEBUG ("seeking to %lld", offset); + GST_DEBUG ("seeking to %" G_GUINT64_FORMAT, offset); res = gnome_vfs_seek (src->handle, GNOME_VFS_SEEK_START, offset); if (res != GNOME_VFS_OK) goto seek_failed; @@ -618,20 +628,29 @@ gst_gnome_vfs_src_create (GstBaseSrc * basesrc, guint64 offset, guint size, buf = gst_buffer_new_and_alloc (size); data = GST_BUFFER_DATA (buf); + + todo = size; + while (todo > 0) { + /* this can return less that we ask for */ + res = gnome_vfs_read (src->handle, data, todo, &readbytes); + + if (G_UNLIKELY (res == GNOME_VFS_ERROR_EOF || (res == GNOME_VFS_OK + && readbytes == 0))) + goto eos; + + if (G_UNLIKELY (res != GNOME_VFS_OK)) + goto read_failed; + + if (readbytes < todo) { + data = &data[readbytes]; + todo -= readbytes; + } else { + todo = 0; + } + GST_LOG (" got size %" G_GUINT64_FORMAT, readbytes); + } GST_BUFFER_OFFSET (buf) = src->curoffset; - - res = gnome_vfs_read (src->handle, data, size, &readbytes); - - if (G_UNLIKELY (res == GNOME_VFS_ERROR_EOF || (res == GNOME_VFS_OK - && readbytes == 0))) - goto eos; - - GST_BUFFER_SIZE (buf) = readbytes; - - if (G_UNLIKELY (res != GNOME_VFS_OK)) - goto read_failed; - - src->curoffset += readbytes; + src->curoffset += size; /* we're done, return the buffer */ *buffer = buf;