realmedia: do not use the pad buffer allocation functions in demuxers

Doing so can block, see https://bugzilla.gnome.org/show_bug.cgi?id=637822

https://bugzilla.gnome.org/show_bug.cgi?id=637932
This commit is contained in:
Vincent Penquerc'h 2010-12-24 10:12:19 +00:00 committed by Sebastian Dröge
parent 78f8adc593
commit 878781c6a7
2 changed files with 9 additions and 38 deletions

View file

@ -506,13 +506,8 @@ gst_real_audio_demux_parse_data (GstRealAudioDemux * demux)
const guint8 *data; const guint8 *data;
GstBuffer *buf = NULL; GstBuffer *buf = NULL;
ret = gst_pad_alloc_buffer_and_set_caps (demux->srcpad, buf = gst_buffer_new_and_alloc (unit_size);
GST_BUFFER_OFFSET_NONE, unit_size, GST_PAD_CAPS (demux->srcpad), &buf); gst_buffer_set_caps (buf, GST_PAD_CAPS (demux->srcpad));
if (ret != GST_FLOW_OK) {
GST_DEBUG_OBJECT (demux, "pad_alloc flow: %s", gst_flow_get_name (ret));
break;
}
data = gst_adapter_peek (demux->adapter, unit_size); data = gst_adapter_peek (demux->adapter, unit_size);
memcpy (GST_BUFFER_DATA (buf), data, unit_size); memcpy (GST_BUFFER_DATA (buf), data, unit_size);

View file

@ -1930,12 +1930,8 @@ gst_rmdemux_descramble_audio (GstRMDemux * rmdemux, GstRMDemuxStream * stream)
GST_LOG ("packet_size = %u, leaf_size = %u, height= %u", packet_size, GST_LOG ("packet_size = %u, leaf_size = %u, height= %u", packet_size,
leaf_size, height); leaf_size, height);
ret = gst_pad_alloc_buffer_and_set_caps (stream->pad, outbuf = gst_buffer_new_and_alloc (height * packet_size);
GST_BUFFER_OFFSET_NONE, height * packet_size, gst_buffer_set_caps (outbuf, GST_PAD_CAPS (stream->pad));
GST_PAD_CAPS (stream->pad), &outbuf);
if (ret != GST_FLOW_OK)
goto done;
for (p = 0; p < height; ++p) { for (p = 0; p < height; ++p) {
GstBuffer *b = g_ptr_array_index (stream->subpackets, p); GstBuffer *b = g_ptr_array_index (stream->subpackets, p);
@ -1976,8 +1972,6 @@ gst_rmdemux_descramble_audio (GstRMDemux * rmdemux, GstRMDemuxStream * stream)
gst_buffer_unref (outbuf); gst_buffer_unref (outbuf);
done:
gst_rmdemux_stream_clear_cached_subpackets (rmdemux, stream); gst_rmdemux_stream_clear_cached_subpackets (rmdemux, stream);
return ret; return ret;
@ -2061,12 +2055,8 @@ gst_rmdemux_descramble_sipr_audio (GstRMDemux * rmdemux,
GST_LOG ("packet_size = %u, leaf_size = %u, height= %u", packet_size, GST_LOG ("packet_size = %u, leaf_size = %u, height= %u", packet_size,
stream->leaf_size, height); stream->leaf_size, height);
ret = gst_pad_alloc_buffer_and_set_caps (stream->pad, outbuf = gst_buffer_new_and_alloc (height * packet_size);
GST_BUFFER_OFFSET_NONE, height * packet_size, gst_buffer_set_caps (outbuf, GST_PAD_CAPS (stream->pad));
GST_PAD_CAPS (stream->pad), &outbuf);
if (ret != GST_FLOW_OK)
goto done;
for (p = 0; p < height; ++p) { for (p = 0; p < height; ++p) {
GstBuffer *b = g_ptr_array_index (stream->subpackets, p); GstBuffer *b = g_ptr_array_index (stream->subpackets, p);
@ -2091,8 +2081,6 @@ gst_rmdemux_descramble_sipr_audio (GstRMDemux * rmdemux,
gst_buffer_set_caps (outbuf, GST_PAD_CAPS (stream->pad)); gst_buffer_set_caps (outbuf, GST_PAD_CAPS (stream->pad));
ret = gst_pad_push (stream->pad, outbuf); ret = gst_pad_push (stream->pad, outbuf);
done:
gst_rmdemux_stream_clear_cached_subpackets (rmdemux, stream); gst_rmdemux_stream_clear_cached_subpackets (rmdemux, stream);
return ret; return ret;
@ -2505,7 +2493,7 @@ gst_rmdemux_parse_audio_packet (GstRMDemux * rmdemux, GstRMDemuxStream * stream,
GstBuffer * in, guint offset, guint16 version, GstBuffer * in, guint offset, guint16 version,
GstClockTime timestamp, gboolean key) GstClockTime timestamp, gboolean key)
{ {
GstFlowReturn ret, cret; GstFlowReturn ret;
GstBuffer *buffer; GstBuffer *buffer;
const guint8 *data; const guint8 *data;
guint size; guint size;
@ -2513,12 +2501,8 @@ gst_rmdemux_parse_audio_packet (GstRMDemux * rmdemux, GstRMDemuxStream * stream,
data = GST_BUFFER_DATA (in) + offset; data = GST_BUFFER_DATA (in) + offset;
size = GST_BUFFER_SIZE (in) - offset; size = GST_BUFFER_SIZE (in) - offset;
ret = gst_pad_alloc_buffer_and_set_caps (stream->pad, buffer = gst_buffer_new_and_alloc (size);
GST_BUFFER_OFFSET_NONE, size, GST_PAD_CAPS (stream->pad), &buffer); gst_buffer_set_caps (buffer, GST_PAD_CAPS (stream->pad));
cret = gst_rmdemux_combine_flows (rmdemux, stream, ret);
if (ret != GST_FLOW_OK)
goto alloc_failed;
memcpy (GST_BUFFER_DATA (buffer), (guint8 *) data, size); memcpy (GST_BUFFER_DATA (buffer), (guint8 *) data, size);
@ -2552,14 +2536,6 @@ gst_rmdemux_parse_audio_packet (GstRMDemux * rmdemux, GstRMDemuxStream * stream,
gst_buffer_unref (in); gst_buffer_unref (in);
return ret; return ret;
/* ERRORS */
alloc_failed:
{
GST_DEBUG_OBJECT (rmdemux, "pad alloc returned %d", ret);
gst_buffer_unref (in);
return cret;
}
} }
static GstFlowReturn static GstFlowReturn