aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/input/ipaccess.c
diff options
context:
space:
mode:
authorAndreas Eversberg <Andreas.Eversberg@versatel.de>2009-10-08 12:53:16 +0200
committerHarald Welte <laforge@gnumonks.org>2009-10-08 12:53:16 +0200
commit38ae5cb2c20a0088aa6a38caebab7019b3f24de9 (patch)
treee174d81d4f803abf9477ae5cca8c1ab3a7169931 /openbsc/src/input/ipaccess.c
parent736f65d16d96da520c5dc6b27c66a549b10d8ff7 (diff)
use tx delay timer instead of usleep() in ip.access input driver
this fixes the delay of audio caused by stalling of the openbsc process. the use of 'usleep(100000)' for slowing down transmission to nanoBTS is replaced by the tx-delay timer. i did this on bs11 code, so i did it the same way. it actually queues frames for transmission not nanoBTS. on transmission a timer is started and when this timer expires, the next frame in the queue is transmitted (timer restarted) until the queue is empty.
Diffstat (limited to 'openbsc/src/input/ipaccess.c')
-rw-r--r--openbsc/src/input/ipaccess.c33
1 files changed, 24 insertions, 9 deletions
diff --git a/openbsc/src/input/ipaccess.c b/openbsc/src/input/ipaccess.c
index 40891ae1b..2239cf152 100644
--- a/openbsc/src/input/ipaccess.c
+++ b/openbsc/src/input/ipaccess.c
@@ -379,6 +379,21 @@ void ipaccess_prepend_header(struct msgb *msg, int proto)
hh->proto = proto;
}
+static int ts_want_write(struct e1inp_ts *e1i_ts)
+{
+ e1i_ts->driver.ipaccess.fd.when |= BSC_FD_WRITE;
+
+ return 0;
+}
+
+static void timeout_ts1_write(void *data)
+{
+ struct e1inp_ts *e1i_ts = (struct e1inp_ts *)data;
+
+ /* trigger write of ts1, due to tx delay timer */
+ ts_want_write(e1i_ts);
+}
+
static int handle_ts1_write(struct bsc_fd *bfd)
{
struct e1inp_line *line = bfd->data;
@@ -389,10 +404,12 @@ static int handle_ts1_write(struct bsc_fd *bfd)
u_int8_t proto;
int ret;
+ bfd->when &= ~BSC_FD_WRITE;
+
/* get the next msg for this timeslot */
msg = e1inp_tx_ts(e1i_ts, &sign_link);
if (!msg) {
- bfd->when &= ~BSC_FD_WRITE;
+ /* no message after tx delay timer */
return 0;
}
@@ -405,6 +422,7 @@ static int handle_ts1_write(struct bsc_fd *bfd)
break;
default:
msgb_free(msg);
+ bfd->when |= BSC_FD_WRITE; /* come back for more msg */
return -EINVAL;
}
@@ -416,7 +434,11 @@ static int handle_ts1_write(struct bsc_fd *bfd)
ret = send(bfd->fd, msg->data, msg->len, 0);
msgb_free(msg);
- usleep(100000);
+
+ /* set tx delay timer for next event */
+ e1i_ts->sign.tx_timer.cb = timeout_ts1_write;
+ e1i_ts->sign.tx_timer.data = e1i_ts;
+ bsc_schedule_timer(&e1i_ts->sign.tx_timer, 0, 100000);
return ret;
}
@@ -447,13 +469,6 @@ static int ipaccess_fd_cb(struct bsc_fd *bfd, unsigned int what)
}
-static int ts_want_write(struct e1inp_ts *e1i_ts)
-{
- e1i_ts->driver.ipaccess.fd.when |= BSC_FD_WRITE;
-
- return 0;
-}
-
struct e1inp_driver ipaccess_driver = {
.name = "ip.access",
.want_write = ts_want_write,