[gvfs] afc: Fix GStreamer playback of native files



commit d65e2d2454411f51a1b5463ddae97c1adafc4250
Author: Bastien Nocera <hadess hadess net>
Date:   Wed Jun 8 17:35:52 2016 +0200

    afc: Fix GStreamer playback of native files
    
    GStreamer gets very confused when the offset after a seek isn't what it
    expected, and told us that the "Stream contains no data." when trying to
    play back using giosrc.
    
    But we could play the video just fine going through fuse.
    
    FUSE hides bugs with relative seeks, such as our absolute offset being
    wrong when doing absolute seeks. To make sure that the offset we return
    is correct, call tell() and use that as the new offset.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=767405

 daemon/gvfsbackendafc.c |   27 +++++++++++++++++----------
 1 files changed, 17 insertions(+), 10 deletions(-)
---
diff --git a/daemon/gvfsbackendafc.c b/daemon/gvfsbackendafc.c
index 3da3caf..7d51ce4 100644
--- a/daemon/gvfsbackendafc.c
+++ b/daemon/gvfsbackendafc.c
@@ -1458,7 +1458,7 @@ g_vfs_backend_afc_write (GVfsBackend *backend,
   g_vfs_job_succeeded (G_VFS_JOB(job));
 }
 
-static int
+static goffset
 g_vfs_backend_afc_seek (GVfsBackendAfc *self,
                         GVfsJob *job,
                         GVfsBackendHandle handle,
@@ -1467,12 +1467,13 @@ g_vfs_backend_afc_seek (GVfsBackendAfc *self,
 {
   int afc_seek_type;
   FileHandle *fh;
+  guint64 new_offset;
 
   if ((afc_seek_type = gvfs_seek_type_to_lseek (type)) == -1)
     {
       g_vfs_job_failed(job, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
                        _("Unsupported seek type"));
-      return 1;
+      return -1;
     }
 
   fh = (FileHandle *) handle;
@@ -1480,11 +1481,13 @@ g_vfs_backend_afc_seek (GVfsBackendAfc *self,
   if (G_UNLIKELY(g_vfs_backend_afc_check (afc_file_seek (fh->afc_cli,
                                                          fh->fd, offset, afc_seek_type),
                                           job)))
-    {
-      return 1;
-    }
+      return -1;
+
+  if (G_UNLIKELY(g_vfs_backend_afc_check (afc_file_tell (fh->afc_cli, fh->fd, &new_offset),
+                                          job)))
+      return -1;
 
-  return 0;
+  return new_offset;
 }
 
 static void
@@ -1495,15 +1498,17 @@ g_vfs_backend_afc_seek_on_read (GVfsBackend *backend,
                                 GSeekType type)
 {
   GVfsBackendAfc *self;
+  goffset new_offset;
 
   g_return_if_fail (handle != NULL);
 
   self = G_VFS_BACKEND_AFC(backend);
   g_return_if_fail (self->connected);
 
-  if (!g_vfs_backend_afc_seek (self, G_VFS_JOB(job), handle, offset, type))
+  new_offset = g_vfs_backend_afc_seek (self, G_VFS_JOB(job), handle, offset, type);
+  if (new_offset >= 0)
     {
-      g_vfs_job_seek_read_set_offset (job, offset);
+      g_vfs_job_seek_read_set_offset (job, new_offset);
       g_vfs_job_succeeded (G_VFS_JOB(job));
     }
 }
@@ -1516,15 +1521,17 @@ g_vfs_backend_afc_seek_on_write (GVfsBackend *backend,
                                  GSeekType type)
 {
   GVfsBackendAfc *self;
+  goffset new_offset;
 
   g_return_if_fail (handle != NULL);
 
   self = G_VFS_BACKEND_AFC(backend);
   g_return_if_fail (self->connected);
 
-  if (!g_vfs_backend_afc_seek (self, G_VFS_JOB(job), handle, offset, type))
+  new_offset = g_vfs_backend_afc_seek (self, G_VFS_JOB(job), handle, offset, type);
+  if (new_offset >= 0)
     {
-      g_vfs_job_seek_write_set_offset (job, offset);
+      g_vfs_job_seek_write_set_offset (job, new_offset);
       g_vfs_job_succeeded (G_VFS_JOB(job));
     }
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]