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: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8985>
This commit is contained in:
Adrian Perez de Castro 2025-04-13 19:31:23 +02:00 committed by GStreamer Marge Bot
parent c03a5b0c1b
commit 6432f6a1f2

View File

@ -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;
}