+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):
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);
{
return GST_URI_SRC;
}
+
static gchar **
gst_fd_src_uri_get_protocols (void)
{
return protocols;
}
+
static const gchar *
gst_fd_src_uri_get_uri (GstURIHandler * handler)
{
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 *
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);
{
return GST_URI_SRC;
}
+
static gchar **
gst_file_src_uri_get_protocols (void)
{
return protocols;
}
+
static const gchar *
gst_file_src_uri_get_uri (GstURIHandler * handler)
{