Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FFmpeg
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
libremedia
Tethys
FFmpeg
Commits
3a165c18
Commit
3a165c18
authored
8 years ago
by
Anton Khirnov
Browse files
Options
Downloads
Patches
Plain Diff
v4l2: convert to stdatomic
parent
27079a42
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
libavdevice/v4l2.c
+9
-9
9 additions, 9 deletions
libavdevice/v4l2.c
with
9 additions
and
9 deletions
libavdevice/v4l2.c
+
9
−
9
View file @
3a165c18
...
@@ -33,6 +33,7 @@
...
@@ -33,6 +33,7 @@
#include
"libavformat/internal.h"
#include
"libavformat/internal.h"
#include
<unistd.h>
#include
<unistd.h>
#include
<fcntl.h>
#include
<fcntl.h>
#include
<stdatomic.h>
#include
<sys/ioctl.h>
#include
<sys/ioctl.h>
#include
<sys/mman.h>
#include
<sys/mman.h>
#include
<sys/time.h>
#include
<sys/time.h>
...
@@ -42,7 +43,6 @@
...
@@ -42,7 +43,6 @@
#else
#else
#include
<linux/videodev2.h>
#include
<linux/videodev2.h>
#endif
#endif
#include
"libavutil/atomic.h"
#include
"libavutil/avassert.h"
#include
"libavutil/avassert.h"
#include
"libavutil/imgutils.h"
#include
"libavutil/imgutils.h"
#include
"libavutil/internal.h"
#include
"libavutil/internal.h"
...
@@ -70,7 +70,7 @@ struct video_data {
...
@@ -70,7 +70,7 @@ struct video_data {
int
top_field_first
;
int
top_field_first
;
int
buffers
;
int
buffers
;
volatile
int
buffers_queued
;
atomic_
int
buffers_queued
;
void
**
buf_start
;
void
**
buf_start
;
unsigned
int
*
buf_len
;
unsigned
int
*
buf_len
;
char
*
standard
;
char
*
standard
;
...
@@ -441,7 +441,7 @@ static void mmap_release_buffer(void *opaque, uint8_t *data)
...
@@ -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
"
,
av_log
(
NULL
,
AV_LOG_ERROR
,
"ioctl(VIDIOC_QBUF): %s
\n
"
,
errbuf
);
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
)
static
int
mmap_read_frame
(
AVFormatContext
*
ctx
,
AVPacket
*
pkt
)
...
@@ -482,9 +482,9 @@ 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
"
);
av_log
(
ctx
,
AV_LOG_ERROR
,
"Invalid buffer index received.
\n
"
);
return
AVERROR
(
EINVAL
);
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
// 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
)
{
if
(
s
->
frame_size
>
0
&&
buf
.
bytesused
!=
s
->
frame_size
)
{
av_log
(
ctx
,
AV_LOG_ERROR
,
av_log
(
ctx
,
AV_LOG_ERROR
,
...
@@ -495,7 +495,7 @@ static int mmap_read_frame(AVFormatContext *ctx, AVPacket *pkt)
...
@@ -495,7 +495,7 @@ static int mmap_read_frame(AVFormatContext *ctx, AVPacket *pkt)
}
}
/* Image is at s->buff_start[buf.index] */
/* 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 */
/* when we start getting low on queued buffers, fall back on copying data */
res
=
av_new_packet
(
pkt
,
buf
.
bytesused
);
res
=
av_new_packet
(
pkt
,
buf
.
bytesused
);
if
(
res
<
0
)
{
if
(
res
<
0
)
{
...
@@ -511,7 +511,7 @@ static int mmap_read_frame(AVFormatContext *ctx, AVPacket *pkt)
...
@@ -511,7 +511,7 @@ static int mmap_read_frame(AVFormatContext *ctx, AVPacket *pkt)
av_packet_unref
(
pkt
);
av_packet_unref
(
pkt
);
return
res
;
return
res
;
}
}
a
vpriv_atomic_int_add_and_fetch
(
&
s
->
buffers_queued
,
1
);
a
tomic_fetch_add
(
&
s
->
buffers_queued
,
1
);
}
else
{
}
else
{
struct
buff_data
*
buf_descriptor
;
struct
buff_data
*
buf_descriptor
;
...
@@ -568,7 +568,7 @@ static int mmap_start(AVFormatContext *ctx)
...
@@ -568,7 +568,7 @@ static int mmap_start(AVFormatContext *ctx)
return
err
;
return
err
;
}
}
}
}
s
->
buffers_queued
=
s
->
buffers
;
atomic_store
(
&
s
->
buffers_queued
,
s
->
buffers
)
;
type
=
V4L2_BUF_TYPE_VIDEO_CAPTURE
;
type
=
V4L2_BUF_TYPE_VIDEO_CAPTURE
;
res
=
ioctl
(
s
->
fd
,
VIDIOC_STREAMON
,
&
type
);
res
=
ioctl
(
s
->
fd
,
VIDIOC_STREAMON
,
&
type
);
...
@@ -881,7 +881,7 @@ static int v4l2_read_close(AVFormatContext *s1)
...
@@ -881,7 +881,7 @@ static int v4l2_read_close(AVFormatContext *s1)
{
{
struct
video_data
*
s
=
s1
->
priv_data
;
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 "
av_log
(
s1
,
AV_LOG_WARNING
,
"Some buffers are still owned by the caller on "
"close.
\n
"
);
"close.
\n
"
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment