diff options
author | Kevin P. Fleming <kpfleming@digium.com> | 2009-08-06 16:07:15 +0000 |
---|---|---|
committer | Kevin P. Fleming <kpfleming@digium.com> | 2009-08-06 16:07:15 +0000 |
commit | eb449d514e5b50e8ea0cfae377d886b19223a801 (patch) | |
tree | 6bb2cd5db64ff2e200f64968d59383ee2feec7b1 /apps/app_fax.c | |
parent | 0eab85b39ed093a80eaf065c773a7cf6cba04dd6 (diff) |
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
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@210777 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'apps/app_fax.c')
-rw-r--r-- | apps/app_fax.c | 69 |
1 files changed, 36 insertions, 33 deletions
diff --git a/apps/app_fax.c b/apps/app_fax.c index 87ef18ed9..3d2117ddf 100644 --- a/apps/app_fax.c +++ b/apps/app_fax.c @@ -28,10 +28,8 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #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,25 +490,27 @@ static int transmit_audio(fax_session *s) 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; @@ -644,29 +644,32 @@ static int transmit_t38(fax_session *s) 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; @@ -714,7 +717,7 @@ static int transmit(fax_session *s) 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); |