<h1>Project "FreeSWITCH Source" received a push.</h1>
<h2>branch: master updated</h2>
<pre>
via: e37dd41e311986015393befed7160e27a6450933 (commit)
from: b8b7266abb7a6c081ad1e1531aea69daf5d7509c (commit)
</pre>= COMMIT LOG ===========================================================
<div class="highlight"><pre>committer: Christopher Rienzo
comments:
FS-3201 fix truncated TTS
<span style="color: #000080; font-weight: bold">diff --git a/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c b/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c</span>
<span style="color: #000080; font-weight: bold">index 5db1491..812744c 100644</span>
<span style="color: #A00000">--- a/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c</span>
<span style="color: #00A000">+++ b/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c</span>
<span style="color: #800080; font-weight: bold">@@ -260,6 +260,7 @@ static switch_status_t audio_queue_create(audio_queue_t ** queue, const char *na</span>
static switch_status_t audio_queue_write(audio_queue_t *queue, void *data, switch_size_t *data_len);
static switch_status_t audio_queue_read(audio_queue_t *queue, void *data, switch_size_t *data_len, int block);
static switch_status_t audio_queue_clear(audio_queue_t *queue);
<span style="color: #00A000">+static switch_status_t audio_queue_signal(audio_queue_t *queue);</span>
static switch_status_t audio_queue_destroy(audio_queue_t *queue);
/*********************************************************************************************************************************************
<span style="color: #800080; font-weight: bold">@@ -287,6 +288,8 @@ enum speech_channel_state {</span>
        SPEECH_CHANNEL_READY,
        /** processing speech request */
        SPEECH_CHANNEL_PROCESSING,
<span style="color: #00A000">+        /** finished processing speech request */</span>
<span style="color: #00A000">+        SPEECH_CHANNEL_DONE,</span>
        /** error opening channel */
        SPEECH_CHANNEL_ERROR
};
<span style="color: #800080; font-weight: bold">@@ -667,10 +670,12 @@ static switch_status_t audio_queue_create(audio_queue_t ** audio_queue, const ch</span>
static switch_status_t audio_queue_write(audio_queue_t *queue, void *data, switch_size_t *data_len)
{
        switch_status_t status = SWITCH_STATUS_SUCCESS;
<span style="color: #00A000">+#ifdef MOD_UNIMRCP_DEBUG_AUDIO_QUEUE</span>
<span style="color: #00A000">+        switch_size_t len = *data_len;</span>
<span style="color: #00A000">+#endif</span>
        switch_mutex_lock(queue->mutex);
#ifdef MOD_UNIMRCP_DEBUG_AUDIO_QUEUE
<span style="color: #A00000">-        switch_size_t len = *data_len;</span>
        if (queue->file_write) {
                switch_file_write(queue->file_write, data, &len);
        }
<span style="color: #800080; font-weight: bold">@@ -708,6 +713,9 @@ static switch_status_t audio_queue_read(audio_queue_t *queue, void *data, switch</span>
{
        switch_size_t requested = *data_len;
        switch_status_t status = SWITCH_STATUS_SUCCESS;
<span style="color: #00A000">+#ifdef MOD_UNIMRCP_DEBUG_AUDIO_QUEUE</span>
<span style="color: #00A000">+        switch_size_t len = *data_len;</span>
<span style="color: #00A000">+#endif</span>
        switch_mutex_lock(queue->mutex);
        /* wait for data, if allowed */
<span style="color: #800080; font-weight: bold">@@ -736,7 +744,6 @@ static switch_status_t audio_queue_read(audio_queue_t *queue, void *data, switch</span>
#ifdef MOD_UNIMRCP_DEBUG_AUDIO_QUEUE
        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) audio queue read total = %ld\tread = %ld\trequested = %ld\n", queue->name,
                                         queue->read_bytes, *data_len, requested);
<span style="color: #A00000">-        switch_size_t len = *data_len;</span>
        if (queue->file_read) {
                switch_file_write(queue->file_read, data, &len);
        }
<span style="color: #800080; font-weight: bold">@@ -764,6 +771,20 @@ static switch_status_t audio_queue_clear(audio_queue_t *queue)</span>
}
/**
<span style="color: #00A000">+ * Wake any threads waiting on this queue</span>
<span style="color: #00A000">+ *</span>
<span style="color: #00A000">+ * @param queue the queue to empty</span>
<span style="color: #00A000">+ * @return SWITCH_STATUS_SUCCESS</span>
<span style="color: #00A000">+ */</span>
<span style="color: #00A000">+static switch_status_t audio_queue_signal(audio_queue_t *queue)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        switch_mutex_lock(queue->mutex);</span>
<span style="color: #00A000">+        switch_thread_cond_signal(queue->cond);</span>
<span style="color: #00A000">+        switch_mutex_unlock(queue->mutex);</span>
<span style="color: #00A000">+        return SWITCH_STATUS_SUCCESS;</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+/**</span>
* Destroy the audio queue
*
* @param queue the queue to clean up
<span style="color: #800080; font-weight: bold">@@ -1438,9 +1459,19 @@ static switch_status_t speech_channel_read(speech_channel_t *schannel, void *dat</span>
        }
        switch_mutex_lock(schannel->mutex);
<span style="color: #A00000">-        if (schannel->state == SPEECH_CHANNEL_PROCESSING) {</span>
<span style="color: #00A000">+        switch (schannel->state) {</span>
<span style="color: #00A000">+        case SPEECH_CHANNEL_DONE:</span>
<span style="color: #00A000">+                /* pull any remaining audio - never blocking */</span>
<span style="color: #00A000">+                if (audio_queue_read(schannel->audio_queue, data, len, 0) == SWITCH_STATUS_FALSE) {</span>
<span style="color: #00A000">+                        /* all frames read */</span>
<span style="color: #00A000">+                        status = SWITCH_STATUS_BREAK;</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+                break;</span>
<span style="color: #00A000">+        case SPEECH_CHANNEL_PROCESSING:</span>
<span style="color: #00A000">+                /* IN-PROGRESS */</span>
                audio_queue_read(schannel->audio_queue, data, len, block);
<span style="color: #A00000">-        } else {</span>
<span style="color: #00A000">+                break;</span>
<span style="color: #00A000">+        default:</span>
                status = SWITCH_STATUS_BREAK;
        }
        switch_mutex_unlock(schannel->mutex);
<span style="color: #800080; font-weight: bold">@@ -1463,6 +1494,8 @@ static const char *speech_channel_state_to_string(speech_channel_state_t state)</span>
                return "READY";
        case SPEECH_CHANNEL_PROCESSING:
                return "PROCESSING";
<span style="color: #00A000">+        case SPEECH_CHANNEL_DONE:</span>
<span style="color: #00A000">+                return "DONE";</span>
        case SPEECH_CHANNEL_ERROR:
                return "ERROR";
        }
<span style="color: #800080; font-weight: bold">@@ -1498,7 +1531,7 @@ static switch_status_t speech_channel_set_state_unlocked(speech_channel_t *schan</span>
{
        if (schannel->state == SPEECH_CHANNEL_PROCESSING && state != SPEECH_CHANNEL_PROCESSING) {
                /* wake anyone waiting for audio data */
<span style="color: #A00000">-                audio_queue_clear(schannel->audio_queue);</span>
<span style="color: #00A000">+                audio_queue_signal(schannel->audio_queue);</span>
        }
        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) %s ==> %s\n", schannel->name, speech_channel_state_to_string(schannel->state),
<span style="color: #800080; font-weight: bold">@@ -1651,6 +1684,8 @@ static switch_status_t synth_speech_read_tts(switch_speech_handle_t *sh, void *d</span>
                        memset((uint8_t *) data + bytes_read, schannel->silence, *datalen - bytes_read);
                }
        } else {
<span style="color: #00A000">+                /* ready for next speak request */</span>
<span style="color: #00A000">+                speech_channel_set_state(schannel, SPEECH_CHANNEL_READY);</span>
                *datalen = 0;
                status = SWITCH_STATUS_BREAK;
        }
<span style="color: #800080; font-weight: bold">@@ -1878,7 +1913,7 @@ static apt_bool_t synth_on_message_receive(mrcp_application_t *application, mrcp</span>
                        if (message->start_line.request_state == MRCP_REQUEST_STATE_COMPLETE) {
                                /* got COMPLETE */
                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) COMPLETE\n", schannel->name);
<span style="color: #A00000">-                                speech_channel_set_state(schannel, SPEECH_CHANNEL_READY);</span>
<span style="color: #00A000">+                                speech_channel_set_state(schannel, SPEECH_CHANNEL_DONE);</span>
                        } else {
                                /* received unexpected request state */
                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) unexpected STOP response, request_state = %d\n", schannel->name,
<span style="color: #800080; font-weight: bold">@@ -1896,7 +1931,7 @@ static apt_bool_t synth_on_message_receive(mrcp_application_t *application, mrcp</span>
                if (message->start_line.method_id == SYNTHESIZER_SPEAK_COMPLETE) {
                        /* got SPEAK-COMPLETE */
                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) SPEAK-COMPLETE\n", schannel->name);
<span style="color: #A00000">-                        speech_channel_set_state(schannel, SPEECH_CHANNEL_READY);</span>
<span style="color: #00A000">+                        speech_channel_set_state(schannel, SPEECH_CHANNEL_DONE);</span>
                } else {
                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) unexpected event, method_id = %d\n", schannel->name,
                                                         (int) message->start_line.method_id);
</pre></div>
========================================================================<pre>
Summary of changes:
src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c | 49 ++++++++++++++++++++++++----
1 files changed, 42 insertions(+), 7 deletions(-)
</pre>
<p>this email was generated because of /git/your-repo.git/hooks/post-receive by the file /git-core/contrib/hooks/post-receive-email<br />
For more info, see <a href="http://blog.chomperstomp.com/?p=630">http://blog.chomperstomp.com/?p=630</a>
-- <br />
FreeSWITCH Source</p>