Commit f1fa0918 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

v4l2: remove unneeded demux_sys_t.io

parent a1cd839e
...@@ -41,20 +41,11 @@ ...@@ -41,20 +41,11 @@
#include "v4l2.h" #include "v4l2.h"
/* TODO: remove this, use callbacks */
typedef enum {
IO_METHOD_READ=1,
IO_METHOD_MMAP,
} io_method;
struct demux_sys_t struct demux_sys_t
{ {
int fd; int fd;
vlc_thread_t thread; vlc_thread_t thread;
/* Video */
io_method io;
struct buffer_t *bufv; struct buffer_t *bufv;
union union
{ {
...@@ -480,14 +471,12 @@ static int InitVideo (demux_t *demux, int fd) ...@@ -480,14 +471,12 @@ static int InitVideo (demux_t *demux, int fd)
msg_Err (demux, "cannot start streaming: %m"); msg_Err (demux, "cannot start streaming: %m");
return -1; return -1;
} }
sys->io = IO_METHOD_MMAP;
entry = StreamThread; entry = StreamThread;
} }
else if (caps & V4L2_CAP_READWRITE) else if (caps & V4L2_CAP_READWRITE)
{ {
sys->bufv = NULL;
sys->blocksize = fmt.fmt.pix.sizeimage; sys->blocksize = fmt.fmt.pix.sizeimage;
sys->io = IO_METHOD_READ;
entry = ReadThread; entry = ReadThread;
} }
else else
...@@ -511,30 +500,22 @@ void DemuxClose( vlc_object_t *obj ) ...@@ -511,30 +500,22 @@ void DemuxClose( vlc_object_t *obj )
vlc_join (sys->thread, NULL); vlc_join (sys->thread, NULL);
/* Stop video capture */ /* Stop video capture */
switch( sys->io ) if (sys->bufv != NULL)
{
case IO_METHOD_READ:
/* Nothing to do */
break;
case IO_METHOD_MMAP:
{ {
/* NOTE: Some buggy drivers hang if buffers are not unmapped before
* streamoff */
for (uint32_t i = 0; i < sys->bufc; i++) for (uint32_t i = 0; i < sys->bufc; i++)
{ {
struct v4l2_buffer buf = { struct v4l2_buffer buf = {
.type = V4L2_BUF_TYPE_VIDEO_CAPTURE, .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
.memory = V4L2_MEMORY_MMAP, .memory = V4L2_MEMORY_MMAP,
}; };
v4l2_ioctl (fd, VIDIOC_DQBUF, &buf); v4l2_ioctl (fd, VIDIOC_DQBUF, &buf);
v4l2_munmap (sys->bufv[i].start, sys->bufv[i].length); v4l2_munmap (sys->bufv[i].start, sys->bufv[i].length);
} }
enum v4l2_buf_type buf_type = V4L2_BUF_TYPE_VIDEO_CAPTURE; enum v4l2_buf_type buf_type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
v4l2_ioctl (fd, VIDIOC_STREAMOFF, &buf_type); v4l2_ioctl (fd, VIDIOC_STREAMOFF, &buf_type);
free (sys->bufv); free (sys->bufv);
break;
}
} }
ControlsDeinit( obj, sys->controls ); ControlsDeinit( obj, sys->controls );
......
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