提交 d79ff1c6 authored 作者: Anthony Minessale's avatar Anthony Minessale

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@107 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 0ce22f5a
...@@ -214,7 +214,7 @@ static void audio_bridge_function(switch_core_session *session, char *data) ...@@ -214,7 +214,7 @@ static void audio_bridge_function(switch_core_session *session, char *data)
if (state > CS_RING) { if (state > CS_RING) {
break; break;
} }
switch_yield(100); switch_yield(1000);
} }
time(&start); time(&start);
...@@ -222,7 +222,7 @@ static void audio_bridge_function(switch_core_session *session, char *data) ...@@ -222,7 +222,7 @@ static void audio_bridge_function(switch_core_session *session, char *data)
switch_channel_get_state(peer_channel) == CS_TRANSMIT && switch_channel_get_state(peer_channel) == CS_TRANSMIT &&
!switch_channel_test_flag(peer_channel, CF_ANSWERED) && !switch_channel_test_flag(peer_channel, CF_ANSWERED) &&
((time(NULL) - start) < timelimit)) { ((time(NULL) - start) < timelimit)) {
switch_yield(100); switch_yield(20000);
} }
if (switch_channel_test_flag(peer_channel, CF_ANSWERED)) { if (switch_channel_test_flag(peer_channel, CF_ANSWERED)) {
...@@ -233,7 +233,7 @@ static void audio_bridge_function(switch_core_session *session, char *data) ...@@ -233,7 +233,7 @@ static void audio_bridge_function(switch_core_session *session, char *data)
other_audio_thread.running = -1; other_audio_thread.running = -1;
/* wait for the other audio thread */ /* wait for the other audio thread */
while (other_audio_thread.running) { while (other_audio_thread.running) {
switch_yield(100); switch_yield(1000);
} }
} }
......
...@@ -35,14 +35,12 @@ ...@@ -35,14 +35,12 @@
static const char modname[] = "mod_codec_g729"; static const char modname[] = "mod_codec_g729";
struct g729_context { struct g729_context {
struct dec_state *decoder_object; struct dec_state decoder_object;
struct cod_state *encoder_object; struct cod_state encoder_object;
}; };
static switch_status switch_g729_init(switch_codec *codec, switch_codec_flag flags, const struct switch_codec_settings *codec_settings) static switch_status switch_g729_init(switch_codec *codec, switch_codec_flag flags, const struct switch_codec_settings *codec_settings)
{ {
struct dec_state *decoder_object = NULL;
struct cod_state *encoder_object = NULL;
struct g729_context *context = NULL; struct g729_context *context = NULL;
int encoding, decoding; int encoding, decoding;
...@@ -52,20 +50,14 @@ static switch_status switch_g729_init(switch_codec *codec, switch_codec_flag fla ...@@ -52,20 +50,14 @@ static switch_status switch_g729_init(switch_codec *codec, switch_codec_flag fla
if (!(encoding || decoding) || (!(context = switch_core_alloc(codec->memory_pool, sizeof(*context))))) { if (!(encoding || decoding) || (!(context = switch_core_alloc(codec->memory_pool, sizeof(*context))))) {
return SWITCH_STATUS_FALSE; return SWITCH_STATUS_FALSE;
} else { } else {
if ((encoding) && (!(encoder_object = switch_core_alloc(codec->memory_pool, sizeof(*encoder_object))))) { memset(context, 0, sizeof(*context));
return SWITCH_STATUS_FALSE; if (encoding) {
g729_init_coder(&context->encoder_object, 0);
} }
if ((decoding) && (!(decoder_object = switch_core_alloc(codec->memory_pool, sizeof(*decoder_object))))) { if (decoding) {
return SWITCH_STATUS_FALSE; g729_init_decoder(&context->decoder_object);
} }
if (encoder_object) {
g729_init_coder(encoder_object, 0);
}
if (decoder_object) {
g729_init_decoder(decoder_object);
}
context->decoder_object = decoder_object;
context->encoder_object = encoder_object;
codec->private = context; codec->private = context;
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
...@@ -88,7 +80,6 @@ static switch_status switch_g729_encode(switch_codec *codec, ...@@ -88,7 +80,6 @@ static switch_status switch_g729_encode(switch_codec *codec,
unsigned int *flag) unsigned int *flag)
{ {
struct g729_context *context = codec->private; struct g729_context *context = codec->private;
struct cod_state *encoder_object = context->encoder_object;
short *dbuf; short *dbuf;
unsigned char *ebuf; unsigned char *ebuf;
int cbret = 0; int cbret = 0;
...@@ -102,7 +93,7 @@ static switch_status switch_g729_encode(switch_codec *codec, ...@@ -102,7 +93,7 @@ static switch_status switch_g729_encode(switch_codec *codec,
if (decoded_data_len < (size_t)codec->implementation->samples_per_frame*2 || *encoded_data_len < (size_t)codec->implementation->encoded_bytes_per_frame) if (decoded_data_len < (size_t)codec->implementation->samples_per_frame*2 || *encoded_data_len < (size_t)codec->implementation->encoded_bytes_per_frame)
return SWITCH_STATUS_FALSE; return SWITCH_STATUS_FALSE;
g729_coder(encoder_object, (short *) dbuf, ebuf, &cbret); g729_coder(&context->encoder_object, (short *) dbuf, ebuf, &cbret);
*encoded_data_len = (codec->implementation->encoded_bytes_per_frame / 2); *encoded_data_len = (codec->implementation->encoded_bytes_per_frame / 2);
...@@ -119,7 +110,6 @@ static switch_status switch_g729_decode(switch_codec *codec, ...@@ -119,7 +110,6 @@ static switch_status switch_g729_decode(switch_codec *codec,
unsigned int *flag) unsigned int *flag)
{ {
struct g729_context *context = codec->private; struct g729_context *context = codec->private;
struct dec_state *decoder_object = context->decoder_object;
short *dbuf; short *dbuf;
unsigned char *ebuf; unsigned char *ebuf;
...@@ -136,7 +126,7 @@ static switch_status switch_g729_decode(switch_codec *codec, ...@@ -136,7 +126,7 @@ static switch_status switch_g729_decode(switch_codec *codec,
memset(dbuf, 0, codec->implementation->bytes_per_frame); memset(dbuf, 0, codec->implementation->bytes_per_frame);
*decoded_data_len = codec->implementation->bytes_per_frame; *decoded_data_len = codec->implementation->bytes_per_frame;
} else { } else {
g729_decoder(decoder_object, decoded_data, (void *) encoded_data, (int)encoded_data_len); g729_decoder(&context->decoder_object, decoded_data, (void *) encoded_data, (int)encoded_data_len);
*decoded_data_len = codec->implementation->bytes_per_frame; *decoded_data_len = codec->implementation->bytes_per_frame;
} }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
ProjectType="Visual C++" ProjectType="Visual C++"
Version="8.00" Version="8.00"
Name="mod_codec_g729" Name="mod_codec_g729"
ProjectGUID="{B1FE4613-3F4B-4DAF-9714-2472BF8F56AE}" ProjectGUID="{1D95CD95-0DE2-48C3-AC23-D5C7D1C9C0F0}"
RootNamespace="mod_codec_g729" RootNamespace="mod_codec_g729"
Keyword="Win32Proj" Keyword="Win32Proj"
> >
......
...@@ -792,7 +792,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void) ...@@ -792,7 +792,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void)
/* Wait for an event.*/ /* Wait for an event.*/
if (!(iaxevent = iax_get_event(0))) { if (!(iaxevent = iax_get_event(0))) {
switch_yield(100); switch_yield(1000);
} else { } else {
struct private_object *tech_pvt = iax_get_private(iaxevent->session); struct private_object *tech_pvt = iax_get_private(iaxevent->session);
......
差异被折叠。
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论