Implementation of C-Netz (German mobile telephone system)
This commit is contained in:
@@ -38,6 +38,7 @@ struct debug_cat {
|
||||
{ "dsp", "\033[0;31m" },
|
||||
{ "anetz", "\033[1;34m" },
|
||||
{ "bnetz", "\033[1;34m" },
|
||||
{ "cnetz", "\033[1;34m" },
|
||||
{ "nmt", "\033[1;34m" },
|
||||
{ "frame", "\033[0;36m" },
|
||||
{ "call", "\033[1;37m" },
|
||||
|
@@ -9,10 +9,11 @@
|
||||
#define DDSP 2
|
||||
#define DANETZ 3
|
||||
#define DBNETZ 4
|
||||
#define DNMT 5
|
||||
#define DFRAME 6
|
||||
#define DCALL 7
|
||||
#define DMNCC 8
|
||||
#define DCNETZ 5
|
||||
#define DNMT 6
|
||||
#define DFRAME 7
|
||||
#define DCALL 8
|
||||
#define DMNCC 9
|
||||
|
||||
#define PDEBUG(cat, level, fmt, arg...) _printdebug(__FILE__, __FUNCTION__, __LINE__, cat, level, fmt, ## arg)
|
||||
void _printdebug(const char *file, const char *function, int line, int cat, int level, const char *fmt, ...);
|
||||
|
@@ -1,3 +1,5 @@
|
||||
#ifndef _FILTER_H
|
||||
#define _FILTER_H
|
||||
|
||||
typedef struct biquad_low_pass {
|
||||
double a0, a1, a2, b1, b2;
|
||||
@@ -7,3 +9,4 @@ typedef struct biquad_low_pass {
|
||||
void biquad_init(biquad_low_pass_t *bq, double frequency, int samplerate);
|
||||
void biquad_process(biquad_low_pass_t *bq, double *samples, int length, int iterations);
|
||||
|
||||
#endif /* _FILTER_H */
|
||||
|
@@ -30,6 +30,7 @@
|
||||
|
||||
sender_t *sender_head = NULL;
|
||||
static sender_t **sender_tailp = &sender_head;
|
||||
int cant_recover = 0;
|
||||
|
||||
/* Init transceiver instance and link to list of transceivers. */
|
||||
int sender_create(sender_t *sender, const char *sounddev, int samplerate, int pre_emphasis, int de_emphasis, const char *write_wave, const char *read_wave, int kanal, int loopback, double loss_volume, int use_pilot_signal)
|
||||
@@ -139,7 +140,7 @@ static void gen_pilotton(sender_t *sender, int16_t *samples, int length)
|
||||
}
|
||||
|
||||
/* Handle audio streaming of one transceiver. */
|
||||
void process_sender(sender_t *sender, int latspl)
|
||||
void process_sender(sender_t *sender, int *quit, int latspl)
|
||||
{
|
||||
int16_t samples[latspl], pilot[latspl];
|
||||
int rc, count;
|
||||
@@ -147,8 +148,15 @@ void process_sender(sender_t *sender, int latspl)
|
||||
count = sound_get_inbuffer(sender->sound);
|
||||
if (count < 0) {
|
||||
PDEBUG(DSENDER, DEBUG_ERROR, "Failed to get samples in buffer (rc = %d)!\n", count);
|
||||
if (count == -EPIPE)
|
||||
if (count == -EPIPE) {
|
||||
if (cant_recover) {
|
||||
cant_recover:
|
||||
PDEBUG(DSENDER, DEBUG_ERROR, "Cannot recover due to measurements, quitting!\n");
|
||||
*quit = 1;
|
||||
return;
|
||||
}
|
||||
PDEBUG(DSENDER, DEBUG_ERROR, "Trying to recover!\n");
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (count < latspl) {
|
||||
@@ -189,8 +197,11 @@ void process_sender(sender_t *sender, int latspl)
|
||||
}
|
||||
if (rc < 0) {
|
||||
PDEBUG(DSENDER, DEBUG_ERROR, "Failed to write TX data to sound device (rc = %d)\n", rc);
|
||||
if (rc == -EPIPE)
|
||||
if (rc == -EPIPE) {
|
||||
if (cant_recover)
|
||||
goto cant_recover;
|
||||
PDEBUG(DSENDER, DEBUG_ERROR, "Trying to recover!\n");
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (sender->loopback == 1) {
|
||||
@@ -204,8 +215,11 @@ void process_sender(sender_t *sender, int latspl)
|
||||
//printf("count=%d time= %.4f\n", count, (double)count * 1000 / sender->samplerate);
|
||||
if (count < 0) {
|
||||
PDEBUG(DSENDER, DEBUG_ERROR, "Failed to read from sound device (rc = %d)!\n", count);
|
||||
if (count == -EPIPE)
|
||||
if (count == -EPIPE) {
|
||||
if (cant_recover)
|
||||
goto cant_recover;
|
||||
PDEBUG(DSENDER, DEBUG_ERROR, "Trying to recover!\n");
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (count) {
|
||||
@@ -236,7 +250,7 @@ void main_loop(int *quit, int latency)
|
||||
sender = sender_head;
|
||||
while (sender) {
|
||||
latspl = sender->samplerate * latency / 1000;
|
||||
process_sender(sender, latspl);
|
||||
process_sender(sender, quit, latspl);
|
||||
sender = sender->next;
|
||||
}
|
||||
|
||||
|
@@ -50,6 +50,7 @@ typedef struct sender {
|
||||
|
||||
/* list of all senders */
|
||||
extern sender_t *sender_head;
|
||||
extern int cant_recover;
|
||||
|
||||
int sender_create(sender_t *sender, const char *sounddev, int samplerate, int pre_emphasis, int de_emphasis, const char *write_wave, const char *read_wave, int kanal, int loopback, double loss_volume, int use_pilot_signal);
|
||||
void sender_destroy(sender_t *sender);
|
||||
|
@@ -249,7 +249,10 @@ int sound_get_inbuffer(void *inst)
|
||||
|
||||
rc = snd_pcm_delay(sound->phandle, &delay);
|
||||
if (rc < 0) {
|
||||
PDEBUG(DSOUND, DEBUG_ERROR, "failed to get delay from interface (%s)\n", snd_strerror(rc));
|
||||
if (rc == -32)
|
||||
PDEBUG(DSOUND, DEBUG_ERROR, "Buffer underrun: Please use higher latency and enable real time scheduling\n");
|
||||
else
|
||||
PDEBUG(DSOUND, DEBUG_ERROR, "failed to get delay from interface (%s)\n", snd_strerror(rc));
|
||||
if (rc == -EPIPE)
|
||||
snd_pcm_prepare(sound->phandle);
|
||||
return rc;
|
||||
|
Reference in New Issue
Block a user