From 6432f6a1f272d9d04b55f44fa000b864b75f0197 Mon Sep 17 00:00:00 2001 From: Adrian Perez de Castro Date: Sun, 13 Apr 2025 19:31:23 +0200 Subject: [PATCH] alsa: Avoid infinite loop in DSD rate detection Stop testing DSD rates in gst_alsa_detect_dsd_rates() if the rate becomes zero or negative. This avoids an infinite loop if gst_alsa_probe_supported_formats() is used on a PCM sink defined like the following in the ALSA configuration file: pcm.buggy { type plug slave.pcm "buggy_volume" hint.description "Causes an infinite loop in GStreamer" } pcm.buggy_volume { type softvol slave.pcm "buggy_dmix" control.name "buggy_volume" } pcm.buggy_dmix { type dmix ipc_key 12345 slave { pcm "hw:0,0" period_size 1024 buffer_size 4096 } } Part-of: --- subprojects/gst-plugins-base/ext/alsa/gstalsa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subprojects/gst-plugins-base/ext/alsa/gstalsa.c b/subprojects/gst-plugins-base/ext/alsa/gstalsa.c index e22eec3690..b8b21cbea4 100644 --- a/subprojects/gst-plugins-base/ext/alsa/gstalsa.c +++ b/subprojects/gst-plugins-base/ext/alsa/gstalsa.c @@ -383,7 +383,7 @@ gst_alsa_detect_dsd_rates (GstObject * obj, snd_pcm_t * handle, for (i = 0; i < G_N_ELEMENTS (rates_to_test); ++i) { int rate_to_test = rates_to_test[i]; - if (rate_to_test > max_rate) { + if (rate_to_test <= 0 || rate_to_test > max_rate) { keep_testing_rates = FALSE; break; }