gstreamer/sys
William Manley 56b1d088a9 v4l2: Warn, don't assert if v4l gives us a buffer with a too large size
I've seen problems where the `bytesused` field of `v4l2_buffer` would be
a silly number causing the later call to:

    gst_memory_resize (group->mem[i], 0, group->planes[i].bytesused);

to result in this error to be printed:

    (pulsevideo:11): GStreamer-CRITICAL **: gst_memory_resize: assertion 'size + mem->offset + offset <= mem->maxsize' failed

besides causing who-knows what other problems.

We make the assumption that this buffer has still been dequeued correctly
so just clamp to a valid size so downstream elements won't end up in
undefined behaviour.

The invalid `v4l2_buffer` I saw from my capture device was:

    buffer = {
      index = 0,
      type = 1,
      bytesused = 534748928, // <- Invalid
      flags = 8260, // V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC | V4L2_BUF_FLAG_ERROR | V4L2_BUF_FLAG_DONE
      field = 01330, // <- Invalid
      timestamp = {
        tv_sec = 0,
        tv_usec = 0
      },
      timecode = {
        type = 0,
        flags = 0,
        frames = 0 '\000',
        seconds = 0 '\000',
        minutes = 0 '\000',
        hours = 0 '\000',
        userbits = "\000\000\000"
      },
      sequence = 0,
      memory = 2,
      m = {
        offset = 3537219584,
        userptr = 140706665836544, // Could be nonsense, not sure
        planes = 0x7ff8d2d5b000,
        fd = -757747712
      },
      length = 2764800,
      reserved2 = 0,
      reserved = 0
    }

This is from gdb with my own annotations added.

This was with gst-plugins-good 1.8.1, a Magewell XI100DUSB-HDMI video
capture device and kernel 3.13 using a dodgy HDMI cable which is great at
breaking HDMI capture devices.  I'm using io-mode=userptr and have built
gst-plugins-good without libv4l.

https://bugzilla.gnome.org/show_bug.cgi?id=769765
2016-11-01 20:12:56 +02:00
..
directsound meson: directsound: Add ole32 library dependency 2016-10-21 06:01:16 -03:00
oss good: use new gst_element_class_add_static_pad_template() 2016-03-24 14:32:20 +02:00
oss4 oss4: remove dead mixer code 2014-05-02 09:41:19 +01:00
osxaudio osxaudio: Distribute device provider files 2016-09-07 15:35:06 -04:00
osxvideo osxvideo: Remove QuickTime references. 2016-08-31 05:52:37 +10:00
sunaudio good: use new gst_element_class_add_static_pad_template() 2016-03-24 14:32:20 +02:00
v4l2 v4l2: Warn, don't assert if v4l gives us a buffer with a too large size 2016-11-01 20:12:56 +02:00
waveform waveformsink: Fix Memory leak using GST_PTR_FORMAT 2016-10-20 13:14:10 +03:00
ximage Add support for Meson as alternative/parallel build system 2016-08-20 11:21:12 +01:00
Makefile.am v4l2: Fix typo V4L_DIR intead of V4L2_DIR 2014-03-15 18:41:16 +01:00
meson.build Add support for Meson as alternative/parallel build system 2016-08-20 11:21:12 +01:00