version 1.5, 2008/06/02 17:06:36 |
version 1.6, 2008/08/14 09:39:16 |
|
|
* convers anything to 16bit signed) and one for the output (that |
* convers anything to 16bit signed) and one for the output (that |
* converts 16bit signed to anything) |
* converts 16bit signed to anything) |
* |
* |
* (hard) handle underruns in rpipe and mix |
|
* |
|
* (hard) handle overruns in wpipe and sub |
|
* |
|
* (hard) add a lowpass filter for the resampler. Quality is |
* (hard) add a lowpass filter for the resampler. Quality is |
* not acceptable as is. |
* not acceptable as is. |
*/ |
*/ |
|
|
unsigned char *data; |
unsigned char *data; |
unsigned count; |
unsigned count; |
|
|
|
DPRINTFN(3, "rpipe_in: %s\n", p->name); |
|
|
if (ABUF_FULL(obuf)) |
if (ABUF_FULL(obuf)) |
return 0; |
return 0; |
data = abuf_wgetblk(obuf, &count, 0); |
data = abuf_wgetblk(obuf, &count, 0); |
obuf->used += file_read(f, data, count); |
count = file_read(f, data, count); |
|
abuf_wcommit(obuf, count); |
abuf_flush(obuf); |
abuf_flush(obuf); |
return !ABUF_FULL(obuf); |
return !ABUF_FULL(obuf); |
} |
} |
|
|
unsigned char *data; |
unsigned char *data; |
unsigned count; |
unsigned count; |
|
|
|
DPRINTFN(3, "rpipe_out: %s\n", p->name); |
|
|
if (!(f->state & FILE_ROK)) |
if (!(f->state & FILE_ROK)) |
return 0; |
return 0; |
data = abuf_wgetblk(obuf, &count, 0); |
data = abuf_wgetblk(obuf, &count, 0); |
obuf->used += file_read(f, data, count); |
count = file_read(f, data, count); |
|
abuf_wcommit(obuf, count); |
return f->state & FILE_ROK; |
return f->state & FILE_ROK; |
} |
} |
|
|
|
|
unsigned char *data; |
unsigned char *data; |
unsigned count; |
unsigned count; |
|
|
|
DPRINTFN(3, "wpipe_in: %s\n", p->name); |
|
|
if (!(f->state & FILE_WOK)) |
if (!(f->state & FILE_WOK)) |
return 0; |
return 0; |
|
|
data = abuf_rgetblk(ibuf, &count, 0); |
data = abuf_rgetblk(ibuf, &count, 0); |
count = file_write(f, data, count); |
count = file_write(f, data, count); |
ibuf->used -= count; |
abuf_rdiscard(ibuf, count); |
ibuf->start += count; |
|
if (ibuf->start >= ibuf->len) |
|
ibuf->start -= ibuf->len; |
|
return f->state & FILE_WOK; |
return f->state & FILE_WOK; |
} |
} |
|
|
|
|
unsigned char *data; |
unsigned char *data; |
unsigned count; |
unsigned count; |
|
|
|
DPRINTFN(3, "wpipe_out: %s\n", p->name); |
|
|
if (ABUF_EMPTY(ibuf)) |
if (ABUF_EMPTY(ibuf)) |
return 0; |
return 0; |
data = abuf_rgetblk(ibuf, &count, 0); |
data = abuf_rgetblk(ibuf, &count, 0); |
count = file_write(f, data, count); |
count = file_write(f, data, count); |
ibuf->used -= count; |
abuf_rdiscard(ibuf, count); |
ibuf->start += count; |
|
if (ibuf->start >= ibuf->len) |
|
ibuf->start -= ibuf->len; |
|
if (ABUF_EOF(ibuf)) { |
if (ABUF_EOF(ibuf)) { |
abuf_hup(ibuf); |
abuf_hup(ibuf); |
wpipe_del(p); |
wpipe_del(p); |
|
|
short *odata; |
short *odata; |
unsigned ocount; |
unsigned ocount; |
|
|
DPRINTFN(4, "mix_bzero: used = %u, zero = %u\n", |
DPRINTFN(4, "mix_bzero: used = %u, todo = %u\n", |
obuf->used, obuf->mixtodo); |
obuf->used, obuf->mixtodo); |
odata = (short *)abuf_wgetblk(obuf, &ocount, obuf->mixtodo); |
odata = (short *)abuf_wgetblk(obuf, &ocount, obuf->mixtodo); |
if (ocount == 0) |
if (ocount == 0) |
|
|
unsigned i, scount, icount, ocount; |
unsigned i, scount, icount, ocount; |
int vol = ibuf->mixvol; |
int vol = ibuf->mixvol; |
|
|
DPRINTFN(4, "mix_badd: zero = %u, done = %u\n", |
DPRINTFN(4, "mix_badd: todo = %u, done = %u\n", |
obuf->mixtodo, ibuf->mixdone); |
obuf->mixtodo, ibuf->mixdone); |
|
|
idata = (short *)abuf_rgetblk(ibuf, &icount, 0); |
idata = (short *)abuf_rgetblk(ibuf, &icount, 0); |
|
|
*odata += (*idata * vol) >> ADATA_SHIFT; |
*odata += (*idata * vol) >> ADATA_SHIFT; |
idata++; |
idata++; |
odata++; |
odata++; |
} |
} |
|
abuf_rdiscard(ibuf, scount); |
ibuf->used -= scount; |
|
ibuf->mixdone += scount; |
ibuf->mixdone += scount; |
ibuf->start += scount; |
|
if (ibuf->start >= ibuf->len) |
|
ibuf->start -= ibuf->len; |
|
|
|
DPRINTFN(4, "mix_badd: added %u, done = %u, zero = %u\n", |
DPRINTFN(4, "mix_badd: added %u, done = %u, todo = %u\n", |
scount, ibuf->mixdone, obuf->mixtodo); |
scount, ibuf->mixdone, obuf->mixtodo); |
} |
} |
|
|
|
|
if (ocount == 0) |
if (ocount == 0) |
return 0; |
return 0; |
|
|
obuf->used += ocount; |
abuf_wcommit(obuf, ocount); |
obuf->mixtodo -= ocount; |
obuf->mixtodo -= ocount; |
abuf_flush(obuf); |
abuf_flush(obuf); |
mix_bzero(p); |
mix_bzero(p); |
|
|
struct abuf *i, *inext; |
struct abuf *i, *inext; |
unsigned ocount, drop; |
unsigned ocount, drop; |
|
|
DPRINTFN(4, "mix_out: used = %u, zero = %u\n", |
DPRINTFN(4, "mix_out: used = %u, todo = %u\n", |
obuf->used, obuf->mixtodo); |
obuf->used, obuf->mixtodo); |
|
|
mix_bzero(p); |
mix_bzero(p); |
|
|
aproc_del(p); |
aproc_del(p); |
return 0; |
return 0; |
} |
} |
obuf->used += ocount; |
abuf_wcommit(obuf, ocount); |
obuf->mixtodo -= ocount; |
obuf->mixtodo -= ocount; |
LIST_FOREACH(i, &p->ibuflist, ient) { |
LIST_FOREACH(i, &p->ibuflist, ient) { |
i->mixdone -= ocount; |
i->mixdone -= ocount; |
|
|
return; |
return; |
scount = (icount < ocount) ? icount : ocount; |
scount = (icount < ocount) ? icount : ocount; |
memcpy(odata, idata, scount); |
memcpy(odata, idata, scount); |
|
abuf_wcommit(obuf, scount); |
obuf->subdone += scount; |
obuf->subdone += scount; |
obuf->used += scount; |
|
DPRINTFN(4, "sub_bcopy: %u bytes\n", scount); |
DPRINTFN(4, "sub_bcopy: %u bytes\n", scount); |
} |
} |
|
|
|
|
LIST_FOREACH(i, &p->obuflist, oent) { |
LIST_FOREACH(i, &p->obuflist, oent) { |
i->subdone -= done; |
i->subdone -= done; |
} |
} |
ibuf->used -= done; |
abuf_rdiscard(ibuf, done); |
ibuf->start += done; |
|
if (ibuf->start >= ibuf->len) |
|
ibuf->start -= ibuf->len; |
|
return again; |
return again; |
} |
} |
|
|
|
|
LIST_FOREACH(i, &p->obuflist, oent) { |
LIST_FOREACH(i, &p->obuflist, oent) { |
i->subdone -= done; |
i->subdone -= done; |
} |
} |
ibuf->used -= done; |
abuf_rdiscard(ibuf, done); |
ibuf->start += done; |
|
if (ibuf->start >= ibuf->len) |
|
ibuf->start -= ibuf->len; |
|
if (ABUF_EOF(ibuf)) { |
if (ABUF_EOF(ibuf)) { |
abuf_hup(ibuf); |
abuf_hup(ibuf); |
for (i = LIST_FIRST(&p->obuflist); |
for (i = LIST_FIRST(&p->obuflist); |
|
|
* Update FIFO pointers. |
* Update FIFO pointers. |
*/ |
*/ |
icount -= ifr * ist->bpf; |
icount -= ifr * ist->bpf; |
ibuf->used -= icount; |
|
ibuf->start += icount; |
|
if (ibuf->start >= ibuf->len) |
|
ibuf->start -= ibuf->len; |
|
|
|
ocount -= ofr * ost->bpf; |
ocount -= ofr * ost->bpf; |
obuf->used += ocount; |
abuf_rdiscard(ibuf, icount); |
|
abuf_wcommit(obuf, ocount); |
} |
} |
|
|
void |
void |