From 318258f2945aff4ff3f243968b4cd709f012570c Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 5 Feb 2008 08:11:02 +0100 Subject: [PATCH] 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. --- iecset/iecset.1 | 4 ++++ iecset/iecset.c | 13 ++++++++++--- 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; } -- 2.47.1