mirror of https://github.com/ericonr/sndio.git
make -a per-device, it doesn't make sense to be per-midi-port since
if one port is open, then all ports must be opened.
This commit is contained in:
parent
007a5ce2e1
commit
96eb11eaf9
|
@ -74,18 +74,16 @@ The options are as follows:
|
||||||
.It Fl a Ar flag
|
.It Fl a Ar flag
|
||||||
Control whether
|
Control whether
|
||||||
.Nm
|
.Nm
|
||||||
opens the audio device
|
opens the audio device only when needed or keeps it open all the time.
|
||||||
.Pq Fl f
|
This applies to MIDI ports controlling the device as well.
|
||||||
or the MIDI port
|
|
||||||
.Pq Fl q
|
|
||||||
only when needed or keeps it open all the time.
|
|
||||||
If the flag is
|
If the flag is
|
||||||
.Va on
|
.Va on
|
||||||
then it is kept open all the time, ensuring no other program can steal it.
|
then the device is kept open all the time, ensuring no other program can
|
||||||
|
steal it.
|
||||||
If the flag is
|
If the flag is
|
||||||
.Va off ,
|
.Va off ,
|
||||||
then it's automatically closed, allowing other programs to have direct
|
then it's automatically closed, allowing other programs to have direct
|
||||||
access to it, or corresponding audio or MIDI hardware to be disconnected.
|
access to the device, or the device to be disconnected.
|
||||||
The default is
|
The default is
|
||||||
.Va on .
|
.Va on .
|
||||||
.It Fl b Ar nframes
|
.It Fl b Ar nframes
|
||||||
|
@ -322,7 +320,7 @@ On the command line,
|
||||||
per-device parameters
|
per-device parameters
|
||||||
.Pq Fl abwz
|
.Pq Fl abwz
|
||||||
must precede the device definition
|
must precede the device definition
|
||||||
.Pq Fl fq ,
|
.Pq Fl f ,
|
||||||
and per-stream parameters
|
and per-stream parameters
|
||||||
.Pq Fl Ccehjmrtvx
|
.Pq Fl Ccehjmrtvx
|
||||||
must precede the stream definition
|
must precede the stream definition
|
||||||
|
|
|
@ -235,7 +235,6 @@ SLIST_HEAD(cfstrlist, cfstr);
|
||||||
struct cfmid {
|
struct cfmid {
|
||||||
SLIST_ENTRY(cfmid) entry;
|
SLIST_ENTRY(cfmid) entry;
|
||||||
char *path; /* static path (no need to copy it) */
|
char *path; /* static path (no need to copy it) */
|
||||||
int hold;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
SLIST_HEAD(cfmidlist, cfmid);
|
SLIST_HEAD(cfmidlist, cfmid);
|
||||||
|
@ -339,8 +338,8 @@ cfstr_add(struct cfstrlist *list, struct cfstr *cs, char *path)
|
||||||
SLIST_INSERT_HEAD(list, cs, entry);
|
SLIST_INSERT_HEAD(list, cs, entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cfmid *
|
void
|
||||||
cfmid_new(struct cfmid *templ)
|
cfmid_add(struct cfmidlist *list, char *path)
|
||||||
{
|
{
|
||||||
struct cfmid *cm;
|
struct cfmid *cm;
|
||||||
|
|
||||||
|
@ -349,18 +348,6 @@ cfmid_new(struct cfmid *templ)
|
||||||
perror("malloc");
|
perror("malloc");
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
if (templ)
|
|
||||||
memcpy(cm, templ, sizeof(struct cfmid));
|
|
||||||
else {
|
|
||||||
cm->hold = 1;
|
|
||||||
}
|
|
||||||
cm->path = NULL;
|
|
||||||
return cm;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cfmid_add(struct cfmidlist *list, struct cfmid *cm, char *path)
|
|
||||||
{
|
|
||||||
cm->path = path;
|
cm->path = path;
|
||||||
SLIST_INSERT_HEAD(list, cm, entry);
|
SLIST_INSERT_HEAD(list, cm, entry);
|
||||||
}
|
}
|
||||||
|
@ -519,7 +506,6 @@ aucat_main(int argc, char **argv)
|
||||||
*/
|
*/
|
||||||
cd = cfdev_new(NULL);
|
cd = cfdev_new(NULL);
|
||||||
cs = cfstr_new(NULL);
|
cs = cfstr_new(NULL);
|
||||||
cm = cfmid_new(NULL);
|
|
||||||
|
|
||||||
while ((c = getopt(argc, argv, "a:w:dnb:c:C:e:r:h:x:v:i:o:f:m:luq:s:U:L:t:j:z:")) != -1) {
|
while ((c = getopt(argc, argv, "a:w:dnb:c:C:e:r:h:x:v:i:o:f:m:luq:s:U:L:t:j:z:")) != -1) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
|
@ -601,14 +587,13 @@ aucat_main(int argc, char **argv)
|
||||||
nsock++;
|
nsock++;
|
||||||
break;
|
break;
|
||||||
case 'a':
|
case 'a':
|
||||||
cm->hold = cd->hold = opt_onoff();
|
cd->hold = opt_onoff();
|
||||||
break;
|
break;
|
||||||
case 'w':
|
case 'w':
|
||||||
cd->autovol = opt_onoff();
|
cd->autovol = opt_onoff();
|
||||||
break;
|
break;
|
||||||
case 'q':
|
case 'q':
|
||||||
cfmid_add(&cd->mids, cm, optarg);
|
cfmid_add(&cd->mids, optarg);
|
||||||
cm = cfmid_new(cm);
|
|
||||||
break;
|
break;
|
||||||
case 'b':
|
case 'b':
|
||||||
cd->bufsz = strtonum(optarg, 1, RATE_MAX * 5, &str);
|
cd->bufsz = strtonum(optarg, 1, RATE_MAX * 5, &str);
|
||||||
|
@ -688,7 +673,6 @@ aucat_main(int argc, char **argv)
|
||||||
free(cs);
|
free(cs);
|
||||||
free(cd);
|
free(cd);
|
||||||
}
|
}
|
||||||
free(cm);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check modes and calculate "best" device parameters. Iterate over all
|
* Check modes and calculate "best" device parameters. Iterate over all
|
||||||
|
@ -768,7 +752,7 @@ aucat_main(int argc, char **argv)
|
||||||
while (!SLIST_EMPTY(&cd->mids)) {
|
while (!SLIST_EMPTY(&cd->mids)) {
|
||||||
cm = SLIST_FIRST(&cd->mids);
|
cm = SLIST_FIRST(&cd->mids);
|
||||||
SLIST_REMOVE_HEAD(&cd->mids, entry);
|
SLIST_REMOVE_HEAD(&cd->mids, entry);
|
||||||
if (!devctl_add(d, cm->path, cm->hold, MODE_MIDIMASK))
|
if (!devctl_add(d, cm->path, MODE_MIDIMASK))
|
||||||
errx(1, "%s: can't open port", cm->path);
|
errx(1, "%s: can't open port", cm->path);
|
||||||
free(cm);
|
free(cm);
|
||||||
}
|
}
|
||||||
|
@ -925,7 +909,6 @@ midicat_main(int argc, char **argv)
|
||||||
*/
|
*/
|
||||||
cs = cfstr_new(NULL);
|
cs = cfstr_new(NULL);
|
||||||
cd = cfdev_new(NULL);
|
cd = cfdev_new(NULL);
|
||||||
cm = cfmid_new(NULL);
|
|
||||||
|
|
||||||
while ((c = getopt(argc, argv, "di:o:ls:a:q:U:L:")) != -1) {
|
while ((c = getopt(argc, argv, "di:o:ls:a:q:U:L:")) != -1) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
|
@ -945,11 +928,10 @@ midicat_main(int argc, char **argv)
|
||||||
cs = cfstr_new(cs);
|
cs = cfstr_new(cs);
|
||||||
break;
|
break;
|
||||||
case 'a':
|
case 'a':
|
||||||
cm->hold = opt_onoff();
|
cd->hold = opt_onoff();
|
||||||
break;
|
break;
|
||||||
case 'q':
|
case 'q':
|
||||||
cfmid_add(&cd->mids, cm, optarg);
|
cfmid_add(&cd->mids, optarg);
|
||||||
cm = cfmid_new(cm);
|
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
cfstr_add(&cd->opts, cs, optarg);
|
cfstr_add(&cd->opts, cs, optarg);
|
||||||
|
@ -1000,19 +982,15 @@ midicat_main(int argc, char **argv)
|
||||||
if (SLIST_EMPTY(&cd->mids)) {
|
if (SLIST_EMPTY(&cd->mids)) {
|
||||||
if (SLIST_EMPTY(&cd->ins) && SLIST_EMPTY(&cd->outs)) {
|
if (SLIST_EMPTY(&cd->ins) && SLIST_EMPTY(&cd->outs)) {
|
||||||
cfstr_add(&cd->opts, cs, DEFAULT_OPT);
|
cfstr_add(&cd->opts, cs, DEFAULT_OPT);
|
||||||
free(cm);
|
|
||||||
nsock++;
|
nsock++;
|
||||||
} else {
|
} else {
|
||||||
cfmid_add(&cd->mids, cm, "default");
|
cfmid_add(&cd->mids, "default");
|
||||||
free(cs);
|
free(cs);
|
||||||
}
|
}
|
||||||
} else {
|
} else
|
||||||
free(cm);
|
|
||||||
free(cs);
|
free(cs);
|
||||||
}
|
|
||||||
cfdev_add(&cfdevs, cd, "default");
|
cfdev_add(&cfdevs, cd, "default");
|
||||||
} else {
|
} else {
|
||||||
free(cm);
|
|
||||||
free(cs);
|
free(cs);
|
||||||
free(cd);
|
free(cd);
|
||||||
}
|
}
|
||||||
|
@ -1028,7 +1006,7 @@ midicat_main(int argc, char **argv)
|
||||||
cd = SLIST_FIRST(&cfdevs);
|
cd = SLIST_FIRST(&cfdevs);
|
||||||
SLIST_REMOVE_HEAD(&cfdevs, entry);
|
SLIST_REMOVE_HEAD(&cfdevs, entry);
|
||||||
|
|
||||||
d = dev_new_thru();
|
d = dev_new_thru(cd->hold);
|
||||||
if (d == NULL)
|
if (d == NULL)
|
||||||
errx(1, "%s: can't open device", cd->path);
|
errx(1, "%s: can't open device", cd->path);
|
||||||
if (SLIST_EMPTY(&cd->opts) && APROC_OK(d->midi))
|
if (SLIST_EMPTY(&cd->opts) && APROC_OK(d->midi))
|
||||||
|
@ -1040,7 +1018,7 @@ midicat_main(int argc, char **argv)
|
||||||
while (!SLIST_EMPTY(&cd->mids)) {
|
while (!SLIST_EMPTY(&cd->mids)) {
|
||||||
cm = SLIST_FIRST(&cd->mids);
|
cm = SLIST_FIRST(&cd->mids);
|
||||||
SLIST_REMOVE_HEAD(&cd->mids, entry);
|
SLIST_REMOVE_HEAD(&cd->mids, entry);
|
||||||
if (!devctl_add(d, cm->path, cm->hold, MODE_MIDIMASK))
|
if (!devctl_add(d, cm->path, MODE_MIDIMASK))
|
||||||
errx(1, "%s: can't open port", cm->path);
|
errx(1, "%s: can't open port", cm->path);
|
||||||
free(cm);
|
free(cm);
|
||||||
}
|
}
|
||||||
|
|
11
aucat/dev.c
11
aucat/dev.c
|
@ -183,7 +183,7 @@ dev_new_loop(struct aparams *dipar, struct aparams *dopar, unsigned bufsz)
|
||||||
* Create a MIDI thru box device
|
* Create a MIDI thru box device
|
||||||
*/
|
*/
|
||||||
struct dev *
|
struct dev *
|
||||||
dev_new_thru(void)
|
dev_new_thru(int hold)
|
||||||
{
|
{
|
||||||
struct dev *d;
|
struct dev *d;
|
||||||
|
|
||||||
|
@ -195,7 +195,7 @@ dev_new_thru(void)
|
||||||
d->ctl_list = NULL;
|
d->ctl_list = NULL;
|
||||||
d->reqmode = MODE_MIDIMASK;
|
d->reqmode = MODE_MIDIMASK;
|
||||||
d->pstate = DEV_CLOSED;
|
d->pstate = DEV_CLOSED;
|
||||||
d->hold = 0;
|
d->hold = hold;
|
||||||
d->path = "midithru";
|
d->path = "midithru";
|
||||||
d->next = dev_list;
|
d->next = dev_list;
|
||||||
dev_list = d;
|
dev_list = d;
|
||||||
|
@ -206,21 +206,16 @@ dev_new_thru(void)
|
||||||
* Add a MIDI port to the device
|
* Add a MIDI port to the device
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
devctl_add(struct dev *d, char *name, int hold, unsigned mode)
|
devctl_add(struct dev *d, char *name, unsigned mode)
|
||||||
{
|
{
|
||||||
struct devctl *c;
|
struct devctl *c;
|
||||||
|
|
||||||
if (hold) {
|
|
||||||
if (!dev_ref(d))
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
c = malloc(sizeof(struct devctl));
|
c = malloc(sizeof(struct devctl));
|
||||||
if (c == NULL) {
|
if (c == NULL) {
|
||||||
perror("malloc");
|
perror("malloc");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
c->path = name;
|
c->path = name;
|
||||||
c->hold = hold;
|
|
||||||
c->mode = mode;
|
c->mode = mode;
|
||||||
c->next = d->ctl_list;
|
c->next = d->ctl_list;
|
||||||
d->ctl_list = c;
|
d->ctl_list = c;
|
||||||
|
|
|
@ -54,9 +54,8 @@ struct dev {
|
||||||
struct aproc *midi;
|
struct aproc *midi;
|
||||||
struct devctl {
|
struct devctl {
|
||||||
struct devctl *next;
|
struct devctl *next;
|
||||||
char *path;
|
|
||||||
unsigned mode;
|
unsigned mode;
|
||||||
int hold;
|
char *path;
|
||||||
} *ctl_list;
|
} *ctl_list;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -68,12 +67,12 @@ void dev_unref(struct dev *);
|
||||||
void dev_del(struct dev *);
|
void dev_del(struct dev *);
|
||||||
void dev_wakeup(struct dev *);
|
void dev_wakeup(struct dev *);
|
||||||
void dev_drain(struct dev *);
|
void dev_drain(struct dev *);
|
||||||
struct dev *dev_new_thru(void);
|
struct dev *dev_new_thru(int);
|
||||||
struct dev *dev_new_loop(struct aparams *, struct aparams *, unsigned);
|
struct dev *dev_new_loop(struct aparams *, struct aparams *, unsigned);
|
||||||
struct dev *dev_new_sio(char *, unsigned,
|
struct dev *dev_new_sio(char *, unsigned,
|
||||||
struct aparams *, struct aparams *,
|
struct aparams *, struct aparams *,
|
||||||
unsigned, unsigned, unsigned, unsigned);
|
unsigned, unsigned, unsigned, unsigned);
|
||||||
int devctl_add(struct dev *, char *, int, unsigned);
|
int devctl_add(struct dev *, char *, unsigned);
|
||||||
void dev_midiattach(struct dev *, struct abuf *, struct abuf *);
|
void dev_midiattach(struct dev *, struct abuf *, struct abuf *);
|
||||||
unsigned dev_roundof(struct dev *, unsigned);
|
unsigned dev_roundof(struct dev *, unsigned);
|
||||||
int dev_getpos(struct dev *);
|
int dev_getpos(struct dev *);
|
||||||
|
|
|
@ -51,14 +51,16 @@ The options are as follows:
|
||||||
.It Fl a Ar flag
|
.It Fl a Ar flag
|
||||||
Control whether
|
Control whether
|
||||||
.Nm
|
.Nm
|
||||||
opens the MIDI port only when needed or keeps it open all the time.
|
opens all MIDI ports connected to the thru box only when needed
|
||||||
|
or keeps them open all the time.
|
||||||
If the flag is
|
If the flag is
|
||||||
.Va on
|
.Va on
|
||||||
then it is kept open all the time, ensuring no other program can steal it.
|
then MIDI ports are are kept open all the time, ensuring no other program can
|
||||||
|
steal any of them.
|
||||||
If the flag is
|
If the flag is
|
||||||
.Va off ,
|
.Va off ,
|
||||||
then it's automatically closed, allowing other programs to have direct
|
then they are automatically closed, allowing other programs to have direct
|
||||||
access to it, or the corresponding MIDI hardware to be disconnected.
|
access to MIDI ports, or the corresponding hardware to be disconnected.
|
||||||
The default is
|
The default is
|
||||||
.Va on .
|
.Va on .
|
||||||
.It Fl d
|
.It Fl d
|
||||||
|
|
Loading…
Reference in New Issue