mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-22 05:56:31 +00:00
gst/elements/gstfilesink.c: Simplify code so that we don't have to handle short writes and return GST_FLOW_ERROR if a...
Original commit message from CVS: * gst/elements/gstfilesink.c: (gst_filesink_render): Simplify code so that we don't have to handle short writes and return GST_FLOW_ERROR if an error occured.
This commit is contained in:
parent
3b6bf29c8c
commit
38565eafdb
3 changed files with 20 additions and 30 deletions
|
@ -1,3 +1,9 @@
|
|||
2005-06-29 Tim-Philipp Müller <tim at centricular dot net>
|
||||
|
||||
* gst/elements/gstfilesink.c: (gst_filesink_render):
|
||||
Simplify code so that we don't have to handle short
|
||||
writes and return GST_FLOW_ERROR if an error occured.
|
||||
|
||||
2005-06-29 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
|
||||
|
||||
* docs/gst/gstreamer-docs.sgml:
|
||||
|
|
|
@ -359,8 +359,7 @@ static GstFlowReturn
|
|||
gst_filesink_render (GstBaseSink * sink, GstBuffer * buffer)
|
||||
{
|
||||
GstFileSink *filesink;
|
||||
guint bytes_written = 0, back_pending = 0;
|
||||
guint size;
|
||||
guint size, back_pending = 0;
|
||||
|
||||
size = GST_BUFFER_SIZE (buffer);
|
||||
|
||||
|
@ -369,21 +368,14 @@ gst_filesink_render (GstBaseSink * sink, GstBuffer * buffer)
|
|||
if (ftell (filesink->file) < filesink->data_written)
|
||||
back_pending = filesink->data_written - ftell (filesink->file);
|
||||
|
||||
while (bytes_written < size) {
|
||||
size_t wrote = fwrite (GST_BUFFER_DATA (buffer) + bytes_written, 1,
|
||||
size - bytes_written, filesink->file);
|
||||
|
||||
if (wrote <= 0) {
|
||||
GST_ELEMENT_ERROR (filesink, RESOURCE, WRITE,
|
||||
(_("Error while writing to file \"%s\"."), filesink->filename),
|
||||
("Only %d of %d bytes written: %s",
|
||||
bytes_written, size, strerror (errno)));
|
||||
break;
|
||||
}
|
||||
bytes_written += wrote;
|
||||
if (fwrite (GST_BUFFER_DATA (buffer), size, 1, filesink->file) != 1) {
|
||||
GST_ELEMENT_ERROR (filesink, RESOURCE, WRITE,
|
||||
(_("Error while writing to file \"%s\"."), filesink->filename),
|
||||
("%s", g_strerror (errno)));
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
|
||||
filesink->data_written += bytes_written - back_pending;
|
||||
filesink->data_written += size - back_pending;
|
||||
|
||||
return GST_FLOW_OK;
|
||||
}
|
||||
|
|
|
@ -359,8 +359,7 @@ static GstFlowReturn
|
|||
gst_filesink_render (GstBaseSink * sink, GstBuffer * buffer)
|
||||
{
|
||||
GstFileSink *filesink;
|
||||
guint bytes_written = 0, back_pending = 0;
|
||||
guint size;
|
||||
guint size, back_pending = 0;
|
||||
|
||||
size = GST_BUFFER_SIZE (buffer);
|
||||
|
||||
|
@ -369,21 +368,14 @@ gst_filesink_render (GstBaseSink * sink, GstBuffer * buffer)
|
|||
if (ftell (filesink->file) < filesink->data_written)
|
||||
back_pending = filesink->data_written - ftell (filesink->file);
|
||||
|
||||
while (bytes_written < size) {
|
||||
size_t wrote = fwrite (GST_BUFFER_DATA (buffer) + bytes_written, 1,
|
||||
size - bytes_written, filesink->file);
|
||||
|
||||
if (wrote <= 0) {
|
||||
GST_ELEMENT_ERROR (filesink, RESOURCE, WRITE,
|
||||
(_("Error while writing to file \"%s\"."), filesink->filename),
|
||||
("Only %d of %d bytes written: %s",
|
||||
bytes_written, size, strerror (errno)));
|
||||
break;
|
||||
}
|
||||
bytes_written += wrote;
|
||||
if (fwrite (GST_BUFFER_DATA (buffer), size, 1, filesink->file) != 1) {
|
||||
GST_ELEMENT_ERROR (filesink, RESOURCE, WRITE,
|
||||
(_("Error while writing to file \"%s\"."), filesink->filename),
|
||||
("%s", g_strerror (errno)));
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
|
||||
filesink->data_written += bytes_written - back_pending;
|
||||
filesink->data_written += size - back_pending;
|
||||
|
||||
return GST_FLOW_OK;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue