audioconvert, audioresample, audiofilter: fix divide by 0 for input buffer without caps

gst-launch-1.0 audiotestsrc ! udpsink host=127.0.0.1
gst-launch-1.0 udpsrc ! audioconvert ! autoaudiosink

would crash with a floating point exception when clipping the input
buffer owing to a division by zero because no caps event was received.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3470>
This commit is contained in:
Tim-Philipp Müller 2022-11-26 09:23:59 +01:00
parent d6b4d7a071
commit 0881870219
3 changed files with 15 additions and 0 deletions

View file

@ -180,6 +180,11 @@ gst_audio_filter_submit_input_buffer (GstBaseTransform * btrans,
GstAudioFilter *filter = GST_AUDIO_FILTER (btrans);
if (btrans->segment.format == GST_FORMAT_TIME) {
if (!GST_AUDIO_INFO_IS_VALID (&filter->info)) {
GST_WARNING_OBJECT (filter, "Got buffer, but not negotiated yet!");
return GST_FLOW_NOT_NEGOTIATED;
}
input =
gst_audio_buffer_clip (input, &btrans->segment, filter->info.rate,
filter->info.bpf);

View file

@ -918,6 +918,11 @@ gst_audio_convert_submit_input_buffer (GstBaseTransform * base,
GstAudioConvert *this = GST_AUDIO_CONVERT (base);
if (base->segment.format == GST_FORMAT_TIME) {
if (!GST_AUDIO_INFO_IS_VALID (&this->in_info)) {
GST_WARNING_OBJECT (this, "Got buffer, but not negotiated yet!");
return GST_FLOW_NOT_NEGOTIATED;
}
input =
gst_audio_buffer_clip (input, &base->segment, this->in_info.rate,
this->in_info.bpf);

View file

@ -977,6 +977,11 @@ gst_audio_resample_submit_input_buffer (GstBaseTransform * base,
GstAudioResample *resample = GST_AUDIO_RESAMPLE (base);
if (base->segment.format == GST_FORMAT_TIME) {
if (!GST_AUDIO_INFO_IS_VALID (&resample->in)) {
GST_WARNING_OBJECT (resample, "Got buffer, but not negotiated yet!");
return GST_FLOW_NOT_NEGOTIATED;
}
input =
gst_audio_buffer_clip (input, &base->segment, resample->in.rate,
resample->in.bpf);