audioresample: Clip input buffers to the segment before handling them

https://bugzilla.gnome.org/show_bug.cgi?id=757068
This commit is contained in:
Sebastian Dröge 2015-10-24 20:08:47 +03:00
parent 000c424835
commit e51c9a3dad

View file

@ -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)
{