提交 f3ac24bb authored 作者: Moises Silva's avatar Moises Silva

Small adjustment to mod_sangoma_codec

* Remove unnecessary memset
* Narrow the scope of the global lock on session initialization
* Assert for couple of expected pointers

This won't fix anything, it's just maintenance clean up done
while investigating FS-8312.
上级 4d180b1a
...@@ -333,18 +333,16 @@ static switch_status_t switch_sangoma_init(switch_codec_t *codec, switch_codec_f ...@@ -333,18 +333,16 @@ static switch_status_t switch_sangoma_init(switch_codec_t *codec, switch_codec_f
if (!(sess = switch_core_alloc(codec->memory_pool, sizeof(*sess)))) { if (!(sess = switch_core_alloc(codec->memory_pool, sizeof(*sess)))) {
return SWITCH_STATUS_FALSE; return SWITCH_STATUS_FALSE;
} }
memset(sess, 0, sizeof(*sess));
sess->encoder.lastrxseqno = -1; sess->encoder.lastrxseqno = -1;
sess->decoder.lastrxseqno = -1; sess->decoder.lastrxseqno = -1;
sess->pool = codec->memory_pool; sess->pool = codec->memory_pool;
sess->impl = codec->implementation; sess->impl = codec->implementation;
switch_assert(sess->pool);
switch_assert(sess->impl);
vcodec = get_codec_from_iana(codec->implementation->ianacode, codec->implementation->bits_per_second); vcodec = get_codec_from_iana(codec->implementation->ianacode, codec->implementation->bits_per_second);
switch_mutex_lock(g_sessions_lock);
if (encoding) { if (encoding) {
sess->encoder.request.usr_priv = sess; sess->encoder.request.usr_priv = sess;
sess->encoder.request.a.host_ip = g_rtpip; sess->encoder.request.a.host_ip = g_rtpip;
...@@ -370,13 +368,15 @@ static switch_status_t switch_sangoma_init(switch_codec_t *codec, switch_codec_f ...@@ -370,13 +368,15 @@ static switch_status_t switch_sangoma_init(switch_codec_t *codec, switch_codec_f
} }
switch_mutex_lock(g_sessions_lock);
sess->sessid = g_next_session_id++; sess->sessid = g_next_session_id++;
switch_snprintf(sess->hashkey, sizeof(sess->hashkey), SANGOMA_SESS_HASH_KEY_FORMAT, sess->sessid); switch_snprintf(sess->hashkey, sizeof(sess->hashkey), SANGOMA_SESS_HASH_KEY_FORMAT, sess->sessid);
switch_core_hash_insert(g_sessions_hash, sess->hashkey, sess); switch_core_hash_insert(g_sessions_hash, sess->hashkey, sess);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Sangoma init done for codec %s/%s, iana = %d\n", codec->implementation->iananame, vcodec->fs_name, codec->implementation->ianacode);
switch_mutex_unlock(g_sessions_lock); switch_mutex_unlock(g_sessions_lock);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Sangoma init done for codec %s/%s, iana = %d\n", codec->implementation->iananame, vcodec->fs_name, codec->implementation->ianacode);
codec->private_info = sess; codec->private_info = sess;
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论