aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Matthews <le.businessman@gmail.com>2014-11-05 15:09:40 -0500
committerLuca Barbato <lu_zero@gentoo.org>2014-11-09 12:29:59 +0100
commita1a259881fa7b23e2ffc0c2a43d4923fe42d0478 (patch)
tree7c3ea73d856298e30f8ac49cd7156031d543612c
parente3e317e0c015b164b6c2eb8913e393216d78de23 (diff)
downloadffmpeg-a1a259881fa7b23e2ffc0c2a43d4923fe42d0478.tar.gz
v4l2: Use av_strerror
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
-rw-r--r--libavdevice/v4l2.c49
1 files changed, 34 insertions, 15 deletions
diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c
index e210dc4b29..3439325045 100644
--- a/libavdevice/v4l2.c
+++ b/libavdevice/v4l2.c
@@ -119,6 +119,7 @@ static int device_open(AVFormatContext *ctx)
int fd;
int res, err;
int flags = O_RDWR;
+ char errbuf[128];
if (ctx->flags & AVFMT_FLAG_NONBLOCK) {
flags |= O_NONBLOCK;
@@ -126,19 +127,21 @@ static int device_open(AVFormatContext *ctx)
fd = avpriv_open(ctx->filename, flags);
if (fd < 0) {
- err = errno;
+ err = AVERROR(errno);
+ av_strerror(err, errbuf, sizeof(errbuf));
av_log(ctx, AV_LOG_ERROR, "Cannot open video device %s : %s\n",
- ctx->filename, strerror(err));
+ ctx->filename, errbuf);
- return AVERROR(err);
+ return err;
}
res = ioctl(fd, VIDIOC_QUERYCAP, &cap);
if (res < 0) {
err = errno;
+ av_strerror(AVERROR(err), errbuf, sizeof(errbuf));
av_log(ctx, AV_LOG_ERROR, "ioctl(VIDIOC_QUERYCAP): %s\n",
- strerror(err));
+ errbuf);
goto fail;
}
@@ -401,7 +404,9 @@ static int mmap_init(AVFormatContext *ctx)
s->fd, buf.m.offset);
if (s->buf_start[i] == MAP_FAILED) {
- av_log(ctx, AV_LOG_ERROR, "mmap: %s\n", strerror(errno));
+ char errbuf[128];
+ av_strerror(AVERROR(errno), errbuf, sizeof(errbuf));
+ av_log(ctx, AV_LOG_ERROR, "mmap: %s\n", errbuf);
return AVERROR(errno);
}
@@ -423,6 +428,7 @@ static void mmap_release_buffer(void *opaque, uint8_t *data)
int res, fd;
struct buff_data *buf_descriptor = opaque;
struct video_data *s = buf_descriptor->s;
+ char errbuf[128];
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
buf.memory = V4L2_MEMORY_MMAP;
@@ -431,9 +437,11 @@ static void mmap_release_buffer(void *opaque, uint8_t *data)
av_free(buf_descriptor);
res = ioctl(fd, VIDIOC_QBUF, &buf);
- if (res < 0)
+ if (res < 0) {
+ av_strerror(AVERROR(errno), errbuf, sizeof(errbuf));
av_log(NULL, AV_LOG_ERROR, "ioctl(VIDIOC_QBUF): %s\n",
- strerror(errno));
+ errbuf);
+ }
avpriv_atomic_int_add_and_fetch(&s->buffers_queued, 1);
}
@@ -457,13 +465,15 @@ static int mmap_read_frame(AVFormatContext *ctx, AVPacket *pkt)
/* FIXME: Some special treatment might be needed in case of loss of signal... */
while ((res = ioctl(s->fd, VIDIOC_DQBUF, &buf)) < 0 && (errno == EINTR));
if (res < 0) {
+ char errbuf[128];
if (errno == EAGAIN) {
pkt->size = 0;
return AVERROR(EAGAIN);
}
+ av_strerror(AVERROR(errno), errbuf, sizeof(errbuf));
av_log(ctx, AV_LOG_ERROR, "ioctl(VIDIOC_DQBUF): %s\n",
- strerror(errno));
+ errbuf);
return AVERROR(errno);
}
@@ -542,7 +552,8 @@ static int mmap_start(AVFormatContext *ctx)
{
struct video_data *s = ctx->priv_data;
enum v4l2_buf_type type;
- int i, res;
+ int i, res, err;
+ char errbuf[128];
for (i = 0; i < s->buffers; i++) {
struct v4l2_buffer buf = {
@@ -553,10 +564,12 @@ static int mmap_start(AVFormatContext *ctx)
res = ioctl(s->fd, VIDIOC_QBUF, &buf);
if (res < 0) {
+ err = AVERROR(errno);
+ av_strerror(err, errbuf, sizeof(errbuf));
av_log(ctx, AV_LOG_ERROR, "ioctl(VIDIOC_QBUF): %s\n",
- strerror(errno));
+ errbuf);
- return AVERROR(errno);
+ return err;
}
}
s->buffers_queued = s->buffers;
@@ -564,10 +577,12 @@ static int mmap_start(AVFormatContext *ctx)
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
res = ioctl(s->fd, VIDIOC_STREAMON, &type);
if (res < 0) {
+ err = AVERROR(errno);
+ av_strerror(err, errbuf, sizeof(errbuf));
av_log(ctx, AV_LOG_ERROR, "ioctl(VIDIOC_STREAMON): %s\n",
- strerror(errno));
+ errbuf);
- return AVERROR(errno);
+ return err;
}
return 0;
@@ -677,8 +692,10 @@ static int v4l2_set_parameters(AVFormatContext *s1)
}
} else {
if (ioctl(s->fd, VIDIOC_G_PARM, &streamparm) != 0) {
+ char errbuf[128];
+ av_strerror(AVERROR(errno), errbuf, sizeof(errbuf));
av_log(s1, AV_LOG_ERROR, "ioctl(VIDIOC_G_PARM): %s\n",
- strerror(errno));
+ errbuf);
return AVERROR(errno);
}
}
@@ -779,8 +796,10 @@ static int v4l2_read_header(AVFormatContext *s1)
"Querying the device for the current frame size\n");
fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
if (ioctl(s->fd, VIDIOC_G_FMT, &fmt) < 0) {
+ char errbuf[128];
+ av_strerror(AVERROR(errno), errbuf, sizeof(errbuf));
av_log(s1, AV_LOG_ERROR, "ioctl(VIDIOC_G_FMT): %s\n",
- strerror(errno));
+ errbuf);
return AVERROR(errno);
}