Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
3a165c18
Commit
3a165c18
authored
Jul 17, 2016
by
Anton Khirnov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
v4l2: convert to stdatomic
parent
27079a42
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
9 deletions
+9
-9
v4l2.c
libavdevice/v4l2.c
+9
-9
No files found.
libavdevice/v4l2.c
View file @
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
"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment