=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/aucat/Attic/sock.c,v retrieving revision 1.34 retrieving revision 1.35 diff -u -r1.34 -r1.35 --- src/usr.bin/aucat/Attic/sock.c 2009/10/27 22:41:03 1.34 +++ src/usr.bin/aucat/Attic/sock.c 2009/11/03 21:31:37 1.35 @@ -1,4 +1,4 @@ -/* $OpenBSD: sock.c,v 1.34 2009/10/27 22:41:03 ratchov Exp $ */ +/* $OpenBSD: sock.c,v 1.35 2009/11/03 21:31:37 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov * @@ -54,9 +54,11 @@ void sock_setvol(void *, unsigned); +void sock_startreq(void *); struct ctl_ops ctl_sockops = { sock_setvol, + sock_startreq }; void @@ -300,10 +302,12 @@ struct abuf *rbuf, *wbuf; f->pstate = SOCK_INIT; + wbuf = LIST_FIRST(&f->pipe.file.wproc->ibuflist); rbuf = LIST_FIRST(&f->pipe.file.rproc->obuflist); + if (rbuf || wbuf) + ctl_slotstop(dev_midi, f->slot); if (rbuf) abuf_eof(rbuf); - wbuf = LIST_FIRST(&f->pipe.file.wproc->ibuflist); if (wbuf) abuf_hup(wbuf); f->tickpending = 0; @@ -328,7 +332,7 @@ f->delta = 0; f->tickpending = 0; f->pstate = SOCK_START; - if (!(f->mode & AMSG_PLAY)) + if (!(f->mode & AMSG_PLAY) && ctl_slotstart(dev_midi, f->slot)) (void)sock_attach(f, 0); } @@ -350,6 +354,17 @@ } /* + * Attach the stream. Callback invoked when MMC start + */ +void +sock_startreq(void *arg) +{ + struct sock *f = (struct sock *)arg; + + (void)sock_attach(f, 0); +} + +/* * Attach play and/or record buffers to dev_mix and/or dev_sub. */ int @@ -394,8 +409,10 @@ { switch (f->pstate) { case SOCK_START: - (void)sock_attach(f, 1); - f->pstate = SOCK_RUN; + if (ctl_slotstart(dev_midi, f->slot)) { + (void)sock_attach(f, 1); + f->pstate = SOCK_RUN; + } /* PASSTHROUGH */ case SOCK_RUN: sock_freebuf(f); @@ -599,6 +616,8 @@ return 0; } f->xrun = p->xrun; + if (f->opt->mmc && f->xrun == AMSG_IGNORE) + f->xrun = AMSG_SYNC; } if (AMSG_ISSET(p->bufsz)) { /* @@ -673,6 +692,8 @@ f->wpar = f->opt->wpar; if (dev_mix) f->rpar = f->opt->rpar; + if (f->opt->mmc) + f->xrun = AMSG_SYNC; if ((p->proto & ~(AMSG_PLAY | AMSG_REC)) != 0 || (p->proto & (AMSG_PLAY | AMSG_REC)) == 0) { return 0; @@ -691,7 +712,9 @@ f->mode |= AMSG_REC; } if (dev_midi) { - f->slot = ctl_slotnew(dev_midi, p->who, &ctl_sockops, f); + f->slot = ctl_slotnew(dev_midi, + p->who, &ctl_sockops, f, + f->opt->mmc); if (f->slot < 0) { return 0; } @@ -745,7 +768,8 @@ aproc_del(f->pipe.file.rproc); return 0; } - if (f->pstate == SOCK_START) + if (f->pstate == SOCK_START && + ctl_slotstart(dev_midi, f->slot)) (void)sock_attach(f, 1); sock_freebuf(f); AMSG_INIT(m); @@ -943,7 +967,10 @@ f->rstate = SOCK_RMSG; f->rtodo = sizeof(struct amsg); } - if (f->pstate == SOCK_START) + /* + * XXX: have to way that the buffer is full before starting + */ + if (f->pstate == SOCK_START && ctl_slotstart(dev_midi, f->slot)) (void)sock_attach(f, 0); break; case SOCK_RRET: