aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2009-07-10 16:01:35 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2009-07-10 16:01:35 +0000
commit446efb864d569cf4d2e7cb71c291eaf1c381bda6 (patch)
tree7e767fa62931248f5dc0035b62038ad455bd2bd5 /apps
parentcada90ab1cc1c9fac5f4140607984de81361d770 (diff)
Merged revisions 205780 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk ........ r205780 | kpfleming | 2009-07-10 11:00:44 -0500 (Fri, 10 Jul 2009) | 11 lines Eliminate extraneous LOG_DEBUG messages generated by app_fax. The transmit_audio() and transmit_t38() functions in app_fax have processing loops that are supposed to wait for frames to arrive on the channel and then handle them, but they also have short timeouts so that the loops can have watchdog timers and do other required processing. This commit changes the loops to not actually call ast_read() and attempt to process the returned frame unless a frame actually arrived, eliminating hundreds of LOG_DEBUG messages and slightly improving performance. ........ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.2@205781 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps')
-rw-r--r--apps/app_fax.c75
1 files changed, 40 insertions, 35 deletions
diff --git a/apps/app_fax.c b/apps/app_fax.c
index 31a45cce4..46f8e4594 100644
--- a/apps/app_fax.c
+++ b/apps/app_fax.c
@@ -432,14 +432,28 @@ static int transmit_audio(fax_session *s)
ast_activate_generator(s->chan, &generator, &fax);
while (!s->finished) {
- res = ast_waitfor(s->chan, 20);
- if (res < 0)
+ inf = NULL;
+
+ if ((res = ast_waitfor(s->chan, 20)) < 0) {
break;
- else if (res > 0)
- res = 0;
+ }
+
+ /* 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;
+ }
+ }
- inf = ast_read(s->chan);
- if (inf == NULL) {
+ if (!(inf = ast_read(s->chan))) {
ast_debug(1, "Channel hangup\n");
res = -1;
break;
@@ -473,7 +487,7 @@ static int transmit_audio(fax_session *s)
/* Check the frame type. Format also must be checked because there is a chance
- that a frame in old format was already queued before we set chanel format
+ that a frame in old format was already queued before we set channel format
to slinear so it will still be received by ast_read */
if (inf->frametype == AST_FRAME_VOICE && inf->subclass == AST_FORMAT_SLINEAR) {
if (fax_rx(&fax, inf->data.ptr, inf->samples) < 0) {
@@ -482,8 +496,6 @@ static int transmit_audio(fax_session *s)
res = -1;
break;
}
-
- /* Watchdog */
if (last_state != t30state->state) {
state_change = ast_tvnow();
last_state = t30state->state;
@@ -517,15 +529,6 @@ static int transmit_audio(fax_session *s)
}
ast_frfree(inf);
- inf = NULL;
-
- /* 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;
- }
}
ast_debug(1, "Loop finished, res=%d\n", res);
@@ -617,19 +620,31 @@ static int transmit_t38(fax_session *s)
now = start = state_change = ast_tvnow();
while (!s->finished) {
-
- res = ast_waitfor(s->chan, 20);
- if (res < 0)
+ inf = NULL;
+ if ((res = ast_waitfor(s->chan, 20)) < 0) {
break;
- else if (res > 0)
- res = 0;
+ }
last_frame = now;
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;
+ }
+ }
+
t38_terminal_send_timeout(&t38, ast_tvdiff_us(now, last_frame) / (1000000 / 8000));
- inf = ast_read(s->chan);
- if (inf == NULL) {
+ if (!(inf = ast_read(s->chan))) {
ast_debug(1, "Channel hangup\n");
res = -1;
break;
@@ -639,8 +654,6 @@ static int transmit_t38(fax_session *s)
if (inf->frametype == AST_FRAME_MODEM && inf->subclass == AST_MODEM_T38) {
t38_core_rx_ifp_packet(t38state, inf->data.ptr, inf->datalen, inf->seqno);
-
- /* Watchdog */
if (last_state != t30state->state) {
state_change = ast_tvnow();
last_state = t30state->state;
@@ -654,14 +667,6 @@ static int transmit_t38(fax_session *s)
}
ast_frfree(inf);
- inf = NULL;
-
- /* Watchdog */
- 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;
- }
}
ast_debug(1, "Loop finished, res=%d\n", res);