gnomevfssrc: Keep track of interruptions during read with a flag

This commit is contained in:
Sebastian Dröge 2011-05-26 10:31:11 +02:00
parent 847d274a5c
commit 99188bce77

View file

@ -612,6 +612,7 @@ gst_gnome_vfs_src_create (GstBaseSrc * basesrc, guint64 offset, guint size,
guint8 *data;
guint todo;
GstGnomeVFSSrc *src;
gboolean interrupted = FALSE;
src = GST_GNOME_VFS_SRC (basesrc);
@ -643,7 +644,9 @@ gst_gnome_vfs_src_create (GstBaseSrc * basesrc, guint64 offset, guint size,
todo = size;
while (!src->interrupted && todo > 0) {
/* this can return less that we ask for */
res = gnome_vfs_read_cancellable (src->handle, data, todo, &readbytes, src->context);
res =
gnome_vfs_read_cancellable (src->handle, data, todo, &readbytes,
src->context);
if (G_UNLIKELY (res == GNOME_VFS_ERROR_CANCELLED)) {
GST_DEBUG_OBJECT (src, "interrupted");
@ -652,6 +655,7 @@ gst_gnome_vfs_src_create (GstBaseSrc * basesrc, guint64 offset, guint size,
size = size - todo;
GST_BUFFER_SIZE (buf) = size;
todo = 0;
interrupted = TRUE;
break;
}
@ -671,8 +675,7 @@ gst_gnome_vfs_src_create (GstBaseSrc * basesrc, guint64 offset, guint size,
GST_LOG (" got size %" G_GUINT64_FORMAT, readbytes);
}
/* Handle interrupts implicitly, since the flag may have been cleared by now */
if (size == todo)
if (interrupted)
goto interrupted;
GST_BUFFER_OFFSET (buf) = src->curoffset;
@ -803,8 +806,7 @@ gst_gnome_vfs_src_unlock (GstBaseSrc * basesrc)
src = GST_GNOME_VFS_SRC (basesrc);
GST_DEBUG_OBJECT (src, "unlock()");
src->interrupted = TRUE;
if (src->context)
{
if (src->context) {
GnomeVFSCancellation *cancel =
gnome_vfs_context_get_cancellation (src->context);
if (cancel)