提交 235466d1 authored 作者: Brian West's avatar Brian West

fix core

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@766 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 6ad4c8a9
...@@ -36,33 +36,13 @@ static const char modname[] = "mod_echo"; ...@@ -36,33 +36,13 @@ static const char modname[] = "mod_echo";
static void echo_function(switch_core_session *session, char *data) static void echo_function(switch_core_session *session, char *data)
{ {
switch_channel *channel; switch_channel *channel;
switch_frame *frame;
char *codec_name;
switch_codec codec, *read_codec;
channel = switch_core_session_get_channel(session); channel = switch_core_session_get_channel(session);
assert(channel != NULL); assert(channel != NULL);
read_codec = switch_core_session_get_read_codec(session);
switch_channel_answer(channel); switch_channel_answer(channel);
codec_name = "L16"; switch_channel_set_state(channel, CS_LOOPBACK);
if (switch_core_codec_init(&codec,
codec_name,
read_codec->implementation->samples_per_second,
read_codec->implementation->microseconds_per_frame / 1000,
read_codec->implementation->number_of_channels,
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
NULL, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Raw Codec Activated\n");
switch_core_session_set_read_codec(session, &codec);
switch_core_session_set_write_codec(session, &codec);
while(switch_channel_ready(channel)) {
switch_core_session_read_frame(session, &frame, -1, 0);
switch_core_session_write_frame(session, frame, -1 ,0);
}
}
} }
static const switch_application_interface echo_application_interface = { static const switch_application_interface echo_application_interface = {
......
...@@ -1621,7 +1621,9 @@ static void switch_core_standard_on_execute(switch_core_session *session) ...@@ -1621,7 +1621,9 @@ static void switch_core_standard_on_execute(switch_core_session *session)
extension->current_application = extension->current_application->next; extension->current_application = extension->current_application->next;
} }
switch_channel_set_state(session->channel, CS_HANGUP); if (switch_channel_get_state(session->channel) == CS_EXECUTE) {
switch_channel_set_state(session->channel, CS_HANGUP);
}
} }
static void switch_core_standard_on_loopback(switch_core_session *session) static void switch_core_standard_on_loopback(switch_core_session *session)
...@@ -1942,6 +1944,7 @@ SWITCH_DECLARE(void) switch_core_session_run(switch_core_session *session) ...@@ -1942,6 +1944,7 @@ SWITCH_DECLARE(void) switch_core_session_run(switch_core_session *session)
if (state < CS_DONE && midstate == switch_channel_get_state(session->channel)) { if (state < CS_DONE && midstate == switch_channel_get_state(session->channel)) {
switch_thread_cond_wait(session->cond, session->mutex); switch_thread_cond_wait(session->cond, session->mutex);
} }
} }
session->thread_running = 0; session->thread_running = 0;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论