comparison 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
comparison
equal deleted inserted replaced
25:45411b72b6b3 26:237687e2be6c
10 #include <unistd.h> 10 #include <unistd.h>
11 11
12 #include <osmocom/core/msgb.h> 12 #include <osmocom/core/msgb.h>
13 #include <osmocom/core/select.h> 13 #include <osmocom/core/select.h>
14 #include <osmocom/isdn/i460_mux.h> 14 #include <osmocom/isdn/i460_mux.h>
15 #include <osmocom/trau/trau_frame.h>
15 16
16 #include "globals.h" 17 #include "globals.h"
17 #include "submux.h" 18 #include "submux.h"
19 #include "out_frame.h"
18 20
19 void init_trau_ul_frame(int nr) 21 void init_trau_ul_frame(int nr)
20 { 22 {
21 struct ater_subslot *at = &subslots[nr]; 23 struct ater_subslot *at = &subslots[nr];
22 struct osmo_trau_frame *fr = &at->ul_frame; 24 struct osmo_trau_frame *fr = &at->ul_frame;
26 memset(fr->c_bits + 5, 0, 6); 28 memset(fr->c_bits + 5, 0, 6);
27 memset(fr->c_bits + 15, 1, 6); 29 memset(fr->c_bits + 15, 1, 6);
28 memset(fr->t_bits, 1, 4); 30 memset(fr->t_bits, 1, 4);
29 } 31 }
30 32
33 static void handle_play(struct ater_subslot *at)
34 {
35 if (at->play_wait_align) {
36 if (at->mfrm_count)
37 return;
38 at->play_wait_align = false;
39 }
40 trau_frame_from_record(at->play_buffer + at->play_buf_ptr * 34,
41 at->is_efr, &at->ul_frame);
42 at->play_buf_ptr++;
43 if (at->play_buf_ptr < at->play_buf_total)
44 return;
45 free(at->play_buffer);
46 at->play_buffer = NULL;
47 }
48
31 static void tx_service_subslot(int nr) 49 static void tx_service_subslot(int nr)
32 { 50 {
33 struct ater_subslot *at = &subslots[nr]; 51 struct ater_subslot *at = &subslots[nr];
34 struct osmo_trau_frame *fr = &at->ul_frame; 52 struct osmo_trau_frame *fr = &at->ul_frame;
35 struct msgb *msg; 53 struct msgb *msg;
36 int len; 54 int len;
37 55
38 if (!at->is_active) 56 if (!at->is_active)
39 return; 57 return;
58 if (at->play_buffer)
59 handle_play(at);
40 at->mfrm_count++; 60 at->mfrm_count++;
41 if (at->mfrm_count >= 24) { 61 if (at->mfrm_count >= 24) {
42 at->mfrm_count = 0; 62 at->mfrm_count = 0;
43 fr->c_bits[14] = 1; 63 fr->c_bits[14] = 1;
44 } else { 64 } else {