i460_mux: add callback to notify empty tx queue

There is no way for the API user to know if the TX queue of the
multiplexer runs empty. However, this is criticil since an empty TX
queue will cause dropout of a TRAU frame, which can have quite severe
effects to the receiving end. Lets add a callback that allows the APU
user to insert appropiate idle frames or silent frames into the queue
before it runs empty.

Change-Id: I88a87724235fe50d55ce6215bb385c044072226e
Related: OS#2547
diff --git a/src/gsm/i460_mux.c b/src/gsm/i460_mux.c
index 50cb56e..dfd50e5 100644
--- a/src/gsm/i460_mux.c
+++ b/src/gsm/i460_mux.c
@@ -175,9 +175,15 @@
 	ubit_t bit;
 
 	/* if we don't have anything to transmit, return '1' bits */
-	if (llist_empty(&mux->tx_queue))
-		return 0x01;
+	if (llist_empty(&mux->tx_queue)) {
+		/* User code now has a last chance to put something into the queue. */
+		if (mux->in_cb_queue_empty)
+			mux->in_cb_queue_empty(mux->user_data);
 
+		/* If the queue is still empty, return idle bits */
+		if (llist_empty(&mux->tx_queue))
+			return 0x01;
+	}
 	msg = llist_entry(mux->tx_queue.next, struct msgb, list);
 	bit = msgb_pull_u8(msg);
 
@@ -360,6 +366,8 @@
 	schan->demux.out_cb_bits = chd->demux.out_cb_bits;
 	schan->demux.out_cb_bytes = chd->demux.out_cb_bytes;
 	schan->demux.user_data = chd->demux.user_data;
+	schan->mux.in_cb_queue_empty = chd->mux.in_cb_queue_empty;
+	schan->mux.user_data = chd->mux.user_data;
 	rc = alloc_bitbuf(ctx, schan, chd->demux.num_bits);
 	if (rc < 0) {
 		subchan_reset(schan, false);