Add support for not incrementing bytecounter while we're not at the end of the stream
authorRonald S. Bultje <rbultje@ronald.bitfreak.net>
Tue, 22 Jul 2003 21:33:02 +0000 (21:33 +0000)
committerRonald S. Bultje <rbultje@ronald.bitfreak.net>
Tue, 22 Jul 2003 21:33:02 +0000 (21:33 +0000)
Original commit message from CVS:
Add support for not incrementing bytecounter while we're not at the end of the stream

gst/elements/gstfilesink.c
plugins/elements/gstfilesink.c

index c82ee1e..41fb456 100644 (file)
@@ -387,7 +387,9 @@ gst_filesink_chain (GstPad *pad, GstBuffer *buf)
 
   if (GST_FLAG_IS_SET (filesink, GST_FILESINK_OPEN))
   {
-    guint bytes_written = 0;
+    guint bytes_written = 0, back_pending = 0;
+    if (ftell(filesink->file) < filesink->data_written)
+      back_pending = filesink->data_written - ftell(filesink->file);
     do {
       size_t wrote = fwrite (GST_BUFFER_DATA (buf) + bytes_written, 1,
                             GST_BUFFER_SIZE (buf) - bytes_written,
@@ -402,7 +404,7 @@ gst_filesink_chain (GstPad *pad, GstBuffer *buf)
       bytes_written += wrote;
     } while (bytes_written < GST_BUFFER_SIZE (buf));
 
-    filesink->data_written += bytes_written;
+    filesink->data_written += bytes_written - back_pending;
   }
 
   gst_buffer_unref (buf);
index c82ee1e..41fb456 100644 (file)
@@ -387,7 +387,9 @@ gst_filesink_chain (GstPad *pad, GstBuffer *buf)
 
   if (GST_FLAG_IS_SET (filesink, GST_FILESINK_OPEN))
   {
-    guint bytes_written = 0;
+    guint bytes_written = 0, back_pending = 0;
+    if (ftell(filesink->file) < filesink->data_written)
+      back_pending = filesink->data_written - ftell(filesink->file);
     do {
       size_t wrote = fwrite (GST_BUFFER_DATA (buf) + bytes_written, 1,
                             GST_BUFFER_SIZE (buf) - bytes_written,
@@ -402,7 +404,7 @@ gst_filesink_chain (GstPad *pad, GstBuffer *buf)
       bytes_written += wrote;
     } while (bytes_written < GST_BUFFER_SIZE (buf));
 
-    filesink->data_written += bytes_written;
+    filesink->data_written += bytes_written - back_pending;
   }
 
   gst_buffer_unref (buf);