Index: app.c =================================================================== --- app.c (revision 25404) +++ app.c (working copy) @@ -566,6 +566,7 @@ int rfmt = 0; struct ast_silence_generator *silgen = NULL; char prependfile[80]; + int no_audio = 0; if (silencethreshold < 0) silencethreshold = global_silence_threshold; @@ -659,10 +660,13 @@ 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); + no_audio = MAX(maxsilence, 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; } } @@ -761,6 +765,10 @@ ast_channel_stop_silence_generator(chan, silgen); } *duration = end - start; + if (no_audio) { + *duration -= no_audio / 1000; + *duration = MAX(*duration, 0); /* just to make sure it does not get negative */ + } if (!prepend) { for (x = 0; x < fmtcnt; x++) {