sndioctl: Add -q option to suppress output when setting variables

This commit is contained in:
Alexandre Ratchov 2020-04-16 14:52:54 +02:00
parent 2254b715af
commit a04ab3f18c
2 changed files with 11 additions and 5 deletions

View File

@ -23,7 +23,7 @@
.Sh SYNOPSIS .Sh SYNOPSIS
.Nm .Nm
.Bk -words .Bk -words
.Op Fl dimnv .Op Fl dimnqv
.Op Fl f Ar device .Op Fl f Ar device
.Op Ar command ... .Op Ar command ...
.Ek .Ek
@ -49,6 +49,8 @@ instead of their values.
Monitor and display audio parameter changes. Monitor and display audio parameter changes.
.It Fl n .It Fl n
Suppress printing of the variable name. Suppress printing of the variable name.
.It Fl q
Suppress all printing when setting a variable.
.It Fl v .It Fl v
Enable verbose mode, a.k.a. multi-channel mode. Enable verbose mode, a.k.a. multi-channel mode.
By default parameters affecting different channels By default parameters affecting different channels

View File

@ -64,7 +64,7 @@ void onctl(void *, unsigned, unsigned);
struct sioctl_hdl *hdl; struct sioctl_hdl *hdl;
struct info *infolist; struct info *infolist;
int i_flag = 0, v_flag = 0, m_flag = 0, n_flag = 0; int i_flag = 0, v_flag = 0, m_flag = 0, n_flag = 0, q_flag = 0;
static inline int static inline int
isname_first(int c) isname_first(int c)
@ -855,7 +855,7 @@ main(int argc, char **argv)
struct pollfd *pfds; struct pollfd *pfds;
int nfds, revents; int nfds, revents;
while ((c = getopt(argc, argv, "df:imnv")) != -1) { while ((c = getopt(argc, argv, "df:imnqv")) != -1) {
switch (c) { switch (c) {
case 'd': case 'd':
d_flag = 1; d_flag = 1;
@ -872,12 +872,15 @@ main(int argc, char **argv)
case 'n': case 'n':
n_flag = 1; n_flag = 1;
break; break;
case 'q':
q_flag = 1;
break;
case 'v': case 'v':
v_flag++; v_flag++;
break; break;
default: default:
fprintf(stderr, "usage: sndioctl " fprintf(stderr, "usage: sndioctl "
"[-dimnv] [-f device] [command ...]\n"); "[-dimnqv] [-f device] [command ...]\n");
exit(1); exit(1);
} }
} }
@ -913,7 +916,8 @@ main(int argc, char **argv)
} }
} }
commit(); commit();
list(); if (!q_flag)
list();
} }
if (m_flag) { if (m_flag) {
pfds = malloc(sizeof(struct pollfd) * sioctl_nfds(hdl)); pfds = malloc(sizeof(struct pollfd) * sioctl_nfds(hdl));