-/* $OpenBSD: dev.c,v 1.85 2021/01/29 10:55:19 ratchov Exp $ */
+/* $OpenBSD: dev.c,v 1.86 2021/01/29 11:21:00 ratchov Exp $ */
/*
* Copyright (c) 2008-2012 Alexandre Ratchov <alex@caoua.org>
*
d->alt_list = NULL;
dev_addname(d,path);
d->num = dev_sndnum++;
- d->opt_list = NULL;
d->alt_num = -1;
/*
log_puts(": deleting\n");
}
#endif
- while (d->opt_list != NULL)
- opt_del(d, d->opt_list);
if (d->pstate != DEV_CFG)
dev_close(d);
for (p = &dev_list; *p != d; p = &(*p)->next) {
-/* $OpenBSD: dev.h,v 1.33 2021/01/29 10:55:19 ratchov Exp $ */
+/* $OpenBSD: dev.h,v 1.34 2021/01/29 11:21:00 ratchov Exp $ */
/*
* Copyright (c) 2008-2012 Alexandre Ratchov <alex@caoua.org>
*
unsigned int id; /* process id */
};
-struct opt {
- struct opt *next;
-#define OPT_NAMEMAX 11
- char name[OPT_NAMEMAX + 1];
- int maxweight; /* max dynamic range for clients */
- int pmin, pmax; /* play channels */
- int rmin, rmax; /* recording channels */
- int mmc; /* true if MMC control enabled */
- int dup; /* true if join/expand enabled */
- int mode; /* bitmap of MODE_XXX */
-};
-
/*
* subset of channels of a stream
*/
struct dev {
struct dev *next;
struct slot *slot_list; /* audio streams attached */
- struct opt *opt_list;
struct midi *midi;
/*
-/* $OpenBSD: opt.c,v 1.4 2018/06/26 07:12:35 ratchov Exp $ */
+/* $OpenBSD: opt.c,v 1.5 2021/01/29 11:21:00 ratchov Exp $ */
/*
* Copyright (c) 2008-2011 Alexandre Ratchov <alex@caoua.org>
*
#include "opt.h"
#include "utils.h"
+struct opt *opt_list;
+
/*
* create a new audio sub-device "configuration"
*/
}
}
o = xmalloc(sizeof(struct opt));
+ o->dev = d;
if (mode & MODE_PLAY) {
o->pmin = pmin;
o->pmax = pmax;
o->dup = dup;
o->mode = mode;
memcpy(o->name, name, len + 1);
- o->next = d->opt_list;
- d->opt_list = o;
+ o->next = opt_list;
+ opt_list = o;
if (log_level >= 2) {
dev_log(d);
log_puts(".");
{
struct opt *o;
- for (o = d->opt_list; o != NULL; o = o->next) {
+ for (o = opt_list; o != NULL; o = o->next) {
+ if (d != NULL && o->dev != d)
+ continue;
if (strcmp(name, o->name) == 0)
return o;
}
}
void
-opt_del(struct dev *d, struct opt *o)
+opt_del(struct opt *o)
{
struct opt **po;
- for (po = &d->opt_list; *po != o; po = &(*po)->next) {
+ for (po = &opt_list; *po != o; po = &(*po)->next) {
#ifdef DEBUG
if (*po == NULL) {
log_puts("opt_del: not on list\n");
-/* $OpenBSD: opt.h,v 1.2 2018/06/26 07:12:35 ratchov Exp $ */
+/* $OpenBSD: opt.h,v 1.3 2021/01/29 11:21:00 ratchov Exp $ */
/*
* Copyright (c) 2008-2012 Alexandre Ratchov <alex@caoua.org>
*
struct dev;
+struct opt {
+ struct opt *next;
+ struct dev *dev;
+#define OPT_NAMEMAX 11
+ char name[OPT_NAMEMAX + 1];
+ int maxweight; /* max dynamic range for clients */
+ int pmin, pmax; /* play channels */
+ int rmin, rmax; /* recording channels */
+ int mmc; /* true if MMC control enabled */
+ int dup; /* true if join/expand enabled */
+ int mode; /* bitmap of MODE_XXX */
+};
+
+extern struct opt *opt_list;
+
struct opt *opt_new(struct dev *, char *, int, int, int, int,
int, int, int, unsigned int);
-void opt_del(struct dev *, struct opt *);
+void opt_del(struct opt *);
struct opt *opt_byname(struct dev *, char *);
#endif /* !defined(OPT_H) */
-/* $OpenBSD: sndiod.c,v 1.42 2021/01/29 10:51:24 ratchov Exp $ */
+/* $OpenBSD: sndiod.c,v 1.43 2021/01/29 11:21:00 ratchov Exp $ */
/*
* Copyright (c) 2008-2012 Alexandre Ratchov <alex@caoua.org>
*
; /* nothing */
midi_done();
+ while (opt_list)
+ opt_del(opt_list);
while (dev_list)
dev_del(dev_list);
while (port_list)