comparison pcm-br/xconn.c @ 35:499d065ee591

new program itt-pcm-br (PCM bridge)
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 28 Aug 2024 05:00:38 +0000
parents pcm/read_ts.c@ca351324187a
children
comparison
equal deleted inserted replaced
34:f0b026615f3b 35:499d065ee591
1 /*
2 * The two functions in this module get called from Osmocom select loop
3 * whenever each timeslot data socket to osmo-e1d is ready for reading;
4 * the cross-connect of the two timeslots is implemented here.
5 */
6
7 #include <stdint.h>
8 #include <stdbool.h>
9 #include <stdio.h>
10 #include <stdlib.h>
11 #include <unistd.h>
12
13 #include <osmocom/core/select.h>
14
15 #include "globals.h"
16
17 uint8_t readbuf_a[160], readbuf_b[160];
18 FILE *rec_file_a, *rec_file_b;
19
20 int tsa_fd_cb(struct osmo_fd *ofd, unsigned int what)
21 {
22 int rc;
23
24 rc = read(tsa_fd, readbuf_a, 160);
25 if (rc != 160) {
26 fprintf(stderr,
27 "error: read from ts A returned %d instead of 160\n",
28 rc);
29 exit(1);
30 }
31 if (rec_file_a)
32 fwrite(readbuf_a, 1, 160, rec_file_a);
33 write(tsb_fd, readbuf_a, 160);
34 return 0;
35 }
36
37 int tsb_fd_cb(struct osmo_fd *ofd, unsigned int what)
38 {
39 int rc;
40
41 rc = read(tsb_fd, readbuf_b, 160);
42 if (rc != 160) {
43 fprintf(stderr,
44 "error: read from ts B returned %d instead of 160\n",
45 rc);
46 exit(1);
47 }
48 if (rec_file_b)
49 fwrite(readbuf_b, 1, 160, rec_file_b);
50 write(tsa_fd, readbuf_b, 160);
51 return 0;
52 }