From: Ronald S. Bultje Date: Sat, 7 Jun 2003 09:35:37 +0000 (+0000) Subject: Make filesink fail with some grace, see #114614 X-Git-Tag: BRANCH-ERROR-ROOT~163 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=63bc38c5193c0be505151747b59a06dc9f323c8f;p=platform%2Fupstream%2Fgstreamer.git Make filesink fail with some grace, see #114614 Original commit message from CVS: Make filesink fail with some grace, see #114614 --- diff --git a/gst/elements/gstfilesink.c b/gst/elements/gstfilesink.c index ce1832d..8adf9e6 100644 --- a/gst/elements/gstfilesink.c +++ b/gst/elements/gstfilesink.c @@ -365,7 +365,6 @@ static void gst_filesink_chain (GstPad *pad, GstBuffer *buf) { GstFileSink *filesink; - gint bytes_written = 0; g_return_if_fail (pad != NULL); g_return_if_fail (GST_IS_PAD (pad)); @@ -381,13 +380,21 @@ gst_filesink_chain (GstPad *pad, GstBuffer *buf) if (GST_FLAG_IS_SET (filesink, GST_FILESINK_OPEN)) { - bytes_written = fwrite (GST_BUFFER_DATA (buf), 1, - GST_BUFFER_SIZE (buf), filesink->file); - if (bytes_written < GST_BUFFER_SIZE (buf)) - { - g_warning ("filesink: %d bytes should be written, only %d bytes written\n", - GST_BUFFER_SIZE (buf), bytes_written); - } + size_t bytes_written = 0; + do { + size_t wrote = fwrite (GST_BUFFER_DATA (buf) + bytes_written, 1, + GST_BUFFER_SIZE (buf) - bytes_written, + filesink->file); + if (wrote <= 0) { + gst_element_error (GST_ELEMENT (filesink), + "Only %d of %d bytes written: %s", + bytes_written, GST_BUFFER_SIZE (buf), + strerror (errno)); + break; + } + bytes_written += wrote; + } while (bytes_written < GST_BUFFER_SIZE (buf)); + filesink->data_written += bytes_written; } diff --git a/plugins/elements/gstfilesink.c b/plugins/elements/gstfilesink.c index ce1832d..8adf9e6 100644 --- a/plugins/elements/gstfilesink.c +++ b/plugins/elements/gstfilesink.c @@ -365,7 +365,6 @@ static void gst_filesink_chain (GstPad *pad, GstBuffer *buf) { GstFileSink *filesink; - gint bytes_written = 0; g_return_if_fail (pad != NULL); g_return_if_fail (GST_IS_PAD (pad)); @@ -381,13 +380,21 @@ gst_filesink_chain (GstPad *pad, GstBuffer *buf) if (GST_FLAG_IS_SET (filesink, GST_FILESINK_OPEN)) { - bytes_written = fwrite (GST_BUFFER_DATA (buf), 1, - GST_BUFFER_SIZE (buf), filesink->file); - if (bytes_written < GST_BUFFER_SIZE (buf)) - { - g_warning ("filesink: %d bytes should be written, only %d bytes written\n", - GST_BUFFER_SIZE (buf), bytes_written); - } + size_t bytes_written = 0; + do { + size_t wrote = fwrite (GST_BUFFER_DATA (buf) + bytes_written, 1, + GST_BUFFER_SIZE (buf) - bytes_written, + filesink->file); + if (wrote <= 0) { + gst_element_error (GST_ELEMENT (filesink), + "Only %d of %d bytes written: %s", + bytes_written, GST_BUFFER_SIZE (buf), + strerror (errno)); + break; + } + bytes_written += wrote; + } while (bytes_written < GST_BUFFER_SIZE (buf)); + filesink->data_written += bytes_written; }