[Freeswitch-svn] [commit] r1590 - in freeswitch/trunk/src: . include mod/applications/mod_ivrtest mod/languages/mod_spidermonkey

anthm at freeswitch.org anthm at freeswitch.org
Fri Jun 9 18:59:18 EDT 2006


Author: anthm
Date: Fri Jun  9 18:59:13 2006
New Revision: 1590

Modified:
   freeswitch/trunk/src/include/switch_ivr.h
   freeswitch/trunk/src/include/switch_types.h
   freeswitch/trunk/src/mod/applications/mod_ivrtest/mod_ivrtest.c
   freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
   freeswitch/trunk/src/switch_core.c
   freeswitch/trunk/src/switch_ivr.c

Log:
use channel flag to tell when to read from channel during some stuff

Modified: freeswitch/trunk/src/include/switch_ivr.h
==============================================================================
--- freeswitch/trunk/src/include/switch_ivr.h	(original)
+++ freeswitch/trunk/src/include/switch_ivr.h	Fri Jun  9 18:59:13 2006
@@ -72,17 +72,15 @@
   \param terminators digits to end the collection
   \param terminator actual digit that caused the collection to end (if any)
   \param timeout timeout in ms
-  \param poll_channel flag to specify if you want the function to poll the channel while running
   \return SWITCH_STATUS_SUCCESS to keep the collection moving.
 */
 SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_count(switch_core_session_t *session,
-															  char *buf,
-															  unsigned int buflen,
-															  unsigned int maxdigits,
-															  const char *terminators,
-															  char *terminator,
-															  unsigned int timeout,
-                                                              unsigned int poll_channel);
+																char *buf,
+																unsigned int buflen,
+																unsigned int maxdigits,
+																const char *terminators,
+																char *terminator,
+																unsigned int timeout);
 	
 /*!
   \brief play a file from the disk to the session

Modified: freeswitch/trunk/src/include/switch_types.h
==============================================================================
--- freeswitch/trunk/src/include/switch_types.h	(original)
+++ freeswitch/trunk/src/include/switch_types.h	Fri Jun  9 18:59:13 2006
@@ -344,6 +344,7 @@
 CF_LOCK_THREAD	= (1 <<  6) - Prevent the channel thread from exiting while this flag is set
 CF_BRIDGED		= (1 <<  7) - Channel in a bridge
 CF_HOLD			= (1 <<  8) - Channel is on hold
+CF_SERVICE		= (1 <<  9) - Channel has a service thread
 </pre>
  */
 
@@ -356,7 +357,8 @@
 	CF_ACCEPT_CNG	= (1 <<  5),
 	CF_LOCK_THREAD	= (1 <<  6),
 	CF_BRIDGED		= (1 <<  7),
-	CF_HOLD			= (1 <<  8)
+	CF_HOLD			= (1 <<  8),
+	CF_SERVICE		= (1 <<  9)
 } switch_channel_flag_t;
 
 

Modified: freeswitch/trunk/src/mod/applications/mod_ivrtest/mod_ivrtest.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_ivrtest/mod_ivrtest.c	(original)
+++ freeswitch/trunk/src/mod/applications/mod_ivrtest/mod_ivrtest.c	Fri Jun  9 18:59:13 2006
@@ -183,7 +183,7 @@
 			}
 		}
 
-		if (switch_ivr_collect_digits_count(session, buf, sizeof(buf), 10, "#*", &term, 10000, 1) != SWITCH_STATUS_SUCCESS) {
+		if (switch_ivr_collect_digits_count(session, buf, sizeof(buf), 10, "#*", &term, 10000) != SWITCH_STATUS_SUCCESS) {
 			switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
 			break;
 		}

Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c	(original)
+++ freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c	Fri Jun  9 18:59:13 2006
@@ -559,9 +559,7 @@
 	char *buf;
 	int digits;
 	int32 timeout = 5000;
-	int32 poll_chan = 1;
 	
-	
 	if (argc > 0) {
 		char term;
 		digits = atoi(JS_GetStringBytes(JS_ValueToString(cx, argv[0])));
@@ -571,11 +569,9 @@
 		if (argc > 2) {
 			JS_ValueToInt32(cx, argv[2], &timeout);
 		}
-		if (argc > 3) {
-			JS_ValueToInt32(cx, argv[3], &poll_chan);
-		}
+
 		buf = switch_core_session_alloc(jss->session, digits);
-		switch_ivr_collect_digits_count(jss->session, buf, digits, digits, terminators, &term, timeout, poll_chan ? SWITCH_TRUE : SWITCH_FALSE);
+		switch_ivr_collect_digits_count(jss->session, buf, digits, digits, terminators, &term, timeout);
 		*rval = STRING_TO_JSVAL ( JS_NewStringCopyZ(cx, buf) );
 		return JS_TRUE;
 	}

Modified: freeswitch/trunk/src/switch_core.c
==============================================================================
--- freeswitch/trunk/src/switch_core.c	(original)
+++ freeswitch/trunk/src/switch_core.c	Fri Jun  9 18:59:13 2006
@@ -743,6 +743,7 @@
 	channel = switch_core_session_get_channel(session);
 	assert(channel != NULL);
 
+	switch_channel_set_flag(channel, CF_SERVICE);
 	while (data->running > 0) {
 		switch (switch_core_session_read_frame(session, &read_frame, -1, stream_id)) {
 		case SWITCH_STATUS_SUCCESS:
@@ -755,6 +756,7 @@
 		}
 	}
 
+	switch_channel_clear_flag(channel, CF_SERVICE);
 	data->running = 0;
 	return NULL;
 }

Modified: freeswitch/trunk/src/switch_ivr.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr.c	(original)
+++ freeswitch/trunk/src/switch_ivr.c	Fri Jun  9 18:59:13 2006
@@ -63,7 +63,11 @@
 			break;
 		}
 
-		status = switch_core_session_read_frame(session, &read_frame, -1, 0);
+		if (switch_channel_test_flag(channel, CF_SERVICE)) {
+			switch_yield(1000);
+		} else {
+			status = switch_core_session_read_frame(session, &read_frame, -1, 0);
+		}
 
 		if (!SWITCH_READ_ACCEPTABLE(status)) {
 			break;
@@ -75,14 +79,12 @@
 
 
 SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_count(switch_core_session_t *session,
-															  char *buf,
-															  unsigned int buflen,
-															  unsigned int maxdigits,
-															  const char *terminators,
-															  char *terminator,
-															  unsigned int timeout,
-															  unsigned int poll_channel
-															  )
+																char *buf,
+																unsigned int buflen,
+																unsigned int maxdigits,
+																const char *terminators,
+																char *terminator,
+																unsigned int timeout)
 {
 	unsigned int i = 0, x =  (unsigned int) strlen(buf);
 	switch_channel_t *channel;
@@ -135,14 +137,14 @@
 				}
 			}
 		}
-		if (poll_channel) {
+
+		if (switch_channel_test_flag(channel, CF_SERVICE)) {
+			switch_yield(1000);
+		} else {
 			status = switch_core_session_read_frame(session, &read_frame, -1, 0);
-			
 			if (!SWITCH_READ_ACCEPTABLE(status)) {
 				break;
 			}
-		} else {
-			switch_yield(1000);
 		}
 	}
 



More information about the Freeswitch-svn mailing list