Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
4f414765
提交
4f414765
authored
10月 04, 2010
作者:
Moises Silva
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
mod_sangoma_codec: fix memory leak by using a memory pool per transcoding session
上级
be3d61de
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
23 行增加
和
4 行删除
+23
-4
mod_sangoma_codec.c
src/mod/codecs/mod_sangoma_codec/mod_sangoma_codec.c
+23
-4
没有找到文件。
src/mod/codecs/mod_sangoma_codec/mod_sangoma_codec.c
浏览文件 @
4f414765
...
...
@@ -199,6 +199,8 @@ static int sangoma_create_rtp_port(void *usr_priv, uint32_t host_ip, uint32_t *p
static
int
sangoma_create_rtp
(
void
*
usr_priv
,
sngtc_codec_request_leg_t
*
codec_req_leg
,
sngtc_codec_reply_leg_t
*
codec_reply_leg
,
void
**
rtp_fd
)
{
switch_status_t
status
;
switch_memory_pool_t
*
sesspool
=
NULL
;
switch_rtp_t
*
rtp_session
=
NULL
;
char
codec_ip
[
255
];
switch_rtp_flag_t
flags
=
0
;
...
...
@@ -209,6 +211,18 @@ static int sangoma_create_rtp(void *usr_priv, sngtc_codec_request_leg_t *codec_r
switch_port_t
rtp_port
;
struct
sangoma_transcoding_session
*
sess
=
usr_priv
;
/*
* We *MUST* use a new pool
* Do not use the session pool since the session may go away while the RTP socket should linger around
* until sangoma_transcode decides to kill it (possibly because the same RTP session is used for a different call)
* also do not use the module pool otherwise memory would keep growing because switch_rtp_destroy does not
* free the memory used (is assumed it'll be freed when the pool is destroyed)
*/
status
=
switch_core_new_memory_pool
(
&
sesspool
);
if
(
status
!=
SWITCH_STATUS_SUCCESS
)
{
return
-
1
;
}
rtp_port
=
(
switch_port_t
)(
long
)
*
rtp_fd
;
codec_req_leg
->
host_udp_port
=
rtp_port
;
...
...
@@ -222,20 +236,20 @@ static int sangoma_create_rtp(void *usr_priv, sngtc_codec_request_leg_t *codec_r
local_ip
,
rtp_port
,
codec_ip
,
codec_reply_leg
->
codec_udp_port
,
iana
,
codec_req_leg
->
ms
*
1000
,
sess
->
sessid
);
/* create the RTP socket, dont use the session pool since the session may go away while the RTP socket should linger around
* until sangoma_transcode decides to kill it (possibly because the same RTP session is used for a different call) */
/* create the RTP socket */
rtp_session
=
switch_rtp_new
(
local_ip
,
rtp_port
,
codec_ip
,
codec_reply_leg
->
codec_udp_port
,
iana
,
sess
->
impl
->
samples_per_packet
,
codec_req_leg
->
ms
*
1000
,
/* microseconds per packet */
flags
,
NULL
,
&
err
,
g_
pool
);
flags
,
NULL
,
&
err
,
sess
pool
);
if
(
!
rtp_session
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"failed to create switch rtp session: %s
\n
"
,
err
);
switch_core_destroy_memory_pool
(
&
sesspool
);
return
-
1
;
}
switch_rtp_set_private
(
rtp_session
,
sesspool
);
*
rtp_fd
=
rtp_session
;
return
0
;
...
...
@@ -243,8 +257,11 @@ static int sangoma_create_rtp(void *usr_priv, sngtc_codec_request_leg_t *codec_r
static
int
sangoma_destroy_rtp
(
void
*
usr_priv
,
void
*
fd
)
{
switch_memory_pool_t
*
sesspool
;
switch_rtp_t
*
rtp
=
fd
;
sesspool
=
switch_rtp_get_private
(
rtp
);
switch_rtp_destroy
(
&
rtp
);
switch_core_destroy_memory_pool
(
&
sesspool
);
return
0
;
}
...
...
@@ -406,6 +423,7 @@ static switch_status_t switch_sangoma_encode(switch_codec_t *codec, switch_codec
sess
->
encoder
.
tx
++
;
/* do the reading */
memset
(
&
encoded_frame
,
0
,
sizeof
(
encoded_frame
));
for
(
;
;
)
{
sres
=
switch_rtp_zerocopy_read_frame
(
sess
->
encoder
.
rxrtp
,
&
encoded_frame
,
SWITCH_IO_FLAG_NOBLOCK
);
if
(
sres
==
SWITCH_STATUS_GENERR
)
{
...
...
@@ -525,6 +543,7 @@ static switch_status_t switch_sangoma_decode(switch_codec_t *codec, /* codec ses
sess
->
decoder
.
tx
++
;
/* do the reading */
memset
(
&
ulaw_frame
,
0
,
sizeof
(
ulaw_frame
));
for
(
;
;
)
{
sres
=
switch_rtp_zerocopy_read_frame
(
sess
->
decoder
.
rxrtp
,
&
ulaw_frame
,
SWITCH_IO_FLAG_NOBLOCK
);
if
(
sres
==
SWITCH_STATUS_GENERR
)
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论