[asterisk-commits] kpfleming: trunk r210777 - in /trunk: ./ apps/ include/asterisk/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Aug 6 11:07:23 CDT 2009


Author: kpfleming
Date: Thu Aug  6 11:07:15 2009
New Revision: 210777

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=210777
Log:
Minor improvements to app_fax.

This patch makes some small changes to handle watchdog timeouts in a better way,
and also uses a 'cleaner' method of including the spandsp header files.

(closes issue #14769)
Reported by: andrew
Patches:
      app_fax-20090406.diff uploaded by andrew (license 240)
      v1-14769.patch uploaded by dimas (license 88)
Tested by: freh, deti, caspy, dimas, sgimeno, Dovid

Modified:
    trunk/apps/app_fax.c
    trunk/configure
    trunk/configure.ac
    trunk/include/asterisk/autoconfig.h.in

Modified: trunk/apps/app_fax.c
URL: http://svn.asterisk.org/svn-view/asterisk/trunk/apps/app_fax.c?view=diff&rev=210777&r1=210776&r2=210777
==============================================================================
--- trunk/apps/app_fax.c (original)
+++ trunk/apps/app_fax.c Thu Aug  6 11:07:15 2009
@@ -28,10 +28,8 @@
 #include <errno.h>
 #include <tiffio.h>
 
+#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
 #include <spandsp.h>
-#ifdef HAVE_SPANDSP_EXPOSE_H
-#include <spandsp/expose.h>
-#endif
 #include <spandsp/version.h>
 
 #include "asterisk/lock.h"
@@ -492,24 +490,26 @@
 	while (!s->finished) {
 		inf = NULL;
 
-		if ((res = ast_waitfor(s->chan, 20)) < 0) {
+		if ((res = ast_waitfor(s->chan, 25)) < 0) {
+			ast_debug(1, "Error waiting for a frame\n");
 			break;
 		}
 
-		/* if nothing arrived, check the watchdog timers */
-		if (res == 0) {
-			now = ast_tvnow();
-			if (ast_tvdiff_sec(now, start) > WATCHDOG_TOTAL_TIMEOUT || ast_tvdiff_sec(now, state_change) > WATCHDOG_STATE_TIMEOUT) {
-				ast_log(LOG_WARNING, "It looks like we hung. Aborting.\n");
-				res = -1;
-				break;
-			} else {
-				/* timers have not triggered, loop around to wait
-				 * again
-				 */
-				continue;
-			}
-		}
+		/* Watchdog */
+		now = ast_tvnow();
+		if (ast_tvdiff_sec(now, start) > WATCHDOG_TOTAL_TIMEOUT || ast_tvdiff_sec(now, state_change) > WATCHDOG_STATE_TIMEOUT) {
+			ast_log(LOG_WARNING, "It looks like we hung. Aborting.\n");
+			res = -1;
+			break;
+		}
+
+		if (!res) {
+			/* There was timeout waiting for a frame. Loop around and wait again */
+			continue;
+		}
+
+		/* There is a frame available. Get it */
+		res = 0;
 
 		if (!(inf = ast_read(s->chan))) {
 			ast_debug(1, "Channel hangup\n");
@@ -644,28 +644,31 @@
 
 	while (!s->finished) {
 		inf = NULL;
-		if ((res = ast_waitfor(s->chan, 20)) < 0) {
+
+		if ((res = ast_waitfor(s->chan, 25)) < 0) {
+			ast_debug(1, "Error waiting for a frame\n");
 			break;
 		}
 
 		last_frame = now;
+
+		/* Watchdog */
 		now = ast_tvnow();
-		/* if nothing arrived, check the watchdog timers */
-		if (res == 0) {
-			if (ast_tvdiff_sec(now, start) > WATCHDOG_TOTAL_TIMEOUT || ast_tvdiff_sec(now, state_change) > WATCHDOG_STATE_TIMEOUT) {
-				ast_log(LOG_WARNING, "It looks like we hung. Aborting.\n");
-				res = -1;
-				break;
-			} else {
-				/* timers have not triggered, loop around to wait
-				 * again
-				 */
-				t38_terminal_send_timeout(&t38, ast_tvdiff_us(now, last_frame) / (1000000 / 8000));
-				continue;
-			}
-		}
-
+		if (ast_tvdiff_sec(now, start) > WATCHDOG_TOTAL_TIMEOUT || ast_tvdiff_sec(now, state_change) > WATCHDOG_STATE_TIMEOUT) {
+			ast_log(LOG_WARNING, "It looks like we hung. Aborting.\n");
+			res = -1;
+			break;
+		}
+		
 		t38_terminal_send_timeout(&t38, ast_tvdiff_us(now, last_frame) / (1000000 / 8000));
+
+		if (!res) {
+			/* There was timeout waiting for a frame. Loop around and wait again */
+			continue;
+		}
+
+		/* There is a frame available. Get it */
+		res = 0;
 
 		if (!(inf = ast_read(s->chan))) {
 			ast_debug(1, "Channel hangup\n");
@@ -714,7 +717,7 @@
 
 	pbx_builtin_setvar_helper(s->chan, "FAXMODE", NULL);
 	pbx_builtin_setvar_helper(s->chan, "REMOTESTATIONID", NULL);
-	pbx_builtin_setvar_helper(s->chan, "FAXPAGES", NULL);
+	pbx_builtin_setvar_helper(s->chan, "FAXPAGES", "0");
 	pbx_builtin_setvar_helper(s->chan, "FAXRESOLUTION", NULL);
 	pbx_builtin_setvar_helper(s->chan, "FAXBITRATE", NULL); 
 

Modified: trunk/configure.ac
URL: http://svn.asterisk.org/svn-view/asterisk/trunk/configure.ac?view=diff&rev=210777&r1=210776&r2=210777
==============================================================================
--- trunk/configure.ac (original)
+++ trunk/configure.ac Thu Aug  6 11:07:15 2009
@@ -1488,10 +1488,6 @@
 	AST_EXT_LIB_CHECK([SPANDSP], [spandsp], [t38_terminal_init], [spandsp.h], [-ltiff])
 fi
 
-if test "x${PBX_SPANDSP}" = "x1" ; then
-	AC_CHECK_HEADER([spandsp/expose.h], [AC_DEFINE_UNQUOTED([HAVE_SPANDSP_EXPOSE_H], 1, [Define to 1 if spandsp/expose.h is available.])], [], [#include <spandsp.h>])
-fi
-
 AST_EXT_LIB_CHECK([SS7], [ss7], [ss7_pollflags], [libss7.h])
 
 AST_EXT_LIB_CHECK([OPENR2], [openr2], [openr2_chan_new], [openr2.h])

Modified: trunk/include/asterisk/autoconfig.h.in
URL: http://svn.asterisk.org/svn-view/asterisk/trunk/include/asterisk/autoconfig.h.in?view=diff&rev=210777&r1=210776&r2=210777
==============================================================================
--- trunk/include/asterisk/autoconfig.h.in (original)
+++ trunk/include/asterisk/autoconfig.h.in Thu Aug  6 11:07:15 2009
@@ -860,9 +860,6 @@
 /* Define this to indicate the ${SPANDSP_DESCRIP} library */
 #undef HAVE_SPANDSP
 
-/* Define to 1 if spandsp/expose.h is available. */
-#undef HAVE_SPANDSP_EXPOSE_H
-
 /* Define to indicate the ${SPANDSP_DESCRIP} library version */
 #undef HAVE_SPANDSP_VERSION
 
@@ -1295,9 +1292,6 @@
 /* Define to the version of this package. */
 #undef PACKAGE_VERSION
 
-/* Define to 1 if the C compiler supports function prototypes. */
-#undef PROTOTYPES
-
 /* Define to necessary symbol if this constant uses a non-standard name on
    your system. */
 #undef PTHREAD_CREATE_JOINABLE
@@ -1313,11 +1307,6 @@
 
 /* Define to the type of arg 5 for `select'. */
 #undef SELECT_TYPE_ARG5
-
-/* Define to 1 if the `setvbuf' function takes the buffering type as its
-   second argument and the buffer pointer as the third, as on System V before
-   release 3. */
-#undef SETVBUF_REVERSED
 
 /* The size of `int', as computed by sizeof. */
 #undef SIZEOF_INT
@@ -1339,20 +1328,30 @@
 /* Define to 1 if your <sys/time.h> declares `struct tm'. */
 #undef TM_IN_SYS_TIME
 
-/* Define to 1 if on AIX 3.
-   System headers sometimes define this.
-   We just want to avoid a redefinition error message.  */
+/* Enable extensions on AIX 3, Interix.  */
 #ifndef _ALL_SOURCE
 # undef _ALL_SOURCE
 #endif
-
-/* Number of bits in a file offset, on hosts where this is settable. */
-#undef _FILE_OFFSET_BITS
-
 /* Enable GNU extensions on systems that have them.  */
 #ifndef _GNU_SOURCE
 # undef _GNU_SOURCE
 #endif
+/* Enable threading extensions on Solaris.  */
+#ifndef _POSIX_PTHREAD_SEMANTICS
+# undef _POSIX_PTHREAD_SEMANTICS
+#endif
+/* Enable extensions on HP NonStop.  */
+#ifndef _TANDEM_SOURCE
+# undef _TANDEM_SOURCE
+#endif
+/* Enable general extensions on Solaris.  */
+#ifndef __EXTENSIONS__
+# undef __EXTENSIONS__
+#endif
+
+
+/* Number of bits in a file offset, on hosts where this is settable. */
+#undef _FILE_OFFSET_BITS
 
 /* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */
 #undef _LARGEFILE_SOURCE
@@ -1369,20 +1368,6 @@
 
 /* Define to 1 if you need to in order for `stat' and other things to work. */
 #undef _POSIX_SOURCE
-
-/* Enable extensions on Solaris.  */
-#ifndef __EXTENSIONS__
-# undef __EXTENSIONS__
-#endif
-#ifndef _POSIX_PTHREAD_SEMANTICS
-# undef _POSIX_PTHREAD_SEMANTICS
-#endif
-#ifndef _TANDEM_SOURCE
-# undef _TANDEM_SOURCE
-#endif
-
-/* Define like PROTOTYPES; this can be used by system headers. */
-#undef __PROTOTYPES
 
 /* Define to empty if `const' does not conform to ANSI C. */
 #undef const




More information about the asterisk-commits mailing list