[Asterisk-cvs] asterisk/apps app_waitforsilence.c,1.4,1.5

markster at lists.digium.com markster at lists.digium.com
Sat Mar 12 00:03:55 CST 2005


Update of /usr/cvsroot/asterisk/apps
In directory mongoose.digium.com:/tmp/cvs-serv17167/apps

Modified Files:
	app_waitforsilence.c 
Log Message:
Cleanup variable name, add restoration of format (bug #3759, with mods)


Index: app_waitforsilence.c
===================================================================
RCS file: /usr/cvsroot/asterisk/apps/app_waitforsilence.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- app_waitforsilence.c	21 Jan 2005 07:06:24 -0000	1.4
+++ app_waitforsilence.c	12 Mar 2005 06:00:05 -0000	1.5
@@ -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 (rfmt && 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<iterations) && (res == 1); i++) {
-		res = do_waiting(chan, duration);
+	for (i=0; (i<iterations) && (res == 1); i++) {
+		res = do_waiting(chan, maxsilence);
 	}
 	LOCAL_USER_REMOVE(u);
 	if (res > 0)




More information about the svn-commits mailing list