aboutsummaryrefslogtreecommitdiffstats
path: root/libavdevice/v4l2.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2016-07-17 22:24:35 +0200
committerAnton Khirnov <anton@khirnov.net>2016-10-02 19:34:57 +0200
commit3a165c187da7d74f46f6c1778294e8c5a3a7151f (patch)
treed85cc31386756000253d68440f652959444d8072 /libavdevice/v4l2.c
parent27079a426c9d3db918b158976e44b9b143d78e1c (diff)
downloadffmpeg-3a165c187da7d74f46f6c1778294e8c5a3a7151f.tar.gz
v4l2: convert to stdatomic
Diffstat (limited to 'libavdevice/v4l2.c')
-rw-r--r--libavdevice/v4l2.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c
index 47241e47a1..0479121d7d 100644
--- a/libavdevice/v4l2.c
+++ b/libavdevice/v4l2.c
@@ -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);
}
- avpriv_atomic_int_add_and_fetch(&s->buffers_queued, 1);
+ atomic_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);
}
- avpriv_atomic_int_add_and_fetch(&s->buffers_queued, -1);
+ atomic_fetch_add(&s->buffers_queued, -1);
// always keep at least one buffer queued
- av_assert0(avpriv_atomic_int_get(&s->buffers_queued) >= 1);
+ av_assert0(atomic_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 (avpriv_atomic_int_get(&s->buffers_queued) == FFMAX(s->buffers / 8, 1)) {
+ if (atomic_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;
}
- avpriv_atomic_int_add_and_fetch(&s->buffers_queued, 1);
+ atomic_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 (avpriv_atomic_int_get(&s->buffers_queued) != s->buffers)
+ if (atomic_load(&s->buffers_queued) != s->buffers)
av_log(s1, AV_LOG_WARNING, "Some buffers are still owned by the caller on "
"close.\n");