aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2009-07-10 16:00:44 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2009-07-10 16:00:44 +0000
commit321a959986833640413140884d3a092596e5700c (patch)
tree3d82911f97c87480ebc658019d5e7b48f1f222a7 /apps
parent477e9880b871c30776e114947e6f3e4074f53bd2 (diff)
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/trunk@205780 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 83ae2cded..6c132c162 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);