Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小白菜888
Ffmpeg
提交
3a165c18
F
Ffmpeg
项目概览
小白菜888
/
Ffmpeg
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
Ffmpeg
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3a165c18
编写于
7月 17, 2016
作者:
A
Anton Khirnov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
v4l2: convert to stdatomic
上级
27079a42
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
9 addition
and
9 deletion
+9
-9
libavdevice/v4l2.c
libavdevice/v4l2.c
+9
-9
未找到文件。
libavdevice/v4l2.c
浏览文件 @
3a165c18
...
...
@@ -33,6 +33,7 @@
#include "libavformat/internal.h"
#include <unistd.h>
#include <fcntl.h>
#include <stdatomic.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/time.h>
...
...
@@ -42,7 +43,6 @@
#else
#include <linux/videodev2.h>
#endif
#include "libavutil/atomic.h"
#include "libavutil/avassert.h"
#include "libavutil/imgutils.h"
#include "libavutil/internal.h"
...
...
@@ -70,7 +70,7 @@ struct video_data {
int
top_field_first
;
int
buffers
;
volatile
int
buffers_queued
;
atomic_
int
buffers_queued
;
void
**
buf_start
;
unsigned
int
*
buf_len
;
char
*
standard
;
...
...
@@ -441,7 +441,7 @@ static void mmap_release_buffer(void *opaque, uint8_t *data)
av_log
(
NULL
,
AV_LOG_ERROR
,
"ioctl(VIDIOC_QBUF): %s
\n
"
,
errbuf
);
}
a
vpriv_atomic_int_add_and_fetch
(
&
s
->
buffers_queued
,
1
);
a
tomic_fetch_add
(
&
s
->
buffers_queued
,
1
);
}
static
int
mmap_read_frame
(
AVFormatContext
*
ctx
,
AVPacket
*
pkt
)
...
...
@@ -482,9 +482,9 @@ static int mmap_read_frame(AVFormatContext *ctx, AVPacket *pkt)
av_log
(
ctx
,
AV_LOG_ERROR
,
"Invalid buffer index received.
\n
"
);
return
AVERROR
(
EINVAL
);
}
a
vpriv_atomic_int_add_and_fetch
(
&
s
->
buffers_queued
,
-
1
);
a
tomic_fetch_add
(
&
s
->
buffers_queued
,
-
1
);
// always keep at least one buffer queued
av_assert0
(
a
vpriv_atomic_int_get
(
&
s
->
buffers_queued
)
>=
1
);
av_assert0
(
a
tomic_load
(
&
s
->
buffers_queued
)
>=
1
);
if
(
s
->
frame_size
>
0
&&
buf
.
bytesused
!=
s
->
frame_size
)
{
av_log
(
ctx
,
AV_LOG_ERROR
,
...
...
@@ -495,7 +495,7 @@ static int mmap_read_frame(AVFormatContext *ctx, AVPacket *pkt)
}
/* Image is at s->buff_start[buf.index] */
if
(
a
vpriv_atomic_int_get
(
&
s
->
buffers_queued
)
==
FFMAX
(
s
->
buffers
/
8
,
1
))
{
if
(
a
tomic_load
(
&
s
->
buffers_queued
)
==
FFMAX
(
s
->
buffers
/
8
,
1
))
{
/* when we start getting low on queued buffers, fall back on copying data */
res
=
av_new_packet
(
pkt
,
buf
.
bytesused
);
if
(
res
<
0
)
{
...
...
@@ -511,7 +511,7 @@ static int mmap_read_frame(AVFormatContext *ctx, AVPacket *pkt)
av_packet_unref
(
pkt
);
return
res
;
}
a
vpriv_atomic_int_add_and_fetch
(
&
s
->
buffers_queued
,
1
);
a
tomic_fetch_add
(
&
s
->
buffers_queued
,
1
);
}
else
{
struct
buff_data
*
buf_descriptor
;
...
...
@@ -568,7 +568,7 @@ static int mmap_start(AVFormatContext *ctx)
return
err
;
}
}
s
->
buffers_queued
=
s
->
buffers
;
atomic_store
(
&
s
->
buffers_queued
,
s
->
buffers
)
;
type
=
V4L2_BUF_TYPE_VIDEO_CAPTURE
;
res
=
ioctl
(
s
->
fd
,
VIDIOC_STREAMON
,
&
type
);
...
...
@@ -881,7 +881,7 @@ static int v4l2_read_close(AVFormatContext *s1)
{
struct
video_data
*
s
=
s1
->
priv_data
;
if
(
a
vpriv_atomic_int_get
(
&
s
->
buffers_queued
)
!=
s
->
buffers
)
if
(
a
tomic_load
(
&
s
->
buffers_queued
)
!=
s
->
buffers
)
av_log
(
s1
,
AV_LOG_WARNING
,
"Some buffers are still owned by the caller on "
"close.
\n
"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录