summaryrefslogtreecommitdiffstats
path: root/bchannel.c
diff options
context:
space:
mode:
authorschlaile2008-07-20 19:33:28 +0200
committerroot2008-07-20 19:33:28 +0200
commita114e74299f4708d96b490be055ab8939b9e7610 (patch)
tree3a787227e89e8f2a399e5a240eb1b24d5bf9b3fb /bchannel.c
parentremoved "lcr query", use "isdninfo" instead. (diff)
downloadlcr-a114e74299f4708d96b490be055ab8939b9e7610.tar.gz
lcr-a114e74299f4708d96b490be055ab8939b9e7610.tar.xz
lcr-a114e74299f4708d96b490be055ab8939b9e7610.zip
rebuffer option for chan_lcr (160 bytes per frame)
l1-link state "unknown" if not known yet. removed root user check. modified: bchannel.c modified: bchannel.h modified: chan_lcr.c modified: chan_lcr.h modified: dss1.cpp modified: lcradmin.c modified: mISDN.cpp modified: main.c
Diffstat (limited to 'bchannel.c')
-rw-r--r--bchannel.c58
1 files changed, 53 insertions, 5 deletions
diff --git a/bchannel.c b/bchannel.c
index 73ea2f8..346374b 100644
--- a/bchannel.c
+++ b/bchannel.c
@@ -195,6 +195,7 @@ void bchannel_activate(struct bchannel *bchannel, int activate)
CERROR(NULL, NULL, "Failed to send to socket %d\n", bchannel->b_sock);
bchannel->b_state = (activate)?BSTATE_ACTIVATING:BSTATE_DEACTIVATING;
+ bchannel->rebuffer_usage = 0;
}
@@ -249,6 +250,7 @@ void bchannel_destroy(struct bchannel *bchannel)
{
close(bchannel->b_sock);
bchannel->b_sock = -1;
+ bchannel->rebuffer_usage = 0;
}
bchannel->b_state = BSTATE_IDLE;
}
@@ -346,17 +348,63 @@ static void bchannel_receive(struct bchannel *bchannel, unsigned char *buffer, i
/* return, because we have no audio from port */
return;
}
- if (bchannel->call->pipe[1] > -1)
+
+ if (bchannel->call->pipe[1] < 0)
{
+ /* nobody there */
+ return;
+ }
+
+
+ if (bchannel->call->rebuffer) {
+ int u = bchannel->rebuffer_usage;
+ unsigned char * b = bchannel->rebuffer;
+ unsigned char * d = data;
+ int l = len;
+ int fd = bchannel->call->pipe[1];
+
+ if (u > 0) {
+ if (u + l >= 160) {
+ memcpy(b + u, d, 160 - u);
+ d += 160 - u;
+ l -= 160 - u;
+ u = 0;
+ if (write(fd, b, 160) < 0) {
+ goto errout;
+ }
+ } else {
+ memcpy(b + u, d, l);
+ u += l;
+ l = 0;
+ }
+ }
+
+ while (l >= 160) {
+ if (write(fd, d, 160) < 0) {
+ goto errout;
+ }
+ d += 160;
+ l -= 160;
+ }
+
+ if (l > 0) {
+ memcpy(b, d, l);
+ }
+ bchannel->rebuffer_usage = u + l;
+ } else {
len = write(bchannel->call->pipe[1], data, len);
if (len < 0)
{
- close(bchannel->call->pipe[1]);
- bchannel->call->pipe[1] = -1;
- CDEBUG(NULL, NULL, "broken pipe on bchannel pipe\n");
- return;
+ goto errout;
}
}
+
+ return;
+ errout:
+ close(bchannel->call->pipe[1]);
+ bchannel->call->pipe[1] = -1;
+ bchannel->rebuffer_usage = 0;
+ CDEBUG(NULL, NULL, "broken pipe on bchannel pipe\n");
}