audio-converter: Fix resampling when there's nothing to output
authorNirbheek Chauhan <nirbheek@centricular.com>
Mon, 20 Dec 2021 16:07:18 +0000 (21:37 +0530)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Sat, 8 Jan 2022 05:15:30 +0000 (05:15 +0000)
commit554a2a5145bf6cd25d439bbe4da69ac32417658c
tree4b9c7f31a110444b28cdc49cca892037e83e6f98
parent51e93408a9e744771dfbdf39f3670ce10afc8472
audio-converter: Fix resampling when there's nothing to output

Sometimes we can't output anything because we don't have enough
incoming frames. In that case, the resampler was trying to call
do_quantize() and do_resample() in a loop forever because there would
never be samples to output (so chain->samples would always be NULL).

Fix this by not calling chain->make_func() in a loop -- seems
completely unnecessary since calling it over and over won't change
anything if the make_func() can't output samples.

Also add some checks for the input and / or output being NULL when
doing conversion or quantization. This will happen when we have
nothing to output.

We can't bail early, because we need resampler->samples_avail to be
updated in gst_audio_resampler_resample(), so we must call that and
no-op everything along the way.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1461>
subprojects/gst-plugins-base/gst-libs/gst/audio/audio-converter.c
subprojects/gst-plugins-base/gst-libs/gst/audio/audio-resampler.c