plugins/elements/gstfilesink.c: Be a bit smarter when seeking, like, don't try to...
authorWim Taymans <wim.taymans@gmail.com>
Tue, 27 Nov 2007 18:45:38 +0000 (18:45 +0000)
committerWim Taymans <wim.taymans@gmail.com>
Tue, 27 Nov 2007 18:45:38 +0000 (18:45 +0000)
Original commit message from CVS:
* plugins/elements/gstfilesink.c: (gst_file_sink_event):
Be a bit smarter when seeking, like, don't try to do a seek when it's
not needed. This avoids errors when the file is not seekable.
Fixes #499771.

ChangeLog
plugins/elements/gstfilesink.c

index 5ad9e4b..15b86ee 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2007-11-27  Wim Taymans  <wim.taymans@gmail.com>
+
+       * plugins/elements/gstfilesink.c: (gst_file_sink_event):
+       Be a bit smarter when seeking, like, don't try to do a seek when it's
+       not needed. This avoids errors when the file is not seekable.
+       Fixes #499771.
+
 2007-11-26  Stefan Kost  <ensonic@users.sf.net>
 
        * docs/gst/gstreamer-docs.sgml:
index 7d24822..9280657 100644 (file)
@@ -384,15 +384,22 @@ gst_file_sink_event (GstBaseSink * sink, GstEvent * event)
           &stop, &pos);
 
       if (format == GST_FORMAT_BYTES) {
-        /* FIXME, the seek should be performed on the pos field, start/stop are
-         * just boundaries for valid bytes offsets. We should also fill the file
-         * with zeroes if the new position extends the current EOF (sparse streams
-         * and segment accumulation). */
-        if (!gst_file_sink_do_seek (filesink, (guint64) start))
-          goto seek_failed;
+        /* only try to seek and fail when we are going to a different
+         * position */
+        if (filesink->current_pos != start) {
+          /* FIXME, the seek should be performed on the pos field, start/stop are
+           * just boundaries for valid bytes offsets. We should also fill the file
+           * with zeroes if the new position extends the current EOF (sparse streams
+           * and segment accumulation). */
+          if (!gst_file_sink_do_seek (filesink, (guint64) start))
+            goto seek_failed;
+        } else {
+          GST_DEBUG_OBJECT (filesink, "Ignored NEWSEGMENT, no seek needed");
+        }
       } else {
-        GST_DEBUG ("Ignored NEWSEGMENT event of format %u (%s)",
-            (guint) format, gst_format_get_name (format));
+        GST_DEBUG_OBJECT (filesink,
+            "Ignored NEWSEGMENT event of format %u (%s)", (guint) format,
+            gst_format_get_name (format));
       }
       break;
     }