summaryrefslogtreecommitdiff
path: root/gst
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian@centricular.com>2015-10-24 20:08:47 +0300
committerSebastian Dröge <sebastian@centricular.com>2015-11-02 10:20:37 +0200
commite51c9a3dad6a1349125ce45860a4d9633f9c7575 (patch)
tree06891b690c5f60ad38a45cd1cc1af77cab907ee4 /gst
parent000c424835b086339e8189ba06dc0629ec97ef36 (diff)
audioresample: Clip input buffers to the segment before handling them
https://bugzilla.gnome.org/show_bug.cgi?id=757068
Diffstat (limited to 'gst')
-rw-r--r--gst/audioresample/gstaudioresample.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/gst/audioresample/gstaudioresample.c b/gst/audioresample/gstaudioresample.c
index 30825a6aa..7155c3c3a 100644
--- a/gst/audioresample/gstaudioresample.c
+++ b/gst/audioresample/gstaudioresample.c
@@ -135,6 +135,8 @@ static GstFlowReturn gst_audio_resample_transform (GstBaseTransform * base,
GstBuffer * inbuf, GstBuffer * outbuf);
static gboolean gst_audio_resample_transform_meta (GstBaseTransform * trans,
GstBuffer * outbuf, GstMeta * meta, GstBuffer * inbuf);
+static GstFlowReturn gst_audio_resample_submit_input_buffer (GstBaseTransform *
+ base, gboolean is_discont, GstBuffer * input);
static gboolean gst_audio_resample_sink_event (GstBaseTransform * base,
GstEvent * event);
static gboolean gst_audio_resample_start (GstBaseTransform * base);
@@ -205,6 +207,8 @@ gst_audio_resample_class_init (GstAudioResampleClass * klass)
GST_DEBUG_FUNCPTR (gst_audio_resample_sink_event);
GST_BASE_TRANSFORM_CLASS (klass)->transform_meta =
GST_DEBUG_FUNCPTR (gst_audio_resample_transform_meta);
+ GST_BASE_TRANSFORM_CLASS (klass)->submit_input_buffer =
+ GST_DEBUG_FUNCPTR (gst_audio_resample_submit_input_buffer);
GST_BASE_TRANSFORM_CLASS (klass)->passthrough_on_same_caps = TRUE;
}
@@ -1267,6 +1271,25 @@ gst_audio_resample_transform_meta (GstBaseTransform * trans, GstBuffer * outbuf,
return FALSE;
}
+static GstFlowReturn
+gst_audio_resample_submit_input_buffer (GstBaseTransform * base,
+ gboolean is_discont, GstBuffer * input)
+{
+ GstAudioResample *resample = GST_AUDIO_RESAMPLE (base);
+
+ if (base->segment.format == GST_FORMAT_TIME) {
+ input =
+ gst_audio_buffer_clip (input, &base->segment, resample->inrate,
+ resample->channels * resample->width);
+
+ if (!input)
+ return GST_FLOW_OK;
+ }
+
+ return GST_BASE_TRANSFORM_CLASS (parent_class)->submit_input_buffer (base,
+ is_discont, input);
+}
+
static gboolean
gst_audio_resample_query (GstPad * pad, GstObject * parent, GstQuery * query)
{