mirror of https://github.com/ericonr/sndio.git
When the audio device is closed, mark it as closed before
dropping connections otherwise clients may try to drain their buffer and would attempt to reopen the device
This commit is contained in:
parent
2834345924
commit
ccdecf59c4
27
sndiod/dev.c
27
sndiod/dev.c
|
@ -78,8 +78,19 @@ unsigned int dev_sndnum = 0;
|
|||
void
|
||||
dev_log(struct dev *d)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
static char *pstates[] = {
|
||||
"cfg", "ini", "run"
|
||||
};
|
||||
#endif
|
||||
log_puts("snd");
|
||||
log_putu(d->num);
|
||||
#ifdef DEBUG
|
||||
if (log_level >= 3) {
|
||||
log_puts(" pst=");
|
||||
log_puts(pstates[d->pstate]);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1122,7 +1133,8 @@ dev_open(struct dev *d)
|
|||
void
|
||||
dev_close(struct dev *d)
|
||||
{
|
||||
struct slot *s, *snext;
|
||||
int i;
|
||||
struct slot *s;
|
||||
|
||||
#ifdef DEBUG
|
||||
if (log_level >= 3) {
|
||||
|
@ -1130,13 +1142,13 @@ dev_close(struct dev *d)
|
|||
log_puts(": closing\n");
|
||||
}
|
||||
#endif
|
||||
while ((s = d->slot_list) != NULL) {
|
||||
snext = s->next;
|
||||
d->pstate = DEV_CFG;
|
||||
for (s = d->slot, i = DEV_NSLOT; i > 0; i--, s++) {
|
||||
if (s->ops)
|
||||
s->ops->exit(s->arg);
|
||||
s->ops = NULL;
|
||||
d->slot_list = snext;
|
||||
}
|
||||
d->slot_list = NULL;
|
||||
dev_sio_close(d);
|
||||
if (d->mode & MODE_PLAY) {
|
||||
if (d->encbuf != NULL)
|
||||
|
@ -1149,7 +1161,6 @@ dev_close(struct dev *d)
|
|||
xfree(d->rbuf);
|
||||
}
|
||||
dev_clear(d);
|
||||
d->pstate = DEV_CFG;
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -1735,6 +1746,12 @@ slot_attach(struct slot *s)
|
|||
void
|
||||
slot_ready(struct slot *s)
|
||||
{
|
||||
/*
|
||||
* device may be disconnected, and if so we're called from
|
||||
* slot->ops->exit() on a closed device
|
||||
*/
|
||||
if (s->dev->pstate == DEV_CFG)
|
||||
return;
|
||||
if (s->tstate == MMC_OFF)
|
||||
slot_attach(s);
|
||||
else {
|
||||
|
|
Loading…
Reference in New Issue