From 285549a2fb5d6ff1dca3643acb509c24f8a21c75 Mon Sep 17 00:00:00 2001 From: Alexandre Ratchov Date: Fri, 2 Nov 2012 14:15:24 +0100 Subject: [PATCH] check that we run dev_cycle at block boundary --- sndiod/siofile.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/sndiod/siofile.c b/sndiod/siofile.c index 5207415..119d7fd 100644 --- a/sndiod/siofile.c +++ b/sndiod/siofile.c @@ -318,6 +318,19 @@ dev_sio_run(void *arg) d->sio.cstate = DEV_SIO_CYCLE; break; case DEV_SIO_CYCLE: +#ifdef DEBUG + /* + * check that we're called at cycle boundary: + * either after a recorded block, or when POLLOUT is + * raised + */ + if (!((d->mode & MODE_REC) && d->prime == 0) && + !(d->sio.events & POLLOUT)) { + dev_log(d); + log_puts(": cycle not at block boundary\n"); + panic(); + } +#endif dev_cycle(d); if (d->mode & MODE_PLAY) { d->sio.cstate = DEV_SIO_WRITE; @@ -331,7 +344,8 @@ dev_sio_run(void *arg) case DEV_SIO_WRITE: #ifdef DEBUG if (d->sio.todo == 0) { - log_puts("dev_sio_write: can't write data\n"); + dev_log(d); + log_puts(": can't write data\n"); panic(); } #endif