diff options
author | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2008-11-10 23:25:38 +0000 |
---|---|---|
committer | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2008-11-10 23:25:38 +0000 |
commit | 122ebd30c24a1bbcc01712945fe70a9507035d0e (patch) | |
tree | 9e208a9d9db736070d535889a5ccfa6cd1475221 /usr.bin/aucat/dev.c | |
parent | 826857ad8597b5c1726eb93815778835b5322a00 (diff) |
add a per-stream ``soft volume'' knob and the corresponding -v option.
The code will be useful later for the volume knob in the sndio API.
Diffstat (limited to 'usr.bin/aucat/dev.c')
-rw-r--r-- | usr.bin/aucat/dev.c | 69 |
1 files changed, 50 insertions, 19 deletions
diff --git a/usr.bin/aucat/dev.c b/usr.bin/aucat/dev.c index 6c2d30a0159..d4c418ac118 100644 --- a/usr.bin/aucat/dev.c +++ b/usr.bin/aucat/dev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dev.c,v 1.13 2008/11/09 16:26:07 ratchov Exp $ */ +/* $OpenBSD: dev.c,v 1.14 2008/11/10 23:25:37 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -304,6 +304,41 @@ dev_stop(void) } /* + * find the end points connected to the mix/sub + */ +int +dev_getep(struct abuf **sibuf, struct abuf **sobuf) +{ + struct abuf *ibuf, *obuf; + + if (sibuf) { + ibuf = *sibuf; + for (;;) { + if (!ibuf || !ibuf->rproc) { + DPRINTF("dev_getep: reader desappeared\n"); + return 0; + } + if (ibuf->rproc == dev_mix) + break; + ibuf = LIST_FIRST(&ibuf->rproc->obuflist); + } + } + if (sobuf) { + obuf = *sobuf; + for (;;) { + if (!obuf || !obuf->wproc) { + DPRINTF("dev_getep: writer desappeared\n"); + return 0; + } + if (obuf->wproc == dev_sub) + break; + obuf = LIST_FIRST(&obuf->wproc->ibuflist); + } + } + return 1; +} + +/* * sync play buffer to rec buffer (for instance when one of * them underruns/overruns) */ @@ -321,24 +356,8 @@ dev_sync(struct abuf *ibuf, struct abuf *obuf) rbuf = LIST_FIRST(&dev_sub->ibuflist); if (!rbuf) return; - for (;;) { - if (!ibuf || !ibuf->rproc) { - DPRINTF("dev_sync: reader desappeared\n"); - return; - } - if (ibuf->rproc == dev_mix) - break; - ibuf = LIST_FIRST(&ibuf->rproc->obuflist); - } - for (;;) { - if (!obuf || !obuf->wproc) { - DPRINTF("dev_sync: writer desappeared\n"); - return; - } - if (obuf->wproc == dev_sub) - break; - obuf = LIST_FIRST(&obuf->wproc->ibuflist); - } + if (!dev_getep(&ibuf, &obuf)) + return; /* * calculate delta, the number of frames the play chain is ahead @@ -476,6 +495,18 @@ dev_attach(char *name, } /* + * change the playback volume of the fiven stream + */ +void +dev_setvol(struct abuf *ibuf, int vol) +{ + if (!dev_getep(&ibuf, NULL)) + return; + fprintf(stderr, "vol = %d\n", vol); + ibuf->mixvol = vol; +} + +/* * clear buffers of the play and record chains so that when the device * is started, playback and record start in sync */ |