Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
NotesChapter
ijkplayer
提交
32643bb7
I
ijkplayer
项目概览
NotesChapter
/
ijkplayer
与 Fork 源项目一致
从无法访问的项目Fork
通知
5
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,发现更多精彩内容 >>
提交
32643bb7
编写于
6月 15, 2013
作者:
Z
Zhang Rui
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
jni: ijkplayer: introduce msg_queue
上级
84618244
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
184 addition
and
0 deletion
+184
-0
ijkmediaplayer/jni/ijkplayer/ff_ffmsg_queue.h
ijkmediaplayer/jni/ijkplayer/ff_ffmsg_queue.h
+183
-0
ijkmediaplayer/jni/ijkplayer/ff_ffplay_def.h
ijkmediaplayer/jni/ijkplayer/ff_ffplay_def.h
+1
-0
未找到文件。
ijkmediaplayer/jni/ijkplayer/ff_ffmsg_queue.h
0 → 100644
浏览文件 @
32643bb7
/*
* ff_ffmsg_queue.h
* based on PacketQueue in ffplay.c
*
* Copyright (c) 2000-2003 Fabrice Bellard
* Copyright (c) 2013 Zhang Rui <bbcallen@gmail.com>
*
* This file is part of ijkPlayer.
*
* ijkPlayer is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* ijkPlayer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with ijkPlayer; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef IJKPLAYER__FF_FFMSG_QUEUE_H
#define IJKPLAYER__FF_FFMSG_QUEUE_H
#include "ff_ffinc.h"
typedef
struct
IjkMessage
{
int
serial
;
struct
IjkMessage
*
next
;
}
IjkMessage
;
typedef
struct
IjkMessageQueue
{
IjkMessage
*
first_msg
,
*
last_msg
;
int
abort_request
;
int
serial
;
SDL_mutex
*
mutex
;
SDL_cond
*
cond
;
}
IjkMessageQueue
;
extern
IjkMessage
flush_msg
;
static
int
ijkmsg_queue_put
(
IjkMessageQueue
*
q
,
IjkMessage
*
msg
);
static
int
ijkmsg_queue_put_private
(
IjkMessageQueue
*
q
,
IjkMessage
*
msg
)
{
IjkMessage
*
msg1
;
if
(
q
->
abort_request
)
return
-
1
;
msg1
=
malloc
(
sizeof
(
IjkMessage
));
if
(
!
msg1
)
return
-
1
;
msg1
=
*
msg
;
msg1
->
next
=
NULL
;
if
(
msg
==
&
flush_msg
)
q
->
serial
++
;
msg1
->
serial
=
q
->
serial
;
if
(
!
q
->
last_msg
)
q
->
first_msg
=
msg1
;
else
q
->
last_msg
->
next
=
msg1
;
q
->
last_msg
=
msg1
;
SDL_CondSignal
(
q
->
cond
);
return
0
;
}
static
IjkMessage
*
ijk_dup_msg
(
IjkMessage
*
msg
)
{
IjkMessage
*
msg1
=
malloc
(
sizeof
(
IjkMessage
));
if
(
!
msg1
)
return
NULL
;
*
msg1
=
*
msg
;
return
msg1
;
}
static
int
ijkmsg_queue_put
(
IjkMessageQueue
*
q
,
IjkMessage
*
msg
)
{
int
ret
;
if
(
msg
!=
&
flush_msg
&&
(
msg
=
ijk_dup_msg
(
msg
)))
return
-
1
;
SDL_LockMutex
(
q
->
mutex
);
ret
=
ijkmsg_queue_put_private
(
q
,
msg
);
SDL_UnlockMutex
(
q
->
mutex
);
if
(
msg
!=
&
flush_msg
&&
ret
<
0
)
free
(
msg
);
return
ret
;
}
static
void
ijkmsg_queue_init
(
IjkMessageQueue
*
q
)
{
memset
(
q
,
0
,
sizeof
(
IjkMessageQueue
));
q
->
mutex
=
SDL_CreateMutex
();
q
->
cond
=
SDL_CreateCond
();
q
->
abort_request
=
1
;
}
static
void
ijkmsg_queue_flush
(
IjkMessageQueue
*
q
)
{
IjkMessage
*
msg
,
*
msg1
;
SDL_LockMutex
(
q
->
mutex
);
for
(
msg
=
q
->
first_msg
;
msg
!=
NULL
;
msg
=
msg1
)
{
msg1
=
msg
->
next
;
free
(
msg
);
}
q
->
last_msg
=
NULL
;
q
->
first_msg
=
NULL
;
SDL_UnlockMutex
(
q
->
mutex
);
}
static
void
ijkmsg_queue_destroy
(
IjkMessageQueue
*
q
)
{
ijkmsg_queue_flush
(
q
);
SDL_DestroyMutex
(
q
->
mutex
);
SDL_DestroyCond
(
q
->
cond
);
}
static
void
ijkmsg_queue_abort
(
IjkMessageQueue
*
q
)
{
SDL_LockMutex
(
q
->
mutex
);
q
->
abort_request
=
1
;
SDL_CondSignal
(
q
->
cond
);
SDL_UnlockMutex
(
q
->
mutex
);
}
static
void
ijkmsg_queue_start
(
IjkMessageQueue
*
q
)
{
SDL_LockMutex
(
q
->
mutex
);
q
->
abort_request
=
0
;
ijkmsg_queue_put_private
(
q
,
&
flush_msg
);
SDL_UnlockMutex
(
q
->
mutex
);
}
/* return < 0 if aborted, 0 if no msg and > 0 if msg. */
static
int
ijkmsg_queue_get
(
IjkMessageQueue
*
q
,
IjkMessage
*
msg
,
int
block
,
int
*
serial
)
{
IjkMessage
*
msg1
;
int
ret
;
SDL_LockMutex
(
q
->
mutex
);
for
(;;)
{
if
(
q
->
abort_request
)
{
ret
=
-
1
;
break
;
}
msg1
=
q
->
first_msg
;
if
(
msg1
)
{
q
->
first_msg
=
msg1
->
next
;
if
(
!
q
->
first_msg
)
q
->
last_msg
=
NULL
;
*
msg
=
*
msg1
;
if
(
serial
)
*
serial
=
msg1
->
serial
;
free
(
msg1
);
ret
=
1
;
break
;
}
else
if
(
!
block
)
{
ret
=
0
;
break
;
}
else
{
SDL_CondWait
(
q
->
cond
,
q
->
mutex
);
}
}
SDL_UnlockMutex
(
q
->
mutex
);
return
ret
;
}
#endif
ijkmediaplayer/jni/ijkplayer/ff_ffplay_def.h
浏览文件 @
32643bb7
...
...
@@ -26,6 +26,7 @@
#include "ff_ffinc.h"
#include "ff_ffplay_config.h"
#include "ff_ffmsg_queue.h"
#define MAX_QUEUE_SIZE (15 * 1024 * 1024)
#define MIN_FRAMES 5
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录