Move the options list out of the device structure

This commit is contained in:
Alexandre Ratchov 2020-12-04 09:13:55 +01:00
parent 4710960bbe
commit 8e99cca36c
5 changed files with 28 additions and 22 deletions

View File

@ -1045,7 +1045,6 @@ dev_new(char *path, struct aparams *par,
d->alt_list = NULL;
dev_addname(d,path);
d->num = dev_sndnum++;
d->opt_list = NULL;
d->alt_num = -1;
/*
@ -1502,8 +1501,6 @@ dev_del(struct dev *d)
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) {

View File

@ -114,18 +114,6 @@ struct slot {
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
*/
@ -171,7 +159,6 @@ struct ctlslot {
struct dev {
struct dev *next;
struct slot *slot_list; /* audio streams attached */
struct opt *opt_list;
struct midi *midi;
/*

View File

@ -20,6 +20,8 @@
#include "opt.h"
#include "utils.h"
struct opt *opt_list;
/*
* create a new audio sub-device "configuration"
*/
@ -54,6 +56,7 @@ opt_new(struct dev *d, char *name,
}
}
o = xmalloc(sizeof(struct opt));
o->dev = d;
if (mode & MODE_PLAY) {
o->pmin = pmin;
o->pmax = pmax;
@ -67,8 +70,8 @@ opt_new(struct dev *d, char *name,
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(".");
@ -110,7 +113,9 @@ opt_byname(struct dev *d, char *name)
{
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;
}
@ -118,11 +123,11 @@ opt_byname(struct dev *d, char *name)
}
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");

View File

@ -19,9 +19,24 @@
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) */

View File

@ -595,6 +595,8 @@ main(int argc, char **argv)
; /* nothing */
midi_done();
while (opt_list)
opt_del(opt_list);
while (dev_list)
dev_del(dev_list);
while (port_list)