mirror of
https://github.com/ericonr/sndio.git
synced 2024-02-18 04:45:21 -06:00
prefix device specific messages with the device name.
Mark the device as DEV_CLOSE before closing streams, otherwise a stream may try to call dev_close() a second time (dev_close() is in the dev_unref() code path)
This commit is contained in:
parent
51ce17cf96
commit
a34a843352
66
aucat/dev.c
66
aucat/dev.c
@ -520,24 +520,30 @@ dev_close(struct dev *d)
|
|||||||
switch (d->pstate) {
|
switch (d->pstate) {
|
||||||
case DEV_START:
|
case DEV_START:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (debug_level >= 3)
|
if (debug_level >= 3) {
|
||||||
dbg_puts("draining device\n");
|
dev_dbg(d);
|
||||||
|
dbg_puts(": draining device\n");
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
dev_start(d);
|
dev_start(d);
|
||||||
break;
|
break;
|
||||||
case DEV_INIT:
|
case DEV_INIT:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (debug_level >= 3)
|
if (debug_level >= 3) {
|
||||||
dbg_puts("flushing device\n");
|
dev_dbg(d);
|
||||||
|
dbg_puts(": flushing device\n");
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
dev_clear(d);
|
dev_clear(d);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (debug_level >= 2)
|
if (debug_level >= 2) {
|
||||||
dbg_puts("closing device\n");
|
dev_dbg(d);
|
||||||
|
dbg_puts(": closing device\n");
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
d->pstate = DEV_CLOSED;
|
||||||
if (d->mix) {
|
if (d->mix) {
|
||||||
/*
|
/*
|
||||||
* Put the mixer in ``autoquit'' state and generate
|
* Put the mixer in ``autoquit'' state and generate
|
||||||
@ -643,7 +649,6 @@ dev_close(struct dev *d)
|
|||||||
aproc_del(d->midi);
|
aproc_del(d->midi);
|
||||||
d->midi = NULL;
|
d->midi = NULL;
|
||||||
}
|
}
|
||||||
d->pstate = DEV_CLOSED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -740,8 +745,10 @@ dev_stop(struct dev *d)
|
|||||||
struct file *f;
|
struct file *f;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (debug_level >= 2)
|
if (debug_level >= 2) {
|
||||||
dbg_puts("device stopped\n");
|
dev_dbg(d);
|
||||||
|
dbg_puts(": device stopped\n");
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
d->pstate = DEV_INIT;
|
d->pstate = DEV_INIT;
|
||||||
if (d->mode & MODE_LOOP)
|
if (d->mode & MODE_LOOP)
|
||||||
@ -765,8 +772,10 @@ int
|
|||||||
dev_ref(struct dev *d)
|
dev_ref(struct dev *d)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (debug_level >= 3)
|
if (debug_level >= 3) {
|
||||||
dbg_puts("device requested\n");
|
dev_dbg(d);
|
||||||
|
dbg_puts(": device requested\n");
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
if (d->pstate == DEV_CLOSED && !dev_open(d)) {
|
if (d->pstate == DEV_CLOSED && !dev_open(d)) {
|
||||||
if (d->hold)
|
if (d->hold)
|
||||||
@ -781,8 +790,10 @@ void
|
|||||||
dev_unref(struct dev *d)
|
dev_unref(struct dev *d)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (debug_level >= 3)
|
if (debug_level >= 3) {
|
||||||
dbg_puts("device released\n");
|
dev_dbg(d);
|
||||||
|
dbg_puts(": device released\n");
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
d->refcnt--;
|
d->refcnt--;
|
||||||
if (d->refcnt == 0 && d->pstate == DEV_INIT && !d->hold)
|
if (d->refcnt == 0 && d->pstate == DEV_INIT && !d->hold)
|
||||||
@ -811,8 +822,10 @@ dev_run(struct dev *d)
|
|||||||
((d->mode & MODE_REC) && !APROC_OK(d->sub)) ||
|
((d->mode & MODE_REC) && !APROC_OK(d->sub)) ||
|
||||||
((d->mode & MODE_MON) && !APROC_OK(d->submon))) {
|
((d->mode & MODE_MON) && !APROC_OK(d->submon))) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (debug_level >= 1)
|
if (debug_level >= 1) {
|
||||||
dbg_puts("device disappeared\n");
|
dev_dbg(d);
|
||||||
|
dbg_puts(": device disappeared\n");
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
if (d->hold) {
|
if (d->hold) {
|
||||||
dev_del(d);
|
dev_del(d);
|
||||||
@ -841,8 +854,10 @@ dev_run(struct dev *d)
|
|||||||
(!APROC_OK(d->midi) ||
|
(!APROC_OK(d->midi) ||
|
||||||
d->midi->u.ctl.tstate != CTL_RUN)) {
|
d->midi->u.ctl.tstate != CTL_RUN)) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (debug_level >= 3)
|
if (debug_level >= 3) {
|
||||||
dbg_puts("device idle, suspending\n");
|
dev_dbg(d);
|
||||||
|
dbg_puts(": device idle, suspending\n");
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
dev_stop(d);
|
dev_stop(d);
|
||||||
if (d->refcnt == 0 && !d->hold)
|
if (d->refcnt == 0 && !d->hold)
|
||||||
@ -966,7 +981,8 @@ dev_sync(struct dev *d, unsigned mode, struct abuf *ibuf, struct abuf *obuf)
|
|||||||
delta += d->sub->u.sub.lat;
|
delta += d->sub->u.sub.lat;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (debug_level >= 3) {
|
if (debug_level >= 3) {
|
||||||
dbg_puts("syncing device");
|
dev_dbg(d);
|
||||||
|
dbg_puts(": syncing device");
|
||||||
if (APROC_OK(d->mix)) {
|
if (APROC_OK(d->mix)) {
|
||||||
dbg_puts(", ");
|
dbg_puts(", ");
|
||||||
aproc_dbg(d->mix);
|
aproc_dbg(d->mix);
|
||||||
@ -1027,7 +1043,8 @@ dev_attach(struct dev *d, char *name, unsigned mode,
|
|||||||
if ((!APROC_OK(d->mix) && (mode & MODE_PLAY)) ||
|
if ((!APROC_OK(d->mix) && (mode & MODE_PLAY)) ||
|
||||||
(!APROC_OK(d->sub) && (mode & MODE_REC)) ||
|
(!APROC_OK(d->sub) && (mode & MODE_REC)) ||
|
||||||
(!APROC_OK(d->submon) && (mode & MODE_MON))) {
|
(!APROC_OK(d->submon) && (mode & MODE_MON))) {
|
||||||
dbg_puts("mode beyond device mode, not attaching\n");
|
dev_dbg(d);
|
||||||
|
dbg_puts(": mode beyond device mode, not attaching\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -1202,7 +1219,8 @@ dev_clear(struct dev *d)
|
|||||||
if (APROC_OK(d->mix)) {
|
if (APROC_OK(d->mix)) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (!LIST_EMPTY(&d->mix->ins)) {
|
if (!LIST_EMPTY(&d->mix->ins)) {
|
||||||
dbg_puts("play end not idle, can't clear device\n");
|
dev_dbg(d);
|
||||||
|
dbg_puts(": play end not idle, can't clear device\n");
|
||||||
dbg_panic();
|
dbg_panic();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -1216,7 +1234,8 @@ dev_clear(struct dev *d)
|
|||||||
if (APROC_OK(d->sub)) {
|
if (APROC_OK(d->sub)) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (!LIST_EMPTY(&d->sub->outs)) {
|
if (!LIST_EMPTY(&d->sub->outs)) {
|
||||||
dbg_puts("record end not idle, can't clear device\n");
|
dev_dbg(d);
|
||||||
|
dbg_puts(": record end not idle, can't clear device\n");
|
||||||
dbg_panic();
|
dbg_panic();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -1230,7 +1249,8 @@ dev_clear(struct dev *d)
|
|||||||
if (APROC_OK(d->submon)) {
|
if (APROC_OK(d->submon)) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (!LIST_EMPTY(&d->submon->outs)) {
|
if (!LIST_EMPTY(&d->submon->outs)) {
|
||||||
dbg_puts("monitoring end not idle, can't clear device\n");
|
dev_dbg(d);
|
||||||
|
dbg_puts(": monitoring end not idle, can't clear device\n");
|
||||||
dbg_panic();
|
dbg_panic();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user