Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_25606643
ijkplayer
提交
ea7409ca
I
ijkplayer
项目概览
qq_25606643
/
ijkplayer
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
ijkplayer
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
ea7409ca
编写于
5月 27, 2014
作者:
Z
Zhang Rui
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ff_ffplay: recycle message to reduce memory allocation
上级
32c4ba71
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
52 addition
and
4 deletion
+52
-4
ijkmedia/ijkplayer/ff_ffmsg_queue.h
ijkmedia/ijkplayer/ff_ffmsg_queue.h
+48
-0
ijkmedia/ijkplayer/ff_ffplay.c
ijkmedia/ijkplayer/ff_ffplay.c
+4
-4
未找到文件。
ijkmedia/ijkplayer/ff_ffmsg_queue.h
浏览文件 @
ea7409ca
...
...
@@ -27,6 +27,8 @@
#include "ff_ffinc.h"
#include "ff_ffmsg.h"
// #define FFP_SHOW_MSG_RECYCLE
typedef
struct
AVMessage
{
int
what
;
int
arg1
;
...
...
@@ -40,6 +42,10 @@ typedef struct MessageQueue {
int
abort_request
;
SDL_mutex
*
mutex
;
SDL_cond
*
cond
;
AVMessage
*
recycle_msg
;
int
recycle_count
;
int
alloc_count
;
}
MessageQueue
;
// TODO: 9 msg pool
...
...
@@ -50,9 +56,27 @@ inline static int msg_queue_put_private(MessageQueue *q, AVMessage *msg)
if
(
q
->
abort_request
)
return
-
1
;
#ifdef FFP_MERGE
msg1
=
av_malloc
(
sizeof
(
AVMessage
));
#else
msg1
=
q
->
recycle_msg
;
if
(
msg1
)
{
q
->
recycle_msg
=
msg1
->
next
;
q
->
recycle_count
++
;
}
else
{
q
->
alloc_count
++
;
msg1
=
av_malloc
(
sizeof
(
AVMessage
));
}
#ifdef FFP_SHOW_MSG_RECYCLE
int
total_count
=
q
->
recycle_count
+
q
->
alloc_count
;
if
(
!
(
total_count
%
50
))
{
ALOGE
(
"msg-recycle
\t
%d +
\t
%d =
\t
%d
\n
"
,
q
->
recycle_count
,
q
->
alloc_count
,
total_count
);
}
#endif
#endif
if
(
!
msg1
)
return
-
1
;
*
msg1
=
*
msg
;
msg1
->
next
=
NULL
;
...
...
@@ -124,7 +148,12 @@ inline static void msg_queue_flush(MessageQueue *q)
SDL_LockMutex
(
q
->
mutex
);
for
(
msg
=
q
->
first_msg
;
msg
!=
NULL
;
msg
=
msg1
)
{
msg1
=
msg
->
next
;
#ifdef FFP_MERGE
av_freep
(
&
msg
);
#else
msg
->
next
=
q
->
recycle_msg
;
q
->
recycle_msg
=
msg
;
#endif
}
q
->
last_msg
=
NULL
;
q
->
first_msg
=
NULL
;
...
...
@@ -137,6 +166,15 @@ inline static void msg_queue_destroy(MessageQueue *q)
msg_queue_flush
(
q
);
SDL_DestroyMutex
(
q
->
mutex
);
SDL_DestroyCond
(
q
->
cond
);
SDL_LockMutex
(
q
->
mutex
);
while
(
q
->
recycle_msg
)
{
AVMessage
*
msg
=
q
->
recycle_msg
;
if
(
msg
)
q
->
recycle_msg
=
msg
->
next
;
av_freep
(
&
msg
);
}
SDL_UnlockMutex
(
q
->
mutex
);
}
inline
static
void
msg_queue_abort
(
MessageQueue
*
q
)
...
...
@@ -183,7 +221,12 @@ inline static int msg_queue_get(MessageQueue *q, AVMessage *msg, int block)
q
->
last_msg
=
NULL
;
q
->
nb_messages
--
;
*
msg
=
*
msg1
;
#ifdef FFP_MERGE
av_free
(
msg1
);
#else
msg1
->
next
=
q
->
recycle_msg
;
q
->
recycle_msg
=
msg1
;
#endif
ret
=
1
;
break
;
}
else
if
(
!
block
)
{
...
...
@@ -211,7 +254,12 @@ inline static void msg_queue_remove(MessageQueue *q, int what)
// ALOGE("remove msg %d", msg->what);
*
p_msg
=
msg
->
next
;
p_msg
=
&
msg
->
next
;
#ifdef FFP_MERGE
av_free
(
msg
);
#else
msg
->
next
=
q
->
recycle_msg
;
q
->
recycle_msg
=
msg
;
#endif
}
else
{
// ALOGE("retain msg %d", msg->what);
last_msg
=
msg
;
...
...
ijkmedia/ijkplayer/ff_ffplay.c
浏览文件 @
ea7409ca
...
...
@@ -163,6 +163,10 @@ static void packet_queue_flush(PacketQueue *q)
static
void
packet_queue_destroy
(
PacketQueue
*
q
)
{
packet_queue_flush
(
q
);
SDL_DestroyMutex
(
q
->
mutex
);
SDL_DestroyCond
(
q
->
cond
);
SDL_LockMutex
(
q
->
mutex
);
while
(
q
->
recycle_pkt
)
{
MyAVPacketList
*
pkt
=
q
->
recycle_pkt
;
...
...
@@ -171,10 +175,6 @@ static void packet_queue_destroy(PacketQueue *q)
av_freep
(
&
pkt
);
}
SDL_UnlockMutex
(
q
->
mutex
);
packet_queue_flush
(
q
);
SDL_DestroyMutex
(
q
->
mutex
);
SDL_DestroyCond
(
q
->
cond
);
}
static
void
packet_queue_abort
(
PacketQueue
*
q
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录