From: Sebastian Dröge Date: Thu, 23 Oct 2008 12:52:58 +0000 (+0000) Subject: plugins/elements/: Use gst_buffer_try_new_and_alloc() and handle errors instead of... X-Git-Tag: GIT_CONVERSION~102 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5357a24dbfb1fadb7b63b3ea4f552a82c7f4bc6e;p=platform%2Fupstream%2Fgstreamer.git plugins/elements/: Use gst_buffer_try_new_and_alloc() and handle errors instead of using gst_buffer_new_and_alloc() w... Original commit message from CVS: * plugins/elements/gstfdsrc.c: (gst_fd_src_create): * plugins/elements/gstfilesrc.c: (gst_file_src_create_read): Use gst_buffer_try_new_and_alloc() and handle errors instead of using gst_buffer_new_and_alloc() which aborts if the buffer couldn't be allocated. --- diff --git a/ChangeLog b/ChangeLog index fc3423b..1af9cb9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2008-10-23 Sebastian Dröge + + * plugins/elements/gstfdsrc.c: (gst_fd_src_create): + * plugins/elements/gstfilesrc.c: (gst_file_src_create_read): + Use gst_buffer_try_new_and_alloc() and handle errors instead of + using gst_buffer_new_and_alloc() which aborts if the buffer couldn't + be allocated. + 2008-10-23 Wim Taymans * gst/gstsegment.c: (gst_segment_set_newsegment_full): diff --git a/plugins/elements/gstfdsrc.c b/plugins/elements/gstfdsrc.c index 4f6beb3..33fb5fd 100644 --- a/plugins/elements/gstfdsrc.c +++ b/plugins/elements/gstfdsrc.c @@ -432,7 +432,11 @@ gst_fd_src_create (GstPushSrc * psrc, GstBuffer ** outbuf) blocksize = GST_BASE_SRC (src)->blocksize; /* create the buffer */ - buf = gst_buffer_new_and_alloc (blocksize); + buf = gst_buffer_try_new_and_alloc (blocksize); + if (G_UNLIKELY (buf == NULL)) { + GST_ERROR_OBJECT (src, "Failed to allocate %u bytes", blocksize); + return GST_FLOW_ERROR; + } do { readbytes = read (src->fd, GST_BUFFER_DATA (buf), blocksize); @@ -556,6 +560,7 @@ gst_fd_src_uri_get_type (void) { return GST_URI_SRC; } + static gchar ** gst_fd_src_uri_get_protocols (void) { @@ -563,6 +568,7 @@ gst_fd_src_uri_get_protocols (void) return protocols; } + static const gchar * gst_fd_src_uri_get_uri (GstURIHandler * handler) { diff --git a/plugins/elements/gstfilesrc.c b/plugins/elements/gstfilesrc.c index cf3d5aa..f890fb9 100644 --- a/plugins/elements/gstfilesrc.c +++ b/plugins/elements/gstfilesrc.c @@ -565,8 +565,8 @@ gst_mmap_buffer_finalize (GstMmapBuffer * mmap_buffer) GST_LOG ("unmapped region %08lx+%08lx at %p", (gulong) offset, (gulong) size, data); - GST_MINI_OBJECT_CLASS (mmap_buffer_parent_class)-> - finalize (GST_MINI_OBJECT (mmap_buffer)); + GST_MINI_OBJECT_CLASS (mmap_buffer_parent_class)->finalize (GST_MINI_OBJECT + (mmap_buffer)); } static GstBuffer * @@ -822,7 +822,11 @@ gst_file_src_create_read (GstFileSrc * src, guint64 offset, guint length, src->read_position = offset; } - buf = gst_buffer_new_and_alloc (length); + buf = gst_buffer_try_new_and_alloc (length); + if (G_UNLIKELY (buf == NULL && length > 0)) { + GST_ERROR_OBJECT (src, "Failed to allocate %u bytes", length); + return GST_FLOW_ERROR; + } GST_LOG_OBJECT (src, "Reading %d bytes", length); ret = read (src->fd, GST_BUFFER_DATA (buf), length); @@ -1076,6 +1080,7 @@ gst_file_src_uri_get_type (void) { return GST_URI_SRC; } + static gchar ** gst_file_src_uri_get_protocols (void) { @@ -1083,6 +1088,7 @@ gst_file_src_uri_get_protocols (void) return protocols; } + static const gchar * gst_file_src_uri_get_uri (GstURIHandler * handler) {