diff --git a/libs/spandsp/src/spandsp/t31.h b/libs/spandsp/src/spandsp/t31.h index 80a676b207..df842b0972 100644 --- a/libs/spandsp/src/spandsp/t31.h +++ b/libs/spandsp/src/spandsp/t31.h @@ -57,6 +57,12 @@ extern "C" SPAN_DECLARE(void) t31_call_event(t31_state_t *s, int event); +/*! Return the amount of free space in the AT COMMAND BUFFER. + \brief Return the amount of free space in the AT COMMAND BUFFER. + \param s The T.31 modem context. + \return The number of bytes of free space. */ +SPAN_DECLARE(int) t31_at_rx_free_space(t31_state_t *s); + SPAN_DECLARE(int) t31_at_rx(t31_state_t *s, const char *t, int len); /*! Process a block of received T.31 modem audio samples. diff --git a/libs/spandsp/src/spandsp/version.h b/libs/spandsp/src/spandsp/version.h index a07f2f061d..469cd37b08 100644 --- a/libs/spandsp/src/spandsp/version.h +++ b/libs/spandsp/src/spandsp/version.h @@ -28,9 +28,9 @@ /* The date and time of the version are in UTC form. */ -#define SPANDSP_RELEASE_DATE 20100724 +#define SPANDSP_RELEASE_DATE 20120902 #define SPANDSP_RELEASE_TIME 163333 -#define SPANDSP_RELEASE_DATETIME_STRING "20100724 163333" +#define SPANDSP_RELEASE_DATETIME_STRING "20120902 163333" #endif /*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/src/t31.c b/libs/spandsp/src/t31.c index 897bd066e3..8e747c4d0f 100644 --- a/libs/spandsp/src/t31.c +++ b/libs/spandsp/src/t31.c @@ -2180,6 +2180,12 @@ SPAN_DECLARE(void) t31_call_event(t31_state_t *s, int event) } /*- End of function --------------------------------------------------------*/ +SPAN_DECLARE(int) t31_at_rx_free_space(t31_state_t *s) +{ + return T31_TX_BUF_LEN - (s->tx.in_bytes - s->tx.out_bytes) - 1; +} +/*- End of function --------------------------------------------------------*/ + SPAN_DECLARE(int) t31_at_rx(t31_state_t *s, const char *t, int len) { if (s->dte_data_timeout) @@ -2215,7 +2221,7 @@ SPAN_DECLARE(int) t31_at_rx(t31_state_t *s, const char *t, int len) if (s->tx.out_bytes) { /* Make room for new data in existing data buffer. */ - s->tx.in_bytes = &s->tx.data[s->tx.in_bytes] - &s->tx.data[s->tx.out_bytes]; + s->tx.in_bytes -= s->tx.out_bytes; memmove(&s->tx.data[0], &s->tx.data[s->tx.out_bytes], s->tx.in_bytes); s->tx.out_bytes = 0; } diff --git a/src/mod/applications/mod_spandsp/mod_spandsp_modem.c b/src/mod/applications/mod_spandsp/mod_spandsp_modem.c index f7fd57ba23..eb54c217aa 100644 --- a/src/mod/applications/mod_spandsp/mod_spandsp_modem.c +++ b/src/mod/applications/mod_spandsp/mod_spandsp_modem.c @@ -1279,7 +1279,7 @@ static void *SWITCH_THREAD_FUNC modem_thread(switch_thread_t *thread, void *obj) modem->last_event = switch_time_now(); } - avail = sizeof(buf) - modem->t31_state->tx.in_bytes + modem->t31_state->tx.out_bytes - 1; + avail = t31_at_rx_free_space(modem->t31_state); if (avail == 0) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Buffer Full, retrying....\n");