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.
This commit is contained in:
Sebastian Dröge 2008-10-23 12:52:58 +00:00
parent d2e5ffde24
commit 5357a24dbf
3 changed files with 24 additions and 4 deletions

View file

@ -1,3 +1,11 @@
2008-10-23 Sebastian Dröge <slomo@circular-chaos.org>
* 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 <wim.taymans@collabora.co.uk>
* gst/gstsegment.c: (gst_segment_set_newsegment_full):

View file

@ -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)
{

View file

@ -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)
{