From: Sebastian Dröge Date: Sat, 24 Oct 2015 17:08:47 +0000 (+0300) Subject: audioresample: Clip input buffers to the segment before handling them X-Git-Tag: 1.19.3~511^2~3257 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e51c9a3dad6a1349125ce45860a4d9633f9c7575;p=platform%2Fupstream%2Fgstreamer.git audioresample: Clip input buffers to the segment before handling them https://bugzilla.gnome.org/show_bug.cgi?id=757068 --- diff --git a/gst/audioresample/gstaudioresample.c b/gst/audioresample/gstaudioresample.c index 30825a6..7155c3c 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) {