spa: alsa: Don't look up h/w dev index for DTS/AC3 devices

Since we know DTS and AC3 devices don't provide the snd_pcm_info of the
real underlying device, let's look for them by name (doesn't seem to be
a better way to detect this case), and avoid overwriting any previously
detected h/w device index (from one of the PCM paths).
This commit is contained in:
Arun Raghavan 2026-06-15 17:07:56 -07:00
parent bdf5b5a2a7
commit 8d1fc2cebd

View file

@ -4500,7 +4500,7 @@ static void mapping_paths_probe(pa_alsa_mapping *m, pa_alsa_profile *profile,
} }
PA_HASHMAP_FOREACH(p, ps->paths, state) { PA_HASHMAP_FOREACH(p, ps->paths, state) {
if (p->autodetect_eld_device) if (p->autodetect_eld_device && m->hw_device_index >= 0)
p->eld_device = m->hw_device_index; p->eld_device = m->hw_device_index;
if (pa_alsa_path_probe(p, m, mixer_handle, m->profile_set->ignore_dB) < 0) if (pa_alsa_path_probe(p, m, mixer_handle, m->profile_set->ignore_dB) < 0)
@ -5087,6 +5087,7 @@ static int add_profiles_to_probe(
static void mapping_query_hw_device(pa_alsa_mapping *mapping, snd_pcm_t *pcm) { static void mapping_query_hw_device(pa_alsa_mapping *mapping, snd_pcm_t *pcm) {
int r; int r;
snd_pcm_info_t* pcm_info; snd_pcm_info_t* pcm_info;
const char *name;
snd_pcm_info_alloca(&pcm_info); snd_pcm_info_alloca(&pcm_info);
r = snd_pcm_info(pcm, pcm_info); r = snd_pcm_info(pcm, pcm_info);
@ -5098,8 +5099,11 @@ static void mapping_query_hw_device(pa_alsa_mapping *mapping, snd_pcm_t *pcm) {
/* XXX: It's not clear what snd_pcm_info_get_device() does if the device is /* XXX: It's not clear what snd_pcm_info_get_device() does if the device is
* not backed by a hw device or if it's backed by multiple hw devices. We * not backed by a hw device or if it's backed by multiple hw devices. We
* only use hw_device_index for HDMI devices, however, and for those the * only use hw_device_index for HDMI devices, however, and for those the
* return value is expected to be always valid, so this shouldn't be a * return value is expected to be always valid with a couple of known
* significant problem. */ * exceptions, which we try to avoid below */
name = snd_pcm_info_get_name(pcm_info);
if (!spa_strstartswith(name, "a52") && !spa_strstartswith(name, "dcahdmi"))
mapping->hw_device_index = snd_pcm_info_get_device(pcm_info); mapping->hw_device_index = snd_pcm_info_get_device(pcm_info);
} }