From 22482e1bbd4036c8211def9977beeae807bd2913 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim-Philipp=20M=C3=BCller?= Date: Sat, 11 Mar 2006 13:02:28 +0000 Subject: [PATCH] plugins/elements/: Emit RESOURCE_NO_SPACE_LEFT error here as well when there's no space left on the device. Original commit message from CVS: * plugins/elements/gstfdsink.c: (gst_fd_sink_render): * plugins/elements/gstfilesink.c: (gst_file_sink_render): Emit RESOURCE_NO_SPACE_LEFT error here as well when there's no space left on the device. --- ChangeLog | 7 +++++++ plugins/elements/gstfdsink.c | 25 +++++++++++++++++++------ plugins/elements/gstfilesink.c | 20 ++++++++++++++------ 3 files changed, 40 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9f8b492..a4dc897 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2006-03-11 Tim-Philipp Müller + + * plugins/elements/gstfdsink.c: (gst_fd_sink_render): + * plugins/elements/gstfilesink.c: (gst_file_sink_render): + Emit RESOURCE_NO_SPACE_LEFT error here as well when + there's no space left on the device. + 2006-03-10 Tim-Philipp Müller * gst/gstclock.h: diff --git a/plugins/elements/gstfdsink.c b/plugins/elements/gstfdsink.c index 8113ca3..f04490c 100644 --- a/plugins/elements/gstfdsink.c +++ b/plugins/elements/gstfdsink.c @@ -278,15 +278,13 @@ gst_fd_sink_render (GstBaseSink * sink, GstBuffer * buffer) GST_DEBUG ("writing %d bytes to file descriptor %d", GST_BUFFER_SIZE (buffer), fdsink->fd); + /* FIXME: short writes are perfectly valid and may happen; also, + * we should probably handle EINTR and EAGAIN in a non-fatal way */ bytes_written = write (fdsink->fd, GST_BUFFER_DATA (buffer), GST_BUFFER_SIZE (buffer)); fdsink->bytes_written += bytes_written; - if (bytes_written != GST_BUFFER_SIZE (buffer)) { - GST_ELEMENT_ERROR (fdsink, RESOURCE, WRITE, - (_("Error while writing to file descriptor \"%d\"."), fdsink->fd), - ("%s", g_strerror (errno))); - return GST_FLOW_ERROR; - } + if (bytes_written != GST_BUFFER_SIZE (buffer)) + goto write_error; } return GST_FLOW_OK; @@ -305,6 +303,21 @@ stopped: return GST_FLOW_WRONG_STATE; } #endif + +write_error: + { + switch (errno) { + case ENOSPC: + GST_ELEMENT_ERROR (fdsink, RESOURCE, NO_SPACE_LEFT, (NULL), (NULL)); + break; + default:{ + GST_ELEMENT_ERROR (fdsink, RESOURCE, WRITE, + (_("Error while writing to file descriptor \"%d\"."), fdsink->fd), + ("%s", g_strerror (errno))); + } + } + return GST_FLOW_ERROR; + } } static gboolean diff --git a/plugins/elements/gstfilesink.c b/plugins/elements/gstfilesink.c index 6e55489..1cf513f 100644 --- a/plugins/elements/gstfilesink.c +++ b/plugins/elements/gstfilesink.c @@ -420,12 +420,20 @@ gst_file_sink_render (GstBaseSink * sink, GstBuffer * buffer) return GST_FLOW_OK; handle_error: - - GST_ELEMENT_ERROR (filesink, RESOURCE, WRITE, - (_("Error while writing to file \"%s\"."), filesink->filename), - ("%s", g_strerror (errno))); - - return GST_FLOW_ERROR; + { + switch (errno) { + case ENOSPC:{ + GST_ELEMENT_ERROR (filesink, RESOURCE, NO_SPACE_LEFT, (NULL), (NULL)); + break; + } + default:{ + GST_ELEMENT_ERROR (filesink, RESOURCE, WRITE, + (_("Error while writing to file \"%s\"."), filesink->filename), + ("%s", g_strerror (errno))); + } + } + return GST_FLOW_ERROR; + } } static gboolean -- 2.7.4