Index: apps/app_fax.c =================================================================== --- apps/app_fax.c (revision 209097) +++ apps/app_fax.c (working copy) @@ -14,6 +14,7 @@ /*** MODULEINFO spandsp + yes ***/ #include "asterisk.h" @@ -28,10 +29,8 @@ #include #include +#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES #include -#ifdef HAVE_SPANDSP_EXPOSE_H -#include -#endif #include #include "asterisk/lock.h" @@ -434,25 +433,27 @@ 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"); res = -1; @@ -620,29 +621,32 @@ 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"); res = -1; @@ -690,7 +694,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);