[Freeswitch-svn] [commit] r2082 - in freeswitch/trunk/src/mod: applications/mod_conference asr_tts/mod_cepstral

Freeswitch SVN anthm at freeswitch.org
Mon Jul 24 14:56:21 EDT 2006


Author: anthm
Date: Mon Jul 24 14:56:20 2006
New Revision: 2082

Modified:
   freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
   freeswitch/trunk/src/mod/asr_tts/mod_cepstral/mod_cepstral.c

Log:
add stricter checking

Modified: freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c	(original)
+++ freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c	Mon Jul 24 14:56:20 2006
@@ -992,7 +992,18 @@
 {
 	confernce_file_node_t *fnode, *nptr;
 	switch_memory_pool_t *pool;
+	uint32_t count;
 
+	switch_mutex_lock(conference->mutex);
+	switch_mutex_lock(conference->member_mutex);
+	count = conference->count;
+	switch_mutex_unlock(conference->member_mutex);
+	switch_mutex_unlock(conference->mutex);	
+
+	if (!count) {
+        return SWITCH_STATUS_FALSE;
+    }
+
 	if (*file != '/') {
 		return conference_say(conference, file, leadin);
 	}
@@ -1155,9 +1166,19 @@
 	confernce_file_node_t *fnode, *nptr;
 	switch_memory_pool_t *pool;
 	switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_TTS;
+	uint32_t count;
 
+	switch_mutex_lock(conference->mutex);
+	switch_mutex_lock(conference->member_mutex);
+	count = conference->count;
 	if (!(conference->tts_engine && conference->tts_voice)) {
-		return SWITCH_STATUS_SUCCESS;
+        count = 0;
+    }
+	switch_mutex_unlock(conference->member_mutex);
+	switch_mutex_unlock(conference->mutex);	
+
+	if (!count) {
+		return SWITCH_STATUS_FALSE;
 	}
 
 	/* Setup a memory pool to use. */
@@ -1406,10 +1427,13 @@
 					char *tbuf = NULL;
 					char *text;
 
-					if ((tbuf = strdup(buf))) {
-						if ((text = strstr(tbuf, "say "))) {
+					if (argc > 2 && (tbuf = strdup(buf))) {
+						if ((text = strstr(tbuf, "say"))) {
 							text += 4;
-							if (text && conference_say(conference, text, 0) == SWITCH_STATUS_SUCCESS) {
+							while(*text == ' ') {
+								text++;
+							}
+							if (!switch_strlen_zero(text) && conference_say(conference, text, 0) == SWITCH_STATUS_SUCCESS) {
 								stream->write_function(stream, "(say) OK\n");
 								if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
 									switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Name", conference->name);
@@ -1425,6 +1449,8 @@
 						}
 
 						free(tbuf);
+					} else {
+						stream->write_function(stream, "(say) Error! No text.");
 					}
 				} else if (!strcasecmp(argv[1], "saymember")) {
 					char *tbuf = NULL, *text, *name;

Modified: freeswitch/trunk/src/mod/asr_tts/mod_cepstral/mod_cepstral.c
==============================================================================
--- freeswitch/trunk/src/mod/asr_tts/mod_cepstral/mod_cepstral.c	(original)
+++ freeswitch/trunk/src/mod/asr_tts/mod_cepstral/mod_cepstral.c	Mon Jul 24 14:56:20 2006
@@ -210,17 +210,23 @@
 
 	cepstral->done_gen = 0;
 	cepstral->done = 0;
-
+	
 	cepstral->tts_stream = NULL;
 	
 	if (!strncasecmp(text, fp, len)) {
 		text += len;
+		if (switch_strlen_zero(text)) {
+			return SWITCH_STATUS_FALSE;
+		}
 		swift_port_speak_file(cepstral->port, text, NULL, &cepstral->tts_stream, NULL); 
 	} else {
+		if (switch_strlen_zero(text)) {
+			return SWITCH_STATUS_FALSE;
+		}
 		swift_port_speak_text(cepstral->port, text, 0, NULL, &cepstral->tts_stream, NULL); 
 	}
 
-	return SWITCH_STATUS_FALSE;
+	return SWITCH_STATUS_SUCCESS;
 }
 
 static void cepstral_speech_flush_tts(switch_speech_handle_t *sh)



More information about the Freeswitch-svn mailing list