summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaroslav Kysela <perex@perex.cz>2022-06-06 12:11:24 +0200
committerJaroslav Kysela <perex@perex.cz>2022-06-06 12:14:24 +0200
commit89ee61914756a6f8bcafbad7fb1eca674b0a012f (patch)
tree0f5b30269d3550b6e98b6807800fd6ff4aef5fb1
parent87ff5318e327eb2343f10bd73dce5a32f12db622 (diff)
downloadalsa-lib-89ee61914756a6f8bcafbad7fb1eca674b0a012f.tar.gz
control: eld - fix the decoding for older hw
It seems that the monitor name is not always present in the ELD structure. Add asterisk suffix to notify user about the monitor present for this case. Thanks goes to Bernhard Rosenkränzer <bero@lindev.ch> for the report. Fixes: https://github.com/alsa-project/alsa-lib/pull/233 Fixes: https://github.com/alsa-project/alsa-lib/pull/234 Signed-off-by: Jaroslav Kysela <perex@perex.cz>
-rw-r--r--src/control/eld.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/control/eld.c b/src/control/eld.c
index 1e161eb1..9be9605f 100644
--- a/src/control/eld.c
+++ b/src/control/eld.c
@@ -74,8 +74,13 @@ int __snd_pcm_info_eld_fixup(snd_pcm_info_t * info)
if (cinfo.count < 20 || cinfo.count > 256)
return -EIO;
l = eld[4] & 0x1f;
- if (l == 0 || l > 16 || 20 + l > cinfo.count)
- return -EIO;
+ if (l == 0)
+ /* no monitor name detected */
+ goto __present;
+ if (l > 16 || 20 + l > cinfo.count) {
+ SNDERR("ELD decode failed, using old HDMI output names\n");
+ return 0;
+ }
s = alloca(l + 1);
s[l] = '\0';
/* sanitize */
@@ -90,7 +95,12 @@ int __snd_pcm_info_eld_fixup(snd_pcm_info_t * info)
s[l] = c;
}
}
- if (valid > 3)
+ if (valid > 3) {
snd_strlcpy((char *)info->name, s, sizeof(info->name));
+ } else {
+__present:
+ strncat((char *)info->name, " *", sizeof(info->name) - 1);
+ ((char *)info->name)[sizeof(info->name)-1] = '\0';
+ }
return 0;
}