diff --git a/libs/spandsp/spandsp/tsb85.xml b/libs/spandsp/spandsp/tsb85.xml
index 8fa4502444..a711100916 100644
--- a/libs/spandsp/spandsp/tsb85.xml
+++ b/libs/spandsp/spandsp/tsb85.xml
@@ -5679,7 +5679,7 @@
-
+
@@ -5687,7 +5687,7 @@
-
+
@@ -5696,7 +5696,7 @@
-
+
@@ -5705,7 +5705,7 @@
-
+
@@ -5714,7 +5714,7 @@
-
+
@@ -5793,7 +5793,7 @@
-
+
@@ -5801,7 +5801,7 @@
-
+
diff --git a/libs/spandsp/src/dtmf.c b/libs/spandsp/src/dtmf.c
index fe235f45a1..48a8836337 100644
--- a/libs/spandsp/src/dtmf.c
+++ b/libs/spandsp/src/dtmf.c
@@ -68,8 +68,6 @@
#define DEFAULT_DTMF_TX_ON_TIME 50
#define DEFAULT_DTMF_TX_OFF_TIME 55
-#define DTMF_SAMPLES_PER_BLOCK 102
-
#if defined(SPANDSP_USE_FIXED_POINT)
/* The fixed point version scales the 16 bit signal down by 7 bits, so the Goertzels will fit in a 32 bit word */
#define FP_SCALE(x) ((int16_t) (x/128.0 + ((x >= 0.0) ? 0.5 : -0.5)))
@@ -80,6 +78,7 @@
#define DTMF_RELATIVE_PEAK_COL 6.309f /* 8dB [10.0^(8.0/10.0)] */
#define DTMF_TO_TOTAL_ENERGY 83.868f /* -0.85dB [DTMF_SAMPLES_PER_BLOCK*10^(-0.85/10.0)] */
#define DTMF_POWER_OFFSET 68.251f /* 10*log(((32768.0/128.0)^2)*DTMF_SAMPLES_PER_BLOCK) */
+#define DTMF_SAMPLES_PER_BLOCK 102
#else
#define FP_SCALE(x) (x)
#define DTMF_THRESHOLD 171032462.0f /* -42dBm0 [((DTMF_SAMPLES_PER_BLOCK*32768.0/1.4142)*10^((-42 - DBM0_MAX_SINE_POWER)/20.0))^2] */
@@ -89,6 +88,7 @@
#define DTMF_RELATIVE_PEAK_COL 6.309f /* 8dB [10.0^(8.0/10.0)] */
#define DTMF_TO_TOTAL_ENERGY 83.868f /* -0.85dB [DTMF_SAMPLES_PER_BLOCK*10^(-0.85/10.0)] */
#define DTMF_POWER_OFFSET 110.395f /* 10*log((32768.0^2)*DTMF_SAMPLES_PER_BLOCK) */
+#define DTMF_SAMPLES_PER_BLOCK 102
#endif
static const float dtmf_row[] =
@@ -604,7 +604,7 @@ SPAN_DECLARE(int) dtmf_tx_release(dtmf_tx_state_t *s)
SPAN_DECLARE(int) dtmf_tx_free(dtmf_tx_state_t *s)
{
- queue_release(&s->queue.queue);
+ dtmf_tx_release(s);
span_free(s);
return 0;
}
diff --git a/libs/spandsp/src/hdlc.c b/libs/spandsp/src/hdlc.c
index d96609b319..22589d3ed9 100644
--- a/libs/spandsp/src/hdlc.c
+++ b/libs/spandsp/src/hdlc.c
@@ -197,7 +197,7 @@ static void rx_flag_or_abort(hdlc_rx_state_t *s)
/* Check the flags are back-to-back when testing for valid preamble. This
greatly reduces the chances of false preamble detection, and anything
which doesn't send them back-to-back is badly broken. */
- if (s->num_bits != 7)
+ if (s->flags_seen != s->framing_ok_threshold - 1 && s->num_bits != 7)
{
/* Don't set the flags seen indicator back to zero too aggressively.
We want to pick up with the minimum of discarded data when there
diff --git a/libs/spandsp/src/t30.c b/libs/spandsp/src/t30.c
index 784a146c1c..bd24898b3e 100644
--- a/libs/spandsp/src/t30.c
+++ b/libs/spandsp/src/t30.c
@@ -152,7 +152,8 @@ static const char *phase_names[] =
/* These state names are modelled after places in the T.30 flow charts. */
enum
{
- T30_STATE_ANSWERING = 1,
+ T30_STATE_IDLE = 0,
+ T30_STATE_ANSWERING,
T30_STATE_B,
T30_STATE_C,
T30_STATE_D,
@@ -186,7 +187,7 @@ enum
static const char *state_names[] =
{
- "NONE",
+ "IDLE",
"ANSWERING",
"B",
"C",
@@ -6402,7 +6403,6 @@ SPAN_DECLARE(void) t30_front_end_status(void *user_data, int status)
/* Cancel any receive timeout, and declare that a receive signal is present,
since the front end is explicitly telling us we have seen something. */
s->rx_signal_present = true;
- timer_t2_t4_stop(s);
break;
}
break;
@@ -6593,6 +6593,7 @@ SPAN_DECLARE(int) t30_restart(t30_state_t *s, bool calling_party)
{
release_resources(s);
s->calling_party = calling_party;
+ s->state = T30_STATE_IDLE;
s->phase = T30_PHASE_IDLE;
s->next_phase = T30_PHASE_IDLE;
s->current_fallback = 0;
diff --git a/libs/spandsp/src/t38_gateway.c b/libs/spandsp/src/t38_gateway.c
index bb3d02e902..8233baedf6 100644
--- a/libs/spandsp/src/t38_gateway.c
+++ b/libs/spandsp/src/t38_gateway.c
@@ -58,6 +58,7 @@
#include "spandsp/alloc.h"
#include "spandsp/logging.h"
#include "spandsp/queue.h"
+#include "spandsp/vector_int.h"
#include "spandsp/dc_restore.h"
#include "spandsp/bit_operations.h"
#include "spandsp/power_meter.h"
@@ -149,7 +150,7 @@
#define DATA_END_TX_COUNT 3
/*! The number of consecutive flags to declare HDLC framing is OK. */
-#define HDLC_FRAMING_OK_THRESHOLD 5
+#define HDLC_FRAMING_OK_THRESHOLD 5
enum
{
@@ -700,7 +701,7 @@ static void monitor_control_messages(t38_gateway_state_t *s,
/* If we are processing a message from the modem side, the contents determine the fast receive modem.
we are to use. If it comes from the T.38 side the contents do not. */
s->core.fast_bit_rate = modem_codes[i].bit_rate;
- if (from_modem)
+ if ((buf[2] == T30_DTC && !from_modem) || (buf[2] != T30_DTC && from_modem))
s->core.fast_rx_modem = modem_codes[i].modem_type;
/*endif*/
}
@@ -1863,7 +1864,7 @@ static void rx_flag_or_abort(hdlc_rx_state_t *t)
/* Check the flags are back-to-back when testing for valid preamble. This
greatly reduces the chances of false preamble detection, and anything
which doesn't send them back-to-back is badly broken. */
- if (t->num_bits != 7)
+ if (t->flags_seen != t->framing_ok_threshold - 1 && t->num_bits != 7)
t->flags_seen = 0;
/*endif*/
if (++t->flags_seen >= t->framing_ok_threshold && !t->framing_ok_announced)
@@ -2070,15 +2071,15 @@ static void update_rx_timing(t38_gateway_state_t *s, int len)
{
case TIMED_MODE_TCF_PREDICTABLE_MODEM_START_PAST_V21_MODEM:
/* Timed announcement of training, 75ms after the DCS carrier fell. */
- s->core.timed_mode = TIMED_MODE_TCF_PREDICTABLE_MODEM_START_FAST_MODEM_ANNOUNCED;
announce_training(s);
+ s->core.timed_mode = TIMED_MODE_TCF_PREDICTABLE_MODEM_START_FAST_MODEM_ANNOUNCED;
break;
case TIMED_MODE_TCF_PREDICTABLE_MODEM_START_FAST_MODEM_SEEN:
/* Timed announcement of training, 75ms after the DCS carrier fell. */
+ announce_training(s);
/* Use a timeout to ride over TEP, if it is present */
s->core.samples_to_timeout = ms_to_samples(500);
s->core.timed_mode = TIMED_MODE_TCF_PREDICTABLE_MODEM_START_FAST_MODEM_ANNOUNCED;
- announce_training(s);
break;
case TIMED_MODE_TCF_PREDICTABLE_MODEM_START_FAST_MODEM_ANNOUNCED:
s->core.timed_mode = TIMED_MODE_IDLE;
@@ -2172,7 +2173,7 @@ SPAN_DECLARE_NONSTD(int) t38_gateway_tx(t38_gateway_state_t *s, int16_t amp[], i
if (s->audio.modems.transmit_on_idle)
{
/* Pad to the requested length with silence */
- memset(&[len], 0, (max_len - len)*sizeof(int16_t));
+ vec_zeroi16(&[len], max_len - len);
len = max_len;
}
/*endif*/
@@ -2180,7 +2181,7 @@ SPAN_DECLARE_NONSTD(int) t38_gateway_tx(t38_gateway_state_t *s, int16_t amp[], i
if (s->audio.modems.audio_tx_log >= 0)
{
if (len < required_len)
- memset(&[len], 0, (required_len - len)*sizeof(int16_t));
+ vec_zeroi16(&[len], required_len - len);
/*endif*/
write(s->audio.modems.audio_tx_log, amp, required_len*sizeof(int16_t));
}