Added a free space function to the T.31 modem in spandsp, so the app doesn't

need to probe around inside the modem.
This commit is contained in:
Steve Underwood 2012-09-04 08:58:43 +08:00
parent f3cd4f41a0
commit 7c6f6e306c
4 changed files with 16 additions and 4 deletions

View File

@ -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.

View File

@ -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 ------------------------------------------------------------*/

View File

@ -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;
}

View File

@ -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");