mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-09-16 17:10:35 +00:00
baseaudiosrc: call parent alloc function
Call the parent alloc function to allocate buffers.
This commit is contained in:
parent
a7d88b0898
commit
86a10fbb9f
1 changed files with 13 additions and 3 deletions
|
@ -749,6 +749,7 @@ static GstFlowReturn
|
||||||
gst_base_audio_src_create (GstBaseSrc * bsrc, guint64 offset, guint length,
|
gst_base_audio_src_create (GstBaseSrc * bsrc, guint64 offset, guint length,
|
||||||
GstBuffer ** outbuf)
|
GstBuffer ** outbuf)
|
||||||
{
|
{
|
||||||
|
GstFlowReturn ret;
|
||||||
GstBaseAudioSrc *src = GST_BASE_AUDIO_SRC (bsrc);
|
GstBaseAudioSrc *src = GST_BASE_AUDIO_SRC (bsrc);
|
||||||
GstBuffer *buf;
|
GstBuffer *buf;
|
||||||
guchar *data, *ptr;
|
guchar *data, *ptr;
|
||||||
|
@ -789,13 +790,17 @@ gst_base_audio_src_create (GstBaseSrc * bsrc, guint64 offset, guint length,
|
||||||
sample = gst_base_audio_src_get_offset (src);
|
sample = gst_base_audio_src_get_offset (src);
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (src, "reading from sample %" G_GUINT64_FORMAT, sample);
|
GST_DEBUG_OBJECT (src, "reading from sample %" G_GUINT64_FORMAT " length %u",
|
||||||
|
sample, length);
|
||||||
|
|
||||||
/* get the number of samples to read */
|
/* get the number of samples to read */
|
||||||
total_samples = samples = length / bps;
|
total_samples = samples = length / bps;
|
||||||
|
|
||||||
/* FIXME, using a bufferpool would be nice here */
|
/* use the basesrc allocation code to use bufferpools or custom allocators */
|
||||||
buf = gst_buffer_new_and_alloc (length);
|
ret = GST_BASE_SRC_CLASS (parent_class)->alloc (bsrc, offset, length, &buf);
|
||||||
|
if (G_UNLIKELY (ret != GST_FLOW_OK))
|
||||||
|
goto alloc_failed;
|
||||||
|
|
||||||
data = ptr = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
|
data = ptr = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
|
||||||
do {
|
do {
|
||||||
read = gst_ring_buffer_read (ringbuffer, sample, ptr, samples);
|
read = gst_ring_buffer_read (ringbuffer, sample, ptr, samples);
|
||||||
|
@ -1025,6 +1030,11 @@ wrong_offset:
|
||||||
G_GUINT64_FORMAT " was given", offset));
|
G_GUINT64_FORMAT " was given", offset));
|
||||||
return GST_FLOW_ERROR;
|
return GST_FLOW_ERROR;
|
||||||
}
|
}
|
||||||
|
alloc_failed:
|
||||||
|
{
|
||||||
|
GST_DEBUG_OBJECT (src, "alloc failed: %s", gst_flow_get_name (ret));
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
stopped:
|
stopped:
|
||||||
{
|
{
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
|
|
Loading…
Reference in a new issue