mirror of https://github.com/ericonr/sndio.git
sndiod: Initialize slot with parameters from the opt struct.
This commit is contained in:
parent
c42684a889
commit
426a9064fa
36
sndiod/dev.c
36
sndiod/dev.c
|
@ -74,7 +74,6 @@ void dev_mmcstop(struct dev *);
|
||||||
void dev_mmcloc(struct dev *, unsigned int);
|
void dev_mmcloc(struct dev *, unsigned int);
|
||||||
|
|
||||||
void slot_log(struct slot *);
|
void slot_log(struct slot *);
|
||||||
struct slot *slot_new(struct dev *, char *, struct slotops *, void *, int);
|
|
||||||
void slot_del(struct slot *);
|
void slot_del(struct slot *);
|
||||||
void slot_setvol(struct slot *, unsigned int);
|
void slot_setvol(struct slot *, unsigned int);
|
||||||
void slot_attach(struct slot *);
|
void slot_attach(struct slot *);
|
||||||
|
@ -1547,7 +1546,8 @@ slot_freebufs(struct slot *s)
|
||||||
* allocate a new slot and register the given call-backs
|
* allocate a new slot and register the given call-backs
|
||||||
*/
|
*/
|
||||||
struct slot *
|
struct slot *
|
||||||
slot_new(struct dev *d, char *who, struct slotops *ops, void *arg, int mode)
|
slot_new(struct dev *d, struct opt *opt, char *who,
|
||||||
|
struct slotops *ops, void *arg, int mode)
|
||||||
{
|
{
|
||||||
char *p;
|
char *p;
|
||||||
char name[SLOT_NAMEMAX];
|
char name[SLOT_NAMEMAX];
|
||||||
|
@ -1642,6 +1642,17 @@ slot_new(struct dev *d, char *who, struct slotops *ops, void *arg, int mode)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
found:
|
found:
|
||||||
|
if ((mode & MODE_REC) && (opt->mode & MODE_MON)) {
|
||||||
|
mode |= MODE_MON;
|
||||||
|
mode &= ~MODE_REC;
|
||||||
|
}
|
||||||
|
if ((mode & opt->mode) != mode) {
|
||||||
|
if (log_level >= 1) {
|
||||||
|
slot_log(s);
|
||||||
|
log_puts(": requested mode not allowed\n");
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
if (!dev_ref(d))
|
if (!dev_ref(d))
|
||||||
return NULL;
|
return NULL;
|
||||||
if ((mode & d->mode) != mode) {
|
if ((mode & d->mode) != mode) {
|
||||||
|
@ -1653,27 +1664,32 @@ found:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
s->dev = d;
|
s->dev = d;
|
||||||
|
s->opt = opt;
|
||||||
s->ops = ops;
|
s->ops = ops;
|
||||||
s->arg = arg;
|
s->arg = arg;
|
||||||
s->pstate = SLOT_INIT;
|
s->pstate = SLOT_INIT;
|
||||||
s->tstate = MMC_OFF;
|
|
||||||
s->mode = mode;
|
s->mode = mode;
|
||||||
aparams_init(&s->par);
|
aparams_init(&s->par);
|
||||||
if (s->mode & MODE_PLAY) {
|
if (s->mode & MODE_PLAY) {
|
||||||
s->mix.slot_cmin = s->mix.dev_cmin = 0;
|
s->mix.slot_cmin = s->mix.dev_cmin = s->opt->pmin;
|
||||||
s->mix.slot_cmax = s->mix.dev_cmax = d->pchan - 1;
|
s->mix.slot_cmax = s->mix.dev_cmax = s->opt->pmax;
|
||||||
}
|
}
|
||||||
if (s->mode & MODE_RECMASK) {
|
if (s->mode & MODE_RECMASK) {
|
||||||
s->sub.slot_cmin = s->sub.dev_cmin = 0;
|
s->sub.slot_cmin = s->sub.dev_cmin = s->opt->rmin;
|
||||||
s->sub.slot_cmax = s->sub.dev_cmax =
|
s->sub.slot_cmax = s->sub.dev_cmax = s->opt->rmax;
|
||||||
((s->mode & MODE_MON) ? d->pchan : d->rchan) - 1;
|
|
||||||
}
|
}
|
||||||
|
if (s->opt->mmc) {
|
||||||
|
s->xrun = XRUN_SYNC;
|
||||||
|
s->tstate = MMC_STOP;
|
||||||
|
} else {
|
||||||
s->xrun = XRUN_IGNORE;
|
s->xrun = XRUN_IGNORE;
|
||||||
s->dup = 0;
|
s->tstate = MMC_OFF;
|
||||||
|
}
|
||||||
|
s->mix.maxweight = s->opt->maxweight;
|
||||||
|
s->dup = s->opt->dup;
|
||||||
s->appbufsz = d->bufsz;
|
s->appbufsz = d->bufsz;
|
||||||
s->round = d->round;
|
s->round = d->round;
|
||||||
s->rate = d->rate;
|
s->rate = d->rate;
|
||||||
s->mix.maxweight = ADATA_UNIT;
|
|
||||||
dev_midi_slotdesc(d, s);
|
dev_midi_slotdesc(d, s);
|
||||||
dev_midi_vol(d, s);
|
dev_midi_vol(d, s);
|
||||||
return s;
|
return s;
|
||||||
|
|
|
@ -237,7 +237,8 @@ void dev_midi_vol(struct dev *, struct slot *);
|
||||||
* sio_open(3) like interface for clients
|
* sio_open(3) like interface for clients
|
||||||
*/
|
*/
|
||||||
void slot_log(struct slot *);
|
void slot_log(struct slot *);
|
||||||
struct slot *slot_new(struct dev *, char *, struct slotops *, void *, int);
|
struct slot *slot_new(struct dev *, struct opt *, char *,
|
||||||
|
struct slotops *, void *, int);
|
||||||
void slot_del(struct slot *);
|
void slot_del(struct slot *);
|
||||||
void slot_setvol(struct slot *, unsigned int);
|
void slot_setvol(struct slot *, unsigned int);
|
||||||
void slot_start(struct slot *);
|
void slot_start(struct slot *);
|
||||||
|
|
|
@ -861,39 +861,10 @@ sock_hello(struct sock *f)
|
||||||
log_puts("\n");
|
log_puts("\n");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if ((mode & MODE_REC) && (opt->mode & MODE_MON)) {
|
s = slot_new(d, opt, p->who, &sock_slotops, f, mode);
|
||||||
mode |= MODE_MON;
|
|
||||||
mode &= ~MODE_REC;
|
|
||||||
}
|
|
||||||
if ((mode & opt->mode) != mode) {
|
|
||||||
if (log_level >= 1) {
|
|
||||||
sock_log(f);
|
|
||||||
log_puts(": requested mode not allowed\n");
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
s = slot_new(d, p->who, &sock_slotops, f, mode);
|
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
s->opt = opt;
|
|
||||||
f->midi = NULL;
|
f->midi = NULL;
|
||||||
if (s->mode & MODE_PLAY) {
|
|
||||||
s->mix.slot_cmin = s->mix.dev_cmin = s->opt->pmin;
|
|
||||||
s->mix.slot_cmax = s->mix.dev_cmax = s->opt->pmax;
|
|
||||||
}
|
|
||||||
if (s->mode & MODE_RECMASK) {
|
|
||||||
s->sub.slot_cmin = s->sub.dev_cmin = s->opt->rmin;
|
|
||||||
s->sub.slot_cmax = s->sub.dev_cmax = s->opt->rmax;
|
|
||||||
}
|
|
||||||
if (s->opt->mmc) {
|
|
||||||
s->xrun = XRUN_SYNC;
|
|
||||||
s->tstate = MMC_STOP;
|
|
||||||
} else {
|
|
||||||
s->xrun = XRUN_IGNORE;
|
|
||||||
s->tstate = MMC_OFF;
|
|
||||||
}
|
|
||||||
s->mix.maxweight = s->opt->maxweight;
|
|
||||||
s->dup = s->opt->dup;
|
|
||||||
f->slot = s;
|
f->slot = s;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue