From 3c9f2bef92c1b78cc1a72dad77223eb210109ece Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 25 Oct 2014 16:34:56 +0200 Subject: tv: unqueue buffers correctly (maybe, maybe not) I clue no idea what I'm doing, but at least it doesn't hang anymore when closing a tv:// stream using a v4l2 loopback device. --- stream/tvi_v4l2.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/stream/tvi_v4l2.c b/stream/tvi_v4l2.c index f339b83439..2a2dae76ba 100644 --- a/stream/tvi_v4l2.c +++ b/stream/tvi_v4l2.c @@ -1012,11 +1012,13 @@ static int uninit(priv_t *priv) } priv->streamon = 0; - /* unqueue all remaining buffers */ - memset(&buf,0,sizeof(buf)); - buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - buf.memory = V4L2_MEMORY_MMAP; - while (!v4l2_ioctl(priv->video_fd, VIDIOC_DQBUF, &buf)); + /* unqueue all remaining buffers (not sure if this code is correct) */ + for (i = 0; i < priv->mapcount; i++) { + if (v4l2_ioctl(priv->video_fd, VIDIOC_DQBUF, &priv->map[i].buf) < 0) { + MP_ERR(priv, "%s: VIDIOC_DQBUF failed: %s\n", + info.short_name, strerror(errno)); + } + } } /* unmap all buffers */ -- cgit v1.2.3