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.
diff --git a/openbsc/src/input/ipaccess.c b/openbsc/src/input/ipaccess.c
index 40891ae..2239cf1 100644
--- a/openbsc/src/input/ipaccess.c
+++ b/openbsc/src/input/ipaccess.c
@@ -379,6 +379,21 @@
 	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 @@
 	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 @@
 		break;
 	default:
 		msgb_free(msg);
+		bfd->when |= BSC_FD_WRITE; /* come back for more msg */
 		return -EINVAL;
 	}
 
@@ -416,7 +434,11 @@
 
 	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 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,