From d00caaaf96aaa4c0259fbc10145986b780f68268 Mon Sep 17 00:00:00 2001 From: Alexandre Ratchov Date: Mon, 17 Mar 2014 09:57:41 +0100 Subject: [PATCH] disable playing and monitoring at the same time and append slots using MODE_MON at the end of the slot list, so that data to monitor is produced (by other slots) before the monitoring slot is consuming it --- sndiod/dev.c | 22 +++++++++++++++++++--- sndiod/sock.c | 7 +++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/sndiod/dev.c b/sndiod/dev.c index 18b2758..0952adb 100644 --- a/sndiod/dev.c +++ b/sndiod/dev.c @@ -1617,6 +1617,7 @@ slot_setvol(struct slot *s, unsigned int vol) void slot_attach(struct slot *s) { + struct slot **ps; struct dev *d = s->dev; unsigned int slot_nch, dev_nch; long long pos; @@ -1660,12 +1661,27 @@ slot_attach(struct slot *s) #ifdef DEBUG if ((s->mode & d->mode) != s->mode) { slot_log(s); - log_puts(": mode beyond device mode, not attaching\n"); + log_puts(": mode beyond device mode\n"); panic(); } #endif - s->next = d->slot_list; - d->slot_list = s; + + /* + * attach slot to the list + */ + ps = &d->slot_list; + if (s->mode & MODE_MON) { + /* + * attach slot at the end of the list as other slots + * must be processed first to produce the data to + * monitor + */ + while (*ps != NULL) + ps = &(*ps)->next; + } + s->next = *ps; + *ps = s; + s->skip = 0; if (s->mode & MODE_PLAY) { slot_nch = s->mix.slot_cmax - s->mix.slot_cmin + 1; diff --git a/sndiod/sock.c b/sndiod/sock.c index c2d1eee..84fdd69 100644 --- a/sndiod/sock.c +++ b/sndiod/sock.c @@ -854,6 +854,13 @@ sock_hello(struct sock *f) mode |= MODE_MON; mode &= ~MODE_REC; } + if ((mode & MODE_MON) && (mode & MODE_PLAY)) { + if (log_level >= 1) { + sock_log(f); + log_puts(": cannot play and monitor\n"); + } + return 0; + } if ((mode & f->opt->mode) != mode) { if (log_level >= 1) { sock_log(f);