summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2008-02-05 08:11:02 +0100
committerTakashi Iwai <tiwai@suse.de>2008-02-05 08:11:02 +0100
commit318258f2945aff4ff3f243968b4cd709f012570c (patch)
treecdd04b295b82a0c979875e899d9fdf1566136b15
parenteedab6e3e3e299bad3b1d4e098800c0c0d8328c4 (diff)
downloadalsa-utils-318258f2945aff4ff3f243968b4cd709f012570c.tar.gz
iecset - Add -n option
Added -n option to iecset to specify the index number of the control element. This is needed for handling multiple SPDIF devices.
-rw-r--r--iecset/iecset.14
-rw-r--r--iecset/iecset.c13
2 files changed, 14 insertions, 3 deletions
diff --git a/iecset/iecset.1 b/iecset/iecset.1
index fd47595..dec4ac0 100644
--- a/iecset/iecset.1
+++ b/iecset/iecset.1
@@ -42,6 +42,10 @@ Specifies the device name of the control to open
\fI\-c\fP card
Specifies the card index to open. Equivalent with \fI\-Dhw:x\fP.
.TP
+\fI\-n\fP index
+Specifies the IEC958 control element index, in case you have multiple
+IEC958 devices and need to choose one of them.
+.TP
\fI\-x\fP
Dumps the status in the form of AESx bytes.
.TP
diff --git a/iecset/iecset.c b/iecset/iecset.c
index 72f6cc0..a2fe4d1 100644
--- a/iecset/iecset.c
+++ b/iecset/iecset.c
@@ -286,6 +286,7 @@ int main(int argc, char **argv)
{
const char *dev = "default";
const char *spdif_str = SND_CTL_NAME_IEC958("", PLAYBACK, DEFAULT);
+ int spdif_index = -1;
snd_ctl_t *ctl;
snd_ctl_elem_list_t *clist;
snd_ctl_elem_id_t *cid;
@@ -301,7 +302,7 @@ int main(int argc, char **argv)
for (i = 0; i < IDX_LAST; i++)
parms[i] = -1; /* not set */
- while ((c = getopt(argc, argv, "D:c:xhi")) != -1) {
+ while ((c = getopt(argc, argv, "D:c:n:xhi")) != -1) {
switch (c) {
case 'D':
dev = optarg;
@@ -315,6 +316,9 @@ int main(int argc, char **argv)
sprintf(tmpname, "hw:%d", i);
dev = tmpname;
break;
+ case 'n':
+ spdif_index = atoi(optarg);
+ break;
case 'x':
dumphex = 1;
break;
@@ -349,10 +353,13 @@ int main(int argc, char **argv)
controls = snd_ctl_elem_list_get_used(clist);
for (cidx = 0; cidx < controls; cidx++) {
if (!strcmp(snd_ctl_elem_list_get_name(clist, cidx), spdif_str))
- break;
+ if (spdif_index < 0 ||
+ snd_ctl_elem_list_get_index(clist, cidx) == spdif_index)
+ break;
}
if (cidx >= controls) {
- fprintf(stderr, "control \"%s\" not found\n", spdif_str);
+ fprintf(stderr, "control \"%s\" (index %d) not found\n",
+ spdif_str, spdif_index);
return 1;
}