]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Added a free space function to the T.31 modem in spandsp, so the app doesn't
authorSteve Underwood <steveu@x100e.coppice.org>
Tue, 4 Sep 2012 00:58:43 +0000 (08:58 +0800)
committerSteve Underwood <steveu@x100e.coppice.org>
Tue, 4 Sep 2012 00:58:43 +0000 (08:58 +0800)
need to probe around inside the modem.

libs/spandsp/src/spandsp/t31.h
libs/spandsp/src/spandsp/version.h
libs/spandsp/src/t31.c
src/mod/applications/mod_spandsp/mod_spandsp_modem.c

index 80a676b20757e80d8a3b8c1d130c61ddf6eaeb14..df842b09726f3dfe8f740ec65ae2b972d60f30cd 100644 (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.
index a07f2f061deaeee8d781dff6c2bab0bad5fa49ab..469cd37b08c278f5567320f76da624bfa2bc1872 100644 (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 ------------------------------------------------------------*/
index 897bd066e3172092f9b79d0e5ebbf7517b8ddf37..8e747c4d0f2e56dd2e1d6ebcd95f8bc50f49a1a7 100644 (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;
         }
index f7fd57ba23688cf5a9dbbe23cb4b78ce1ade7aa9..eb54c217aabc12973c27a9d373202e8f5edeb80f 100644 (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");