Index: app.c =================================================================== --- app.c (revision 19189) +++ app.c (working copy) @@ -554,6 +554,7 @@ int dspsilence = 0; int rfmt=0; struct ast_silence_generator *silgen = NULL; + int no_audio = 0; if (silencethreshold < 0) silencethreshold = global_silence_threshold; @@ -640,10 +641,16 @@ if (!res) { ast_log(LOG_DEBUG, "One waitfor failed, trying another\n"); /* Try one more time in case of masq */ - res = ast_waitfor(chan, 2000); + if (maxsilence > 2000) + no_audio = maxsilence; + else + no_audio = 4000; + res = ast_waitfor(chan, no_audio - 2000); if (!res) { ast_log(LOG_WARNING, "No audio available on %s??\n", chan->name); res = -1; + } else { + no_audio = 0; } } @@ -735,6 +742,8 @@ ast_channel_stop_silence_generator(chan, silgen); *duration = end - start; + if (no_audio && *duration >= no_audio / 1000) + *duration -= no_audio / 1000; for (x=0;x 2000) + no_audio = maxsilence; + else + no_audio = 4000; + res = ast_waitfor(chan, no_audio - 2000); if (!res) { ast_log(LOG_WARNING, "No audio available on %s??\n", chan->name); res = -1; + } else { + no_audio = 0; } } @@ -953,6 +969,8 @@ } ast_dsp_free(sildet); *duration = end - start; + if (no_audio && *duration >= no_audio / 1000) + *duration -= no_audio / 1000; #if 0 if (outmsg > 1) { #else