mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-28 11:10:37 +00:00
gst/gstpad.c: Move size sanity check to the right place: downstream may return a buffer with a smaller size if the bu...
Original commit message from CVS: * gst/gstpad.c: (gst_pad_alloc_buffer_full): Move size sanity check to the right place: downstream may return a buffer with a smaller size if the buffer caps are different than the requested ones, as may happen when doing reverse negotiation.
This commit is contained in:
parent
095ce0b2b3
commit
1d5691d033
2 changed files with 30 additions and 12 deletions
|
@ -1,3 +1,10 @@
|
|||
2008-05-21 Tim-Philipp Müller <tim.muller at collabora co uk>
|
||||
|
||||
* gst/gstpad.c: (gst_pad_alloc_buffer_full):
|
||||
Move size sanity check to the right place: downstream may return
|
||||
a buffer with a smaller size if the buffer caps are different than
|
||||
the requested ones, as may happen when doing reverse negotiation.
|
||||
|
||||
2008-05-21 Wim Taymans <wim.taymans@collabora.co.uk>
|
||||
|
||||
* plugins/elements/gstfilesink.c: (gst_file_sink_set_location),
|
||||
|
|
35
gst/gstpad.c
35
gst/gstpad.c
|
@ -2679,10 +2679,6 @@ gst_pad_buffer_alloc_unchecked (GstPad * pad, guint64 offset, gint size,
|
|||
if (G_UNLIKELY (*buf == NULL))
|
||||
goto fallback;
|
||||
|
||||
/* sanity check */
|
||||
if (G_UNLIKELY (GST_BUFFER_SIZE (*buf) < size))
|
||||
goto wrong_size;
|
||||
|
||||
/* If the buffer alloc function didn't set up the caps like it should,
|
||||
* do it for it */
|
||||
if (G_UNLIKELY (caps && (GST_BUFFER_CAPS (*buf) == NULL))) {
|
||||
|
@ -2705,14 +2701,6 @@ error:
|
|||
"alloc function returned error (%d) %s", ret, gst_flow_get_name (ret));
|
||||
return ret;
|
||||
}
|
||||
wrong_size:
|
||||
{
|
||||
GST_CAT_ERROR_OBJECT (GST_CAT_PADS, pad, "buffer returned by alloc "
|
||||
"function is too small: %u < %d", GST_BUFFER_SIZE (*buf), size);
|
||||
gst_buffer_unref (*buf);
|
||||
*buf = NULL;
|
||||
goto fallback;
|
||||
}
|
||||
fallback:
|
||||
{
|
||||
/* fallback case, allocate a buffer of our own, add pad caps. */
|
||||
|
@ -2781,7 +2769,12 @@ gst_pad_alloc_buffer_full (GstPad * pad, guint64 offset, gint size,
|
|||
GST_PAD_CAPS (pad), caps, caps);
|
||||
if (G_UNLIKELY (!gst_pad_configure_src (pad, caps, setcaps)))
|
||||
goto not_negotiated;
|
||||
} else {
|
||||
/* sanity check (only if caps haven't changed) */
|
||||
if (G_UNLIKELY (GST_BUFFER_SIZE (*buf) < size))
|
||||
goto wrong_size_fallback;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
flushed:
|
||||
|
@ -2812,6 +2805,24 @@ not_negotiated:
|
|||
"alloc function returned unacceptable buffer");
|
||||
return GST_FLOW_NOT_NEGOTIATED;
|
||||
}
|
||||
wrong_size_fallback:
|
||||
{
|
||||
GST_CAT_ERROR_OBJECT (GST_CAT_PADS, pad, "buffer returned by alloc "
|
||||
"function is too small (%u < %d), doing fallback buffer alloc",
|
||||
GST_BUFFER_SIZE (*buf), size);
|
||||
|
||||
gst_buffer_unref (*buf);
|
||||
|
||||
if ((*buf = gst_buffer_try_new_and_alloc (size))) {
|
||||
GST_BUFFER_OFFSET (*buf) = offset;
|
||||
gst_buffer_set_caps (*buf, caps);
|
||||
return GST_FLOW_OK;
|
||||
} else {
|
||||
GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad,
|
||||
"out of memory allocating %d bytes", size);
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue