version 1.32, 2009/07/25 08:44:27 |
version 1.33, 2009/07/25 10:52:18 |
|
|
#include <stdlib.h> |
#include <stdlib.h> |
#include <string.h> |
#include <string.h> |
|
|
#include "conf.h" |
|
#include "aparams.h" |
|
#include "abuf.h" |
#include "abuf.h" |
|
#include "aparams.h" |
#include "aproc.h" |
#include "aproc.h" |
|
#include "conf.h" |
#include "file.h" |
#include "file.h" |
|
|
struct aproc * |
struct aproc * |
|
|
|
|
/* |
/* |
* Append the given amount of silence (or less if there's not enough |
* Append the given amount of silence (or less if there's not enough |
* space), and crank mixitodo accordingly |
* space), and crank mixitodo accordingly. |
*/ |
*/ |
void |
void |
mix_bzero(struct abuf *obuf, unsigned zcount) |
mix_bzero(struct abuf *obuf, unsigned zcount) |
|
|
obuf->mixitodo, ibuf->mixodone); |
obuf->mixitodo, ibuf->mixodone); |
|
|
/* |
/* |
* calculate the maximum we can read |
* Calculate the maximum we can read. |
*/ |
*/ |
idata = (short *)abuf_rgetblk(ibuf, &icount, 0); |
idata = (short *)abuf_rgetblk(ibuf, &icount, 0); |
icount /= ibuf->bpf; |
icount /= ibuf->bpf; |
|
|
return; |
return; |
|
|
/* |
/* |
* zero-fill if necessary |
* Zero-fill if necessary. |
*/ |
*/ |
zcount = ibuf->mixodone + icount * obuf->bpf; |
zcount = ibuf->mixodone + icount * obuf->bpf; |
if (zcount > obuf->mixitodo) |
if (zcount > obuf->mixitodo) |
mix_bzero(obuf, zcount - obuf->mixitodo); |
mix_bzero(obuf, zcount - obuf->mixitodo); |
|
|
/* |
/* |
* calculate the maximum we can write |
* Calculate the maximum we can write. |
*/ |
*/ |
odata = (short *)abuf_wgetblk(obuf, &ocount, ibuf->mixodone); |
odata = (short *)abuf_wgetblk(obuf, &ocount, ibuf->mixodone); |
ocount /= obuf->bpf; |
ocount /= obuf->bpf; |
|
|
if (!aproc_inuse(p)) { |
if (!aproc_inuse(p)) { |
DPRINTF("mix_eof: %s: from input\n", p->name); |
DPRINTF("mix_eof: %s: from input\n", p->name); |
/* |
/* |
* find a blocked input |
* Find a blocked input. |
*/ |
*/ |
odone = obuf->len; |
odone = obuf->len; |
LIST_FOREACH(i, &p->ibuflist, ient) { |
LIST_FOREACH(i, &p->ibuflist, ient) { |
|
|
odone = i->mixodone; |
odone = i->mixodone; |
} |
} |
/* |
/* |
* no blocked inputs, check if output is blocked |
* No blocked inputs. Check if output is blocked. |
*/ |
*/ |
if (LIST_EMPTY(&p->ibuflist) || odone == obuf->mixitodo) |
if (LIST_EMPTY(&p->ibuflist) || odone == obuf->mixitodo) |
abuf_run(obuf); |
abuf_run(obuf); |
|
|
} |
} |
|
|
/* |
/* |
* Normalize input levels |
* Normalize input levels. |
*/ |
*/ |
void |
void |
mix_setmaster(struct aproc *p) |
mix_setmaster(struct aproc *p) |
|
|
} |
} |
|
|
/* |
/* |
* Handle buffer overruns, return 0 if the stream died |
* Handle buffer overruns. Return 0 if the stream died. |
*/ |
*/ |
int |
int |
sub_xrun(struct abuf *ibuf, struct abuf *i) |
sub_xrun(struct abuf *ibuf, struct abuf *i) |
|
|
if (!aproc_inuse(p)) { |
if (!aproc_inuse(p)) { |
DPRINTF("sub_hup: %s: from input\n", p->name); |
DPRINTF("sub_hup: %s: from input\n", p->name); |
/* |
/* |
* find a blocked output |
* Find a blocked output. |
*/ |
*/ |
idone = ibuf->len; |
idone = ibuf->len; |
LIST_FOREACH(i, &p->obuflist, oent) { |
LIST_FOREACH(i, &p->obuflist, oent) { |
|
|
idone = i->subidone; |
idone = i->subidone; |
} |
} |
/* |
/* |
* no blocked outputs, check if input is blocked |
* No blocked outputs. Check if input is blocked. |
*/ |
*/ |
if (LIST_EMPTY(&p->obuflist) || idone == ibuf->used) |
if (LIST_EMPTY(&p->obuflist) || idone == ibuf->used) |
abuf_run(ibuf); |
abuf_run(ibuf); |