-
Notifications
You must be signed in to change notification settings - Fork 538
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: Our producer is always getting the same (shared mem) buffer and so does the example producer #607
Comments
Can you provide a link to your source code? I think QBUF needs to be called on all buffers when streaming begins. |
@stephematician , the source code is simply that of the producer and consumer in the tests folder of v4l2loopback itself. If you run that producer, it already mentions that it is always getting the same buffer on every dqbuf (irrespective of whether a consumer is running or not). |
Looks like this was introduced in 97dc86b? NFI if this was intended. v4l2loopback maintains an 'outbuffer list'; It looks like that when dequeue occurs it returns the tail of that list, then moves the tail to ... the tail. It absolutely looks like a bug to me; and isn't linked to any 'issue' that I can find. b = list_entry(dev->outbufs_list.prev, struct v4l2l_buffer,
list_head);
list_move_tail(&b->list_head, &dev->outbufs_list); The use of
That macro has existed since 2.6.22; it might be good practise to use it here rather than relying on things internal to list_head. |
This is what I get from producer if I revert the commit - looks good to me? user@home:~v4l2loopback/tests$ sudo modprobe v4l2loopback max_buffers=4 video_nr=10
user@home:~v4l2loopback/tests$ ./producer -c 6 -d /dev/video10
get format: OUTPUT:640x480:YUYV bytes/line=1280 sizeimage=614400 field=none
tried format: OUTPUT:640x480:YUYV bytes/line=1280 sizeimage=614400 field=none
got format: OUTPUT:640x480:YUYV bytes/line=1280 sizeimage=614400 field=none
set format: OUTPUT:640x480:YUYV bytes/line=1280 sizeimage=614400 field=none
finalizing format: OUTPUT:640x480:YUYV bytes/line=1280 sizeimage=614400 field=none
final format: OUTPUT:640x480:YUYV bytes/line=1280 sizeimage=614400 field=none
requested 4 buffers, got 4
requested buffer 0/4: buffer#0 @ 0x7fff413ce0e0 OUTPUT bytesused=614400, length=614400 flags=0x00002002 field=none timestamp=40138.746690 memory=MMAP (offset=0)
buffer#0 @0x7d8386c40000 of 614400 bytes
requested buffer 1/4: buffer#1 @ 0x7fff413ce0e0 OUTPUT bytesused=614400, length=614400 flags=0x00002002 field=none timestamp=40138.746691 memory=MMAP (offset=614400)
buffer#1 @0x7d838696a000 of 614400 bytes
requested buffer 2/4: buffer#2 @ 0x7fff413ce0e0 OUTPUT bytesused=614400, length=614400 flags=0x00002002 field=none timestamp=40138.746692 memory=MMAP (offset=1228800)
buffer#2 @0x7d83868d4000 of 614400 bytes
requested buffer 3/4: buffer#3 @ 0x7fff413ce0e0 OUTPUT bytesused=614400, length=614400 flags=0x00002002 field=none timestamp=40138.746693 memory=MMAP (offset=1843200)
buffer#3 @0x7d838683e000 of 614400 bytes
MMAP init qbuf 0/4 (length=614400): buffer#0 @ 0x7fff413ce2b0 OUTPUT bytesused=614400, length=614400 flags=0x00000000 field=any timestamp=0.000000 memory=MMAP (offset=0)
MMAP init qbuf 1/4 (length=614400): buffer#1 @ 0x7fff413ce2b0 OUTPUT bytesused=614400, length=614400 flags=0x00000000 field=any timestamp=0.000000 memory=MMAP (offset=0)
MMAP init qbuf 2/4 (length=614400): buffer#2 @ 0x7fff413ce2b0 OUTPUT bytesused=614400, length=614400 flags=0x00000000 field=any timestamp=0.000000 memory=MMAP (offset=0)
MMAP init qbuf 3/4 (length=614400): buffer#3 @ 0x7fff413ce2b0 OUTPUT bytesused=614400, length=614400 flags=0x00000000 field=any timestamp=0.000000 memory=MMAP (offset=0)
MMAP buffer#0 @ 0x7fff413ce290 OUTPUT bytesused=614400, length=614400 flags=0x00002001 field=none timestamp=0.000000 memory=MMAP (offset=0)
MMAP buffer#1 @ 0x7fff413ce290 OUTPUT bytesused=614400, length=614400 flags=0x00002001 field=none timestamp=0.000000 memory=MMAP (offset=614400)
MMAP buffer#2 @ 0x7fff413ce290 OUTPUT bytesused=614400, length=614400 flags=0x00002001 field=none timestamp=0.000000 memory=MMAP (offset=1228800)
MMAP buffer#3 @ 0x7fff413ce290 OUTPUT bytesused=614400, length=614400 flags=0x00002001 field=none timestamp=0.000000 memory=MMAP (offset=1843200)
MMAP buffer#0 @ 0x7fff413ce290 OUTPUT bytesused=614400, length=614400 flags=0x00002001 field=none timestamp=0.000000 memory=MMAP (offset=0)
MMAP buffer#1 @ 0x7fff413ce290 OUTPUT bytesused=614400, length=614400 flags=0x00002001 field=none timestamp=0.000000 memory=MMAP (offset=614400) If I invoke consumer in a separate terminal while the producer is running (invoked with more frames so it runs long enough for me to switch to a new terminal): user@home:~v4l2loopback/tests$ ./consumer -d /dev/video10
got format: CAPTURE:640x480:YUYV bytes/line=1280 sizeimage=614400 field=none
set format: CAPTURE:640x480:YUYV bytes/line=1280 sizeimage=614400 field=none
requested 4 buffers, got 4
requested buffer 0/4: buffer#0 @ 0x7ffe9330f8d0 CAPTURE bytesused=614400, length=614400 flags=0x00002002 field=none timestamp=40304.269190 memory=MMAP (offset=0)
requested buffer 1/4: buffer#1 @ 0x7ffe9330f8d0 CAPTURE bytesused=614400, length=614400 flags=0x00002002 field=none timestamp=40304.269190 memory=MMAP (offset=614400)
requested buffer 2/4: buffer#2 @ 0x7ffe9330f8d0 CAPTURE bytesused=614400, length=614400 flags=0x00002002 field=none timestamp=40304.269191 memory=MMAP (offset=1228800)
requested buffer 3/4: buffer#3 @ 0x7ffe9330f8d0 CAPTURE bytesused=614400, length=614400 flags=0x00002002 field=none timestamp=40304.269192 memory=MMAP (offset=1843200)
MMAP buffer#3 @ 0x7ffe9330fde0 CAPTURE bytesused=614400, length=614400 flags=0x00002001 field=none timestamp=40304.269192 memory=MMAP (offset=1843200)
MMAP buffer#0 @ 0x7ffe9330fde0 CAPTURE bytesused=614400, length=614400 flags=0x00002001 field=none timestamp=40304.289982 memory=MMAP (offset=0)
MMAP buffer#1 @ 0x7ffe9330fde0 CAPTURE bytesused=614400, length=614400 flags=0x00002001 field=none timestamp=40304.326207 memory=MMAP (offset=614400)
MMAP buffer#2 @ 0x7ffe9330fde0 CAPTURE bytesused=614400, length=614400 flags=0x00002001 field=none timestamp=40304.362905 memory=MMAP (offset=1228800)
MMAP buffer#3 @ 0x7ffe9330fde0 CAPTURE bytesused=614400, length=614400 flags=0x00002001 field=none timestamp=40304.400182 memory=MMAP (offset=1843200)
MMAP buffer#0 @ 0x7ffe9330fde0 CAPTURE bytesused=614400, length=614400 flags=0x00002001 field=none timestamp=40304.436792 memory=MMAP (offset=0)
MMAP buffer#1 @ 0x7ffe9330fde0 CAPTURE bytesused=614400, length=614400 flags=0x00002001 field=none timestamp=40304.473265 memory=MMAP (offset=614400) |
Is there an existing issue for this?
Detail
Notice that also this producer is always getting buffer#1 despite having received 2 buffers at initialization.
So, is this a huge bug in v4l2loopback or are we totally missing how passing buffers through v4l2loopback is supposed to work?
OS Version
Ubuntu 24.04.1 LTS
Which CPU are you using?
amd64/x86_64 ("64bit Intel"), arm64 ("64bit ARM"; e.g. Apple Silicon,...)
The text was updated successfully, but these errors were encountered: