Index: app_waitforsilence.c =================================================================== RCS file: /usr/cvsroot/asterisk/apps/app_waitforsilence.c,v retrieving revision 1.4 diff -u -r1.4 app_waitforsilence.c --- app_waitforsilence.c 21 Jan 2005 07:06:24 -0000 1.4 +++ app_waitforsilence.c 11 Mar 2005 17:18:14 -0000 @@ -43,7 +43,7 @@ LOCAL_USER_DECL; -static int do_waiting(struct ast_channel *chan, int duration) { +static int do_waiting(struct ast_channel *chan, int maxsilence) { struct ast_frame *f; int totalsilence = 0; @@ -96,10 +96,10 @@ totalsilence = dspsilence; else totalsilence = 0; - /* ast_verbose(VERBOSE_PREFIX_3 "dspsilence: %d, totalsilence: %d\n", dspsilence, totalsilence); */ - if (totalsilence >= duration) { - ast_verbose(VERBOSE_PREFIX_3 "exiting with %d silence > %d required\n", totalsilence, duration); + if (totalsilence >= maxsilence) { + if (option_verbose > 2) + ast_verbose(VERBOSE_PREFIX_3 "Exiting with %dms silence > %dms required\n", totalsilence, maxsilence); /* Ended happily with silence */ ast_frfree(f); gotsilence = 1; @@ -108,29 +108,33 @@ } ast_frfree(f); } + if (ast_set_read_format(chan, rfmt)) { + ast_log(LOG_WARNING, "Unable to restore format %s to channel '%s'\n", ast_getformatname(rfmt), chan->name); + } ast_dsp_free(sildet); return gotsilence; } static int waitforsilence_exec(struct ast_channel *chan, void *data) { - int res=1; + int res = 1; struct localuser *u; - int duration = 1000; + int maxsilence = 1000; int iterations = 1, i; res = ast_answer(chan); /* Answer the channel */ - if (!data || ((sscanf(data, "%d|%d", &duration, &iterations) != 2) && - (sscanf(data, "%d", &duration) != 1))) { + if (!data || ((sscanf(data, "%d|%d", &maxsilence, &iterations) != 2) && + (sscanf(data, "%d", &maxsilence) != 1))) { ast_log(LOG_WARNING, "Using default value of 1000ms, 1 iteration\n"); } - ast_verbose(VERBOSE_PREFIX_3 "Waiting %d time(s) for %d ms silence\n", iterations, duration); + if (option_verbose > 2) + ast_verbose(VERBOSE_PREFIX_3 "Waiting %d time(s) for %d ms silence\n", iterations, maxsilence); LOCAL_USER_ADD(u); res = 1; - for ( i=0; (i 0)