lavd/v4l2: simplify code

struct buff_data contains a pointer to struct video_data, so passing the
file descriptor again is redundant.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Giorgio Vazzana 2013-03-09 14:46:00 +01:00 committed by Michael Niedermayer
parent 0286b42540
commit 9222978aed
1 changed files with 2 additions and 5 deletions

View File

@ -125,7 +125,6 @@ struct video_data {
struct buff_data { struct buff_data {
struct video_data *s; struct video_data *s;
int index; int index;
int fd;
}; };
struct fmt_map { struct fmt_map {
@ -483,17 +482,16 @@ static void dummy_release_buffer(AVPacket *pkt)
static void mmap_release_buffer(void *opaque, uint8_t *data) static void mmap_release_buffer(void *opaque, uint8_t *data)
{ {
struct v4l2_buffer buf = { 0 }; struct v4l2_buffer buf = { 0 };
int res, fd; int res;
struct buff_data *buf_descriptor = opaque; struct buff_data *buf_descriptor = opaque;
struct video_data *s = buf_descriptor->s; struct video_data *s = buf_descriptor->s;
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
buf.memory = V4L2_MEMORY_MMAP; buf.memory = V4L2_MEMORY_MMAP;
buf.index = buf_descriptor->index; buf.index = buf_descriptor->index;
fd = buf_descriptor->fd;
av_free(buf_descriptor); av_free(buf_descriptor);
if (v4l2_ioctl(fd, VIDIOC_QBUF, &buf) < 0) { if (v4l2_ioctl(s->fd, VIDIOC_QBUF, &buf) < 0) {
res = AVERROR(errno); res = AVERROR(errno);
av_log(NULL, AV_LOG_ERROR, "ioctl(VIDIOC_QBUF): %s\n", av_log(NULL, AV_LOG_ERROR, "ioctl(VIDIOC_QBUF): %s\n",
av_err2str(res)); av_err2str(res));
@ -643,7 +641,6 @@ static int mmap_read_frame(AVFormatContext *ctx, AVPacket *pkt)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
} }
buf_descriptor->fd = s->fd;
buf_descriptor->index = buf.index; buf_descriptor->index = buf.index;
buf_descriptor->s = s; buf_descriptor->s = s;