After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 740633 - v4l2src: RW io-mode is broken
v4l2src: RW io-mode is broken
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-good
1.4.4
Other Linux
: Normal normal
: 1.4.5
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2014-11-24 15:49 UTC by Nicolas Dufresne (ndufresne)
Modified: 2014-12-08 00:01 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Nicolas Dufresne (ndufresne) 2014-11-24 15:49:39 UTC
gst-launch-1.0 v4l2src io-mode=rw ! xvimagesinkhome/nicolas/Sources/prefix
Définition du pipeline à PAUSED...
Le pipeline est actif et n'a pas besoin de phase PREROLL...
Passage du pipeline à la phase PLAYING...
New clock: GstSystemClock

(gst-launch-1.0:17032): GLib-GObject-CRITICAL **: g_object_ref: assertion 'G_IS_OBJECT (object)' failed

(gst-launch-1.0:17032): GLib-GObject-CRITICAL **: g_object_ref: assertion 'G_IS_OBJECT (object)' failed

This is testted against a UVC driver with libv4l2 (UVC driver don't do RW, so this mean libv4l2 is emulating it).
Comment 1 Nicolas Dufresne (ndufresne) 2014-12-07 22:44:50 UTC
I can fix the RW mode, but libv4l2 RW emulation can't ever work with poll() without hacks. There is no solution to that. Basically, libv4l2 won't know it's doing READ/WRITE before the first call to read() is made. Because it's an emulation of read/write over MMAP, only on the first read() it will setup the MMAP queue and streamon. Before that, poll() will fail, but we need to call poll() before read.

Never the less, I'll add a hack that call v4l2_read(fd, NULL, 0) in bufferpool start if we have lib4l2 and the device is a streaming device (mmap). That will cause the queue to be initialized, after what poll will work normally. I'm including it since it's the only way I have to frequently test that RW isn't broken again.
Comment 2 Nicolas Dufresne (ndufresne) 2014-12-08 00:01:58 UTC
1.5:
commit 0e05faf91a476efd56adfb0d1b82e71a2d13ff89
Author: Nicolas Dufresne <nicolas.dufresne@collabora.co.uk>
Date:   Sun Dec 7 17:27:37 2014 -0500

    v4l2: Fix RW io mode
    
    In RW, allocator can be null, max_buffers can be zero, and we need not
    to wait while the queue is empty since there is no queue.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=740633

commit eb1dcd841abe80abf7b9e880e195c8a0033ea0d4
Author: Nicolas Dufresne <nicolas.dufresne@collabora.co.uk>
Date:   Sun Dec 7 17:33:51 2014 -0500

    v4l2: Workaround libv4l2 RW emulation bug
    
    When libv4l2 emulates RW mode on top of MMAP devices, the queues are
    only initialized on first read. The problem is that poll() will fail
    if called before the queues are initialized and streaming. Workaround
    this by doing a zero size read when pool is started in that IO mode.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=740633

1.4
commit 6e4044
commit 6228d1