From da6739891151df36690997a1452e25b1d1bed969 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 24 Jul 2006 18:56:20 +0000 Subject: [PATCH] add stricter checking git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@2082 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- .../mod_conference/mod_conference.c | 34 ++++++++++++++++--- src/mod/asr_tts/mod_cepstral/mod_cepstral.c | 10 ++++-- 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/src/mod/applications/mod_conference/mod_conference.c b/src/mod/applications/mod_conference/mod_conference.c index 2b35eee661..bcc10fbd05 100644 --- a/src/mod/applications/mod_conference/mod_conference.c +++ b/src/mod/applications/mod_conference/mod_conference.c @@ -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; diff --git a/src/mod/asr_tts/mod_cepstral/mod_cepstral.c b/src/mod/asr_tts/mod_cepstral/mod_cepstral.c index a22a90ea13..fe57d89a2f 100644 --- a/src/mod/asr_tts/mod_cepstral/mod_cepstral.c +++ b/src/mod/asr_tts/mod_cepstral/mod_cepstral.c @@ -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)