Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
e37dd41e
提交
e37dd41e
authored
2月 04, 2011
作者:
Christopher Rienzo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-3201 fix truncated TTS
上级
b8b7266a
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
42 行增加
和
7 行删除
+42
-7
mod_unimrcp.c
src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c
+42
-7
没有找到文件。
src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c
浏览文件 @
e37dd41e
...
...
@@ -260,6 +260,7 @@ static switch_status_t audio_queue_create(audio_queue_t ** queue, const char *na
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
);
static
switch_status_t
audio_queue_signal
(
audio_queue_t
*
queue
);
static
switch_status_t
audio_queue_destroy
(
audio_queue_t
*
queue
);
/*********************************************************************************************************************************************
...
...
@@ -287,6 +288,8 @@ enum speech_channel_state {
SPEECH_CHANNEL_READY
,
/** processing speech request */
SPEECH_CHANNEL_PROCESSING
,
/** finished processing speech request */
SPEECH_CHANNEL_DONE
,
/** error opening channel */
SPEECH_CHANNEL_ERROR
};
...
...
@@ -667,10 +670,12 @@ static switch_status_t audio_queue_create(audio_queue_t ** audio_queue, const ch
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
;
#ifdef MOD_UNIMRCP_DEBUG_AUDIO_QUEUE
switch_size_t
len
=
*
data_len
;
#endif
switch_mutex_lock
(
queue
->
mutex
);
#ifdef MOD_UNIMRCP_DEBUG_AUDIO_QUEUE
switch_size_t
len
=
*
data_len
;
if
(
queue
->
file_write
)
{
switch_file_write
(
queue
->
file_write
,
data
,
&
len
);
}
...
...
@@ -708,6 +713,9 @@ static switch_status_t audio_queue_read(audio_queue_t *queue, void *data, switch
{
switch_size_t
requested
=
*
data_len
;
switch_status_t
status
=
SWITCH_STATUS_SUCCESS
;
#ifdef MOD_UNIMRCP_DEBUG_AUDIO_QUEUE
switch_size_t
len
=
*
data_len
;
#endif
switch_mutex_lock
(
queue
->
mutex
);
/* wait for data, if allowed */
...
...
@@ -736,7 +744,6 @@ static switch_status_t audio_queue_read(audio_queue_t *queue, void *data, switch
#ifdef MOD_UNIMRCP_DEBUG_AUDIO_QUEUE
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"(%s) audio queue read total = %ld
\t
read = %ld
\t
requested = %ld
\n
"
,
queue
->
name
,
queue
->
read_bytes
,
*
data_len
,
requested
);
switch_size_t
len
=
*
data_len
;
if
(
queue
->
file_read
)
{
switch_file_write
(
queue
->
file_read
,
data
,
&
len
);
}
...
...
@@ -763,6 +770,20 @@ static switch_status_t audio_queue_clear(audio_queue_t *queue)
return
SWITCH_STATUS_SUCCESS
;
}
/**
* Wake any threads waiting on this queue
*
* @param queue the queue to empty
* @return SWITCH_STATUS_SUCCESS
*/
static
switch_status_t
audio_queue_signal
(
audio_queue_t
*
queue
)
{
switch_mutex_lock
(
queue
->
mutex
);
switch_thread_cond_signal
(
queue
->
cond
);
switch_mutex_unlock
(
queue
->
mutex
);
return
SWITCH_STATUS_SUCCESS
;
}
/**
* Destroy the audio queue
*
...
...
@@ -1438,9 +1459,19 @@ static switch_status_t speech_channel_read(speech_channel_t *schannel, void *dat
}
switch_mutex_lock
(
schannel
->
mutex
);
if
(
schannel
->
state
==
SPEECH_CHANNEL_PROCESSING
)
{
switch
(
schannel
->
state
)
{
case
SPEECH_CHANNEL_DONE
:
/* pull any remaining audio - never blocking */
if
(
audio_queue_read
(
schannel
->
audio_queue
,
data
,
len
,
0
)
==
SWITCH_STATUS_FALSE
)
{
/* all frames read */
status
=
SWITCH_STATUS_BREAK
;
}
break
;
case
SPEECH_CHANNEL_PROCESSING
:
/* IN-PROGRESS */
audio_queue_read
(
schannel
->
audio_queue
,
data
,
len
,
block
);
}
else
{
break
;
default:
status
=
SWITCH_STATUS_BREAK
;
}
switch_mutex_unlock
(
schannel
->
mutex
);
...
...
@@ -1463,6 +1494,8 @@ static const char *speech_channel_state_to_string(speech_channel_state_t state)
return
"READY"
;
case
SPEECH_CHANNEL_PROCESSING
:
return
"PROCESSING"
;
case
SPEECH_CHANNEL_DONE
:
return
"DONE"
;
case
SPEECH_CHANNEL_ERROR
:
return
"ERROR"
;
}
...
...
@@ -1498,7 +1531,7 @@ static switch_status_t speech_channel_set_state_unlocked(speech_channel_t *schan
{
if
(
schannel
->
state
==
SPEECH_CHANNEL_PROCESSING
&&
state
!=
SPEECH_CHANNEL_PROCESSING
)
{
/* wake anyone waiting for audio data */
audio_queue_
clear
(
schannel
->
audio_queue
);
audio_queue_
signal
(
schannel
->
audio_queue
);
}
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"(%s) %s ==> %s
\n
"
,
schannel
->
name
,
speech_channel_state_to_string
(
schannel
->
state
),
...
...
@@ -1651,6 +1684,8 @@ static switch_status_t synth_speech_read_tts(switch_speech_handle_t *sh, void *d
memset
((
uint8_t
*
)
data
+
bytes_read
,
schannel
->
silence
,
*
datalen
-
bytes_read
);
}
}
else
{
/* ready for next speak request */
speech_channel_set_state
(
schannel
,
SPEECH_CHANNEL_READY
);
*
datalen
=
0
;
status
=
SWITCH_STATUS_BREAK
;
}
...
...
@@ -1878,7 +1913,7 @@ static apt_bool_t synth_on_message_receive(mrcp_application_t *application, mrcp
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
);
speech_channel_set_state
(
schannel
,
SPEECH_CHANNEL_
READY
);
speech_channel_set_state
(
schannel
,
SPEECH_CHANNEL_
DONE
);
}
else
{
/* received unexpected request state */
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"(%s) unexpected STOP response, request_state = %d
\n
"
,
schannel
->
name
,
...
...
@@ -1896,7 +1931,7 @@ static apt_bool_t synth_on_message_receive(mrcp_application_t *application, mrcp
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
);
speech_channel_set_state
(
schannel
,
SPEECH_CHANNEL_
READY
);
speech_channel_set_state
(
schannel
,
SPEECH_CHANNEL_
DONE
);
}
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
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论