From f1015883d0cba96dda55c93effadc881abe39caa Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Tue, 22 Jul 2003 21:33:02 +0000 Subject: [PATCH] Add support for not incrementing bytecounter while we're not at the end of the stream 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 | 6 ++++-- plugins/elements/gstfilesink.c | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/gst/elements/gstfilesink.c b/gst/elements/gstfilesink.c index c82ee1e..41fb456 100644 --- a/gst/elements/gstfilesink.c +++ b/gst/elements/gstfilesink.c @@ -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); diff --git a/plugins/elements/gstfilesink.c b/plugins/elements/gstfilesink.c index c82ee1e..41fb456 100644 --- a/plugins/elements/gstfilesink.c +++ b/plugins/elements/gstfilesink.c @@ -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); -- 2.7.4