-/* $OpenBSD: dev.c,v 1.104 2022/03/15 05:53:37 ratchov Exp $ */
+/* $OpenBSD: dev.c,v 1.105 2022/04/29 09:12:57 ratchov Exp $ */
/*
* Copyright (c) 2008-2012 Alexandre Ratchov <alex@caoua.org>
*
* check if the device is actually used. If it isn't,
* then close it
*/
- if (d->slot_list == NULL && (mtc_array[0].dev != d ||
- mtc_array[0].tstate != MTC_RUN)) {
+ if (d->slot_list == NULL && d->idle >= d->bufsz &&
+ (mtc_array[0].dev != d || mtc_array[0].tstate != MTC_RUN)) {
if (log_level >= 2) {
dev_log(d);
log_puts(": device stopped\n");
log_puts("\n");
}
#endif
+ d->idle = 0;
+
/*
* skip cycles for XRUN_SYNC correction
*/
d->delta += delta;
+ if (d->slot_list == NULL)
+ d->idle += delta;
+
for (s = d->slot_list; s != NULL; s = snext) {
/*
* s->ops->onmove() may remove the slot
} else {
d->prime = 0;
}
+ d->idle = 0;
d->poffs = 0;
/*
-/* $OpenBSD: dev.h,v 1.41 2021/11/01 14:43:25 ratchov Exp $ */
+/* $OpenBSD: dev.h,v 1.42 2022/04/29 09:12:57 ratchov Exp $ */
/*
* Copyright (c) 2008-2012 Alexandre Ratchov <alex@caoua.org>
*
unsigned int mode; /* bitmap of MODE_xxx */
unsigned int bufsz, round, rate;
unsigned int prime;
+ unsigned int idle; /* cycles with no client */
unsigned int master; /* software vol. knob */
unsigned int master_enabled; /* 1 if h/w has no vo. knob */