From 78212445de4c8e07873cbc7dff2abcacd031f151 Mon Sep 17 00:00:00 2001
From: Jaroslav Kysela <perex@perex.cz>
Date: Tue, 1 Jun 2021 17:47:42 +0200
Subject: [PATCH] alsactl: fix the nested iteration

There may be nested iterations for hw: card names.
Handle this card name in snd_card_iterator_sinit().

BugLink: https://github.com/alsa-project/alsa-lib/issues/142
Fixes: eefc2c6 ("alsactl: use card iterator functions for all card loops")
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
---
 alsactl/utils.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/alsactl/utils.c b/alsactl/utils.c
index c79fd951..881b5053 100644
--- a/alsactl/utils.c
+++ b/alsactl/utils.c
@@ -247,6 +247,8 @@ int snd_card_iterator_sinit(struct snd_card_iterator *iter, const char *cardname
 	int cardno = -1;
 
 	if (cardname) {
+		if (strncmp(cardname, "hw:", 3) == 0)
+			cardname += 3;
 		cardno = snd_card_get_index(cardname);
 		if (cardno < 0) {
 			error("Cannot find soundcard '%s'...", cardname);
