]> git.alsa-project.org Git - alsa-utils.git/commitdiff
iecset - Add -n option
authorTakashi Iwai <tiwai@suse.de>
Tue, 5 Feb 2008 07:11:02 +0000 (08:11 +0100)
committerTakashi Iwai <tiwai@suse.de>
Tue, 5 Feb 2008 07:11:02 +0000 (08:11 +0100)
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
iecset/iecset.c

index fd4759557525743e227638fd02d4ca76bc74ab28..dec4ac06eec7967f1000efd57b6fd48f3a71c56d 100644 (file)
@@ -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
index 72f6cc00fdde8bf9e5e67de6c176d73821cfc1ae..a2fe4d1ade01358b0abd6f52fe864cc859274173 100644 (file)
@@ -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;
        }