[svn-commits] murf: trunk r44435 - in /trunk: ./ apps/ main/

svn-commits at lists.digium.com svn-commits at lists.digium.com
Wed Oct 4 18:40:06 MST 2006


Author: murf
Date: Wed Oct  4 20:40:06 2006
New Revision: 44435

URL: http://svn.digium.com/view/asterisk?rev=44435&view=rev
Log:
As per ToDo list, I have made it so that Wait(), WaitExten(), Congestion(), Busy(), Read(), WaitForRing(), will now either actually handle a floating point argument as advertised, or has been upgraded to accept a floating point [timeout] arg.

Modified:
    trunk/CHANGES
    trunk/apps/app_read.c
    trunk/apps/app_speech_utils.c
    trunk/apps/app_waitforring.c
    trunk/main/pbx.c

Modified: trunk/CHANGES
URL: http://svn.digium.com/view/asterisk/trunk/CHANGES?rev=44435&r1=44434&r2=44435&view=diff
==============================================================================
--- trunk/CHANGES (original)
+++ trunk/CHANGES Wed Oct  4 20:40:06 2006
@@ -29,3 +29,11 @@
      two channels.
   * Added 'Strategy' field to manager event QueueParams which represents
      the queue strategy in use. 
+  * From the to-do lists: straighten out the app timeout args:
+     Wait() app now really does 0.3 seconds- was truncating arg to an int.
+     WaitExten() same as Wait().
+     Congestion() - Now takes floating pt. argument.
+     Busy() - now takes floating pt. argument.
+     Read() - timeout now can be floating pt.
+     WaitForRing() now takes floating pt timeout arg.
+     SpeechBackground() -- clarified in the docstrings that the timeout is an integer seconds.

Modified: trunk/apps/app_read.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_read.c?rev=44435&r1=44434&r2=44435&view=diff
==============================================================================
--- trunk/apps/app_read.c (original)
+++ trunk/apps/app_read.c Wed Oct  4 20:40:06 2006
@@ -77,8 +77,8 @@
 "                'n' to read digits even if the line is not up.\n"
 "  attempts   -- if greater than 1, that many attempts will be made in the \n"
 "                event no data is entered.\n"
-"  timeout    -- An integer number of seconds to wait for a digit response. If greater\n"
-"                than 0, that value will override the default timeout.\n\n"
+"  timeout    -- The number of seconds to wait for a digit response. If greater\n"
+"                than 0, that value will override the default timeout. Can be floating point.\n\n"
 "Read should disconnect if the function fails or errors out.\n";
 
 
@@ -91,6 +91,7 @@
 	char tmp[256] = "";
 	int maxdigits = 255;
 	int tries = 1, to = 0, x = 0;
+	double tosec;
 	char *argcopy = NULL;
 	struct tone_zone_sound *ts;
 	struct ast_flags flags = {0};
@@ -126,11 +127,11 @@
 	}
 
 	if (!ast_strlen_zero(arglist.timeout)) {
-		to = atoi(arglist.timeout);
-		if (to <= 0)
+		tosec = atof(arglist.timeout);
+		if (tosec <= 0)
 			to = 0;
 		else
-			to *= 1000;
+			to = tosec * 1000.0;
 	}
 
 	if (ast_strlen_zero(arglist.filename)) {

Modified: trunk/apps/app_speech_utils.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_speech_utils.c?rev=44435&r1=44434&r2=44435&view=diff
==============================================================================
--- trunk/apps/app_speech_utils.c (original)
+++ trunk/apps/app_speech_utils.c Wed Oct  4 20:40:06 2006
@@ -64,7 +64,7 @@
 "Once they stop talking the processing sound is played to indicate the speech recognition engine is working.\n"
 "Once results are available the application returns and results (score and text) are available using dialplan functions.\n"
 "The first text and score are ${SPEECH_TEXT(0)} AND ${SPEECH_SCORE(0)} while the second are ${SPEECH_TEXT(1)} and ${SPEECH_SCORE(1)}.\n"
-"The first argument is the sound file and the second is the timeout. Note the timeout will only start once the sound file has stopped playing.\n";
+"The first argument is the sound file and the second is the timeout integer in seconds. Note the timeout will only start once the sound file has stopped playing.\n";
 
 static char *speechdeactivategrammar_descrip =
 "SpeechDeactivateGrammar(Grammar Name)\n"

Modified: trunk/apps/app_waitforring.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_waitforring.c?rev=44435&r1=44434&r2=44435&view=diff
==============================================================================
--- trunk/apps/app_waitforring.c (original)
+++ trunk/apps/app_waitforring.c Wed Oct  4 20:40:06 2006
@@ -58,16 +58,17 @@
 	struct ast_module_user *u;
 	struct ast_frame *f;
 	int res = 0;
+	double s;
 	int ms;
 
-	if (!data || (sscanf(data, "%d", &ms) != 1)) {
+	if (!data || (sscanf(data, "%lg", &s) != 1)) {
                 ast_log(LOG_WARNING, "WaitForRing requires an argument (minimum seconds)\n");
 		return 0;
 	}
 
 	u = ast_module_user_add(chan);
 
-	ms *= 1000;
+	ms = s*1000.0;
 	while(ms > 0) {
 		ms = ast_waitfor(chan, ms);
 		if (ms < 0) {

Modified: trunk/main/pbx.c
URL: http://svn.digium.com/view/asterisk/trunk/main/pbx.c?rev=44435&r1=44434&r2=44435&view=diff
==============================================================================
--- trunk/main/pbx.c (original)
+++ trunk/main/pbx.c Wed Oct  4 20:40:06 2006
@@ -5023,12 +5023,14 @@
 {
 	int res;
 	struct ast_frame *f;
+	double waitsec;
 	int waittime;
 
-	if (ast_strlen_zero(data) || (sscanf(data, "%d", &waittime) != 1) || (waittime < 0))
-		waittime = -1;
-	if (waittime > -1) {
-		ast_safe_sleep(chan, waittime * 1000);
+	if (ast_strlen_zero(data) || (sscanf(data, "%lg", &waitsec) != 1) || (waitsec < 0))
+		waitsec = -1;
+	if (waitsec > -1) {
+		waittime = waitsec * 1000.0;
+		ast_safe_sleep(chan, waittime);
 	} else do {
 		res = ast_waitfor(chan, -1);
 		if (res < 0)
@@ -5246,11 +5248,12 @@
  */
 static int pbx_builtin_wait(struct ast_channel *chan, void *data)
 {
+	double s;
 	int ms;
 
 	/* Wait for "n" seconds */
-	if (data && (ms = atof(data)) > 0) {
-		ms *= 1000;
+	if (data && (s = atof(data)) > 0.0) {
+		ms = s*1000.0;
 		return ast_safe_sleep(chan, ms);
 	}
 	return 0;
@@ -5262,6 +5265,7 @@
 static int pbx_builtin_waitexten(struct ast_channel *chan, void *data)
 {
 	int ms, res;
+	double s;
 	struct ast_flags flags = {0};
 	char *opts[1] = { NULL };
 	char *parse;
@@ -5285,12 +5289,13 @@
 		ast_indicate_data(chan, AST_CONTROL_HOLD, opts[0], strlen(opts[0]));
 
 	/* Wait for "n" seconds */
-	if (args.timeout && (ms = atof(args.timeout)) > 0)
-		 ms *= 1000;
+	if (args.timeout && (s = atof(args.timeout)) > 0)
+		 ms = s * 1000.0;
 	else if (chan->pbx)
 		ms = chan->pbx->rtimeout * 1000;
 	else
 		ms = 10000;
+
 	res = ast_waitfordigit(chan, ms);
 	if (!res) {
 		if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 1, chan->cid.cid_num)) {



More information about the svn-commits mailing list