version 1.18, 2010/01/11 13:06:32 |
version 1.19, 2010/04/03 17:40:33 |
|
|
/* |
/* |
* fill fifo pointers |
* fill fifo pointers |
*/ |
*/ |
buf->len = len; |
buf->len = nfr; |
buf->used = 0; |
buf->used = 0; |
buf->start = 0; |
buf->start = 0; |
buf->abspos = 0; |
|
buf->silence = 0; |
|
buf->drop = 0; |
|
buf->rproc = NULL; |
buf->rproc = NULL; |
buf->wproc = NULL; |
buf->wproc = NULL; |
buf->duplex = NULL; |
buf->duplex = NULL; |
|
|
#endif |
#endif |
buf->used = 0; |
buf->used = 0; |
buf->start = 0; |
buf->start = 0; |
buf->abspos = 0; |
|
buf->silence = 0; |
|
buf->drop = 0; |
|
} |
} |
|
|
/* |
/* |
|
|
if (count > used) |
if (count > used) |
count = used; |
count = used; |
*rsize = count; |
*rsize = count; |
return (unsigned char *)buf + sizeof(struct abuf) + start; |
return (unsigned char *)buf + sizeof(struct abuf) + start * buf->bpf; |
} |
} |
|
|
/* |
/* |
|
|
buf->start += count; |
buf->start += count; |
if (buf->start >= buf->len) |
if (buf->start >= buf->len) |
buf->start -= buf->len; |
buf->start -= buf->len; |
buf->abspos += count; |
|
} |
} |
|
|
/* |
/* |
|
|
if (count > avail) |
if (count > avail) |
count = avail; |
count = avail; |
*rsize = count; |
*rsize = count; |
return (unsigned char *)buf + sizeof(struct abuf) + end; |
return (unsigned char *)buf + sizeof(struct abuf) + end * buf->bpf; |
} |
} |
|
|
/* |
/* |
|
|
abuf_flush_do(struct abuf *buf) |
abuf_flush_do(struct abuf *buf) |
{ |
{ |
struct aproc *p; |
struct aproc *p; |
unsigned count; |
|
|
|
if (buf->drop > 0) { |
p = buf->rproc; |
count = buf->drop; |
if (!p) |
if (count > buf->used) |
return 0; |
count = buf->used; |
|
if (count == 0) { |
|
#ifdef DEBUG |
#ifdef DEBUG |
if (debug_level >= 4) { |
if (debug_level >= 4) { |
abuf_dbg(buf); |
aproc_dbg(p); |
dbg_puts(": flush: no data to drop\n"); |
dbg_puts(": in\n"); |
} |
|
#endif |
|
return 0; |
|
} |
|
abuf_rdiscard(buf, count); |
|
buf->drop -= count; |
|
#ifdef DEBUG |
|
if (debug_level >= 4) { |
|
abuf_dbg(buf); |
|
dbg_puts(": flush: dropped "); |
|
dbg_putu(count); |
|
dbg_puts(", to drop = "); |
|
dbg_putu(buf->drop); |
|
dbg_puts("\n"); |
|
} |
|
#endif |
|
} else { |
|
p = buf->rproc; |
|
if (!p) |
|
return 0; |
|
#ifdef DEBUG |
|
if (debug_level >= 4) { |
|
aproc_dbg(p); |
|
dbg_puts(": in\n"); |
|
} |
|
#endif |
|
if (!p->ops->in(p, buf)) |
|
return 0; |
|
} |
} |
return 1; |
#endif |
|
return p->ops->in(p, buf); |
} |
} |
|
|
/* |
/* |
|
|
abuf_fill_do(struct abuf *buf) |
abuf_fill_do(struct abuf *buf) |
{ |
{ |
struct aproc *p; |
struct aproc *p; |
unsigned char *data; |
|
unsigned count; |
|
|
|
if (buf->silence > 0) { |
p = buf->wproc; |
data = abuf_wgetblk(buf, &count, 0); |
if (!p) |
if (count >= buf->silence) |
return 0; |
count = buf->silence; |
|
if (count == 0) { |
|
#ifdef DEBUG |
#ifdef DEBUG |
if (debug_level >= 4) { |
if (debug_level >= 4) { |
abuf_dbg(buf); |
aproc_dbg(p); |
dbg_puts(": fill: no space for silence\n"); |
dbg_puts(": out\n"); |
} |
|
#endif |
|
return 0; |
|
} |
|
memset(data, 0, count); |
|
abuf_wcommit(buf, count); |
|
buf->silence -= count; |
|
#ifdef DEBUG |
|
if (debug_level >= 4) { |
|
abuf_dbg(buf); |
|
dbg_puts(": fill: inerted "); |
|
dbg_putu(count); |
|
dbg_puts(", remaining silence = "); |
|
dbg_putu(buf->silence); |
|
dbg_puts("\n"); |
|
} |
|
#endif |
|
p = buf->wproc; |
|
} else { |
|
p = buf->wproc; |
|
if (!p) |
|
return 0; |
|
#ifdef DEBUG |
|
if (debug_level >= 4) { |
|
aproc_dbg(p); |
|
dbg_puts(": out\n"); |
|
} |
|
#endif |
|
if (!p->ops->out(p, buf)) { |
|
return 0; |
|
} |
|
} |
} |
return 1; |
#endif |
|
return p->ops->out(p, buf); |
} |
} |
|
|
/* |
/* |