Commit 18442e84 authored by lucabe's avatar lucabe

Support for the AVFMT_FLAG_NONBLOCK flag (non-blocking input) in v4l2.c


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@9496 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent 61d77ab3
...@@ -119,8 +119,12 @@ static int device_open(AVFormatContext *ctx, uint32_t *capabilities) ...@@ -119,8 +119,12 @@ static int device_open(AVFormatContext *ctx, uint32_t *capabilities)
struct v4l2_capability cap; struct v4l2_capability cap;
int fd; int fd;
int res; int res;
int flags = O_RDWR;
fd = open(ctx->filename, O_RDWR /*| O_NONBLOCK*/, 0); if (ctx->flags & AVFMT_FLAG_NONBLOCK) {
flags |= O_NONBLOCK;
}
fd = open(ctx->filename, flags, 0);
if (fd < 0) { if (fd < 0) {
av_log(ctx, AV_LOG_ERROR, "Cannot open video device %s : %s\n", av_log(ctx, AV_LOG_ERROR, "Cannot open video device %s : %s\n",
ctx->filename, strerror(errno)); ctx->filename, strerror(errno));
...@@ -331,9 +335,13 @@ static int mmap_read_frame(AVFormatContext *ctx, AVPacket *pkt) ...@@ -331,9 +335,13 @@ static int mmap_read_frame(AVFormatContext *ctx, AVPacket *pkt)
buf.memory = V4L2_MEMORY_MMAP; buf.memory = V4L2_MEMORY_MMAP;
/* FIXME: Some special treatment might be needed in case of loss of signal... */ /* FIXME: Some special treatment might be needed in case of loss of signal... */
while ((res = ioctl(s->fd, VIDIOC_DQBUF, &buf)) < 0 && while ((res = ioctl(s->fd, VIDIOC_DQBUF, &buf)) < 0 && (errno == EINTR));
((errno == EAGAIN) || (errno == EINTR)));
if (res < 0) { if (res < 0) {
if (errno == EAGAIN) {
pkt->size = 0;
return AVERROR(EAGAIN);
}
av_log(ctx, AV_LOG_ERROR, "ioctl(VIDIOC_DQBUF): %s\n", strerror(errno)); av_log(ctx, AV_LOG_ERROR, "ioctl(VIDIOC_DQBUF): %s\n", strerror(errno));
return -1; return -1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment