-/* $OpenBSD: dev.c,v 1.96 2021/03/08 09:38:36 ratchov Exp $ */
+/* $OpenBSD: dev.c,v 1.97 2021/03/08 09:42:50 ratchov Exp $ */
/*
* Copyright (c) 2008-2012 Alexandre Ratchov <alex@caoua.org>
*
unsigned int mode, unsigned int bufsz, unsigned int round,
unsigned int rate, unsigned int hold, unsigned int autovol)
{
- struct dev *d;
+ struct dev *d, **pd;
if (dev_sndnum == DEV_NMAX) {
if (log_level >= 1)
d->master = MIDI_MAXCTL;
d->master_enabled = 0;
snprintf(d->name, CTL_NAMEMAX, "%u", d->num);
- d->next = dev_list;
- dev_list = d;
+ for (pd = &dev_list; *pd != NULL; pd = &(*pd)->next)
+ ;
+ d->next = *pd;
+ *pd = d;
return d;
}
-/* $OpenBSD: sndiod.c,v 1.44 2021/02/05 17:59:33 jcs Exp $ */
+/* $OpenBSD: sndiod.c,v 1.45 2021/03/08 09:42:50 ratchov Exp $ */
/*
* Copyright (c) 2008-2012 Alexandre Ratchov <alex@caoua.org>
*
int
main(int argc, char **argv)
{
- int c, i, background, unit, devindex;
+ int c, i, background, unit;
int pmin, pmax, rmin, rmax;
char base[SOCKPATH_MAX], path[SOCKPATH_MAX];
unsigned int mode, dup, mmc, vol;
aparams_init(&par);
mode = MODE_PLAY | MODE_REC;
tcpaddr_list = NULL;
- devindex = 0;
+ d = NULL;
+ p = NULL;
slot_array_init();
errx(1, "%s: volume is %s", optarg, str);
break;
case 's':
- if ((d = dev_list) == NULL) {
- d = mkdev(default_devs[devindex++], &par, 0,
- bufsz, round, rate, hold, autovol);
+ if (d == NULL) {
+ for (i = 0; default_devs[i] != NULL; i++) {
+ mkdev(default_devs[i], &par, 0,
+ bufsz, round, rate, 0, autovol);
+ }
+ d = dev_list;
}
if (mkopt(optarg, d, pmin, pmax, rmin, rmax,
mode, vol, mmc, dup) == NULL)
return 1;
break;
case 'q':
- mkport(optarg, hold);
+ p = mkport(optarg, hold);
break;
case 'Q':
- if (port_list == NULL)
+ if (p == NULL)
errx(1, "-Q %s: no ports defined", optarg);
- namelist_add(&port_list->path_list, optarg);
+ namelist_add(&p->path_list, optarg);
break;
case 'a':
hold = opt_onoff();
errx(1, "%s: block size is %s", optarg, str);
break;
case 'f':
- mkdev(optarg, &par, 0, bufsz, round,
+ d = mkdev(optarg, &par, 0, bufsz, round,
rate, hold, autovol);
- devindex = -1;
break;
case 'F':
- if ((d = dev_list) == NULL)
+ if (d == NULL)
errx(1, "-F %s: no devices defined", optarg);
if (!dev_addname(d, optarg))
exit(1);
for (i = 0; default_ports[i] != NULL; i++)
mkport(default_ports[i], 0);
}
- if (devindex != -1) {
- for (i = devindex; default_devs[i] != NULL; i++) {
+ if (dev_list == NULL) {
+ for (i = 0; default_devs[i] != NULL; i++) {
mkdev(default_devs[i], &par, 0,
bufsz, round, rate, 0, autovol);
}