From c9a23f6d78da2bf98d3784dc2ca74194e212800d Mon Sep 17 00:00:00 2001 From: "Kevin P. Fleming" Date: Mon, 26 Oct 2009 15:56:08 +0000 Subject: [PATCH] Backport audio handling loop fixes from trunk version of app_fax. This backport resolves some issues handling audio frames during FAX processing, and ensures that the FAX application doesn't accidentally get notified of a T.38 switchover at the end of a successful FAX. (closes issue #16127) git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.2@225871 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- apps/app_fax.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/apps/app_fax.c b/apps/app_fax.c index c4a1d42b64..17c75cf6b4 100644 --- a/apps/app_fax.c +++ b/apps/app_fax.c @@ -492,25 +492,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;