]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add stricter checking
authorAnthony Minessale <anthony.minessale@gmail.com>
Mon, 24 Jul 2006 18:56:20 +0000 (18:56 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Mon, 24 Jul 2006 18:56:20 +0000 (18:56 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@2082 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/applications/mod_conference/mod_conference.c
src/mod/asr_tts/mod_cepstral/mod_cepstral.c

index 2b35eee6614628fd479f60bd943d29e4f7885aa0..bcc10fbd05e92c40c5eb32acb910efebb4e14e2e 100644 (file)
@@ -992,6 +992,17 @@ static switch_status_t conference_play_file(conference_obj_t *conference, char *
 {
        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 @@ static switch_status_t conference_say(conference_obj_t *conference, char *text,
        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 @@ static switch_status_t conf_function(char *buf, switch_stream_handle_t *stream)
                                        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 @@ static switch_status_t conf_function(char *buf, switch_stream_handle_t *stream)
                                                }
 
                                                free(tbuf);
+                                       } else {
+                                               stream->write_function(stream, "(say) Error! No text.");
                                        }
                                } else if (!strcasecmp(argv[1], "saymember")) {
                                        char *tbuf = NULL, *text, *name;
index a22a90ea13afdcd47ac478a611d2782a4b273363..fe57d89a2fcada2b4492a812db3c38aca2551861 100644 (file)
@@ -210,17 +210,23 @@ static switch_status_t cepstral_speech_feed_tts(switch_speech_handle_t *sh, char
 
        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)