diff ater/tx_func.c @ 26:237687e2be6c

ater: implement play internals
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 24 Jun 2024 20:15:42 +0000
parents 0d70444b5070
children 2742dbea95f1
line wrap: on
line diff
--- a/ater/tx_func.c	Mon Jun 24 18:56:05 2024 +0000
+++ b/ater/tx_func.c	Mon Jun 24 20:15:42 2024 +0000
@@ -12,9 +12,11 @@
 #include <osmocom/core/msgb.h>
 #include <osmocom/core/select.h>
 #include <osmocom/isdn/i460_mux.h>
+#include <osmocom/trau/trau_frame.h>
 
 #include "globals.h"
 #include "submux.h"
+#include "out_frame.h"
 
 void init_trau_ul_frame(int nr)
 {
@@ -28,6 +30,22 @@
 	memset(fr->t_bits, 1, 4);
 }
 
+static void handle_play(struct ater_subslot *at)
+{
+	if (at->play_wait_align) {
+		if (at->mfrm_count)
+			return;
+		at->play_wait_align = false;
+	}
+	trau_frame_from_record(at->play_buffer + at->play_buf_ptr * 34,
+				at->is_efr, &at->ul_frame);
+	at->play_buf_ptr++;
+	if (at->play_buf_ptr < at->play_buf_total)
+		return;
+	free(at->play_buffer);
+	at->play_buffer = NULL;
+}
+
 static void tx_service_subslot(int nr)
 {
 	struct ater_subslot *at = &subslots[nr];
@@ -37,6 +55,8 @@
 
 	if (!at->is_active)
 		return;
+	if (at->play_buffer)
+		handle_play(at);
 	at->mfrm_count++;
 	if (at->mfrm_count >= 24) {
 		at->mfrm_count = 0;