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 591747 - [v4l2src] should clear formats list when it closes the device
[v4l2src] should clear formats list when it closes the device
Product: GStreamer
Classification: Platform
Component: gst-plugins-good
git master
Other Linux
: Normal normal
: 0.10.16
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Reported: 2009-08-13 21:07 UTC by Filippo Argiolas
Modified: 2009-08-14 09:19 UTC
See Also:
GNOME target: ---
GNOME version: ---

Super quick patch that tries to address the issue (1.13 KB, patch)
2009-08-13 21:32 UTC, Filippo Argiolas
none Details | Review
Updated patch for current tree (1.44 KB, patch)
2009-08-14 08:15 UTC, Filippo Argiolas
committed Details | Review

Description Filippo Argiolas 2009-08-13 21:07:10 UTC
Currently v4l2src calls gst_v4l2src_clear_format_list in the dispose method so if you set the element to NULL, change the device and set it to READY again it doesn't refresh its formats list and sets caps from the previous device format list.
At a quick glance I'd say it should be better to call clear_format_list and unref probed_caps in the stop method so that it gets called on READY->NULL.
Comment 1 Filippo Argiolas 2009-08-13 21:09:59 UTC
Well, probably better to call it in the actual READY to NULL state change.
Comment 2 Filippo Argiolas 2009-08-13 21:19:15 UTC
If it is meant to cache formats list and probed caps while closing and reopening the same device we should at least force a clear_formats call when a new device is set.
Comment 3 Filippo Argiolas 2009-08-13 21:32:33 UTC
Created attachment 140707 [details] [review]
Super quick patch that tries to address the issue
Comment 4 Tim-Philipp Müller 2009-08-13 23:13:32 UTC
Looks good, feel free to commit it if you want to get it in for the release.
Comment 5 Filippo Argiolas 2009-08-14 07:20:16 UTC
Seems I was working on a old checkout (I'm pretty sure I did a git pull but I must have been in gst-plugins-base dir when I did it :P).

Now clear_format_list has been moved in gstv4l2object.c, new patch following this morning.
Comment 6 Filippo Argiolas 2009-08-14 08:15:45 UTC
Created attachment 140744 [details] [review]
Updated patch for current tree
Comment 7 Tim-Philipp Müller 2009-08-14 08:41:34 UTC
Is there a reason why you clear the formats in _stop(), but then the caps in the state change function?

In any case, please commit.
Comment 8 Filippo Argiolas 2009-08-14 08:54:32 UTC
Actually it all happens in the state change function:

      /* close the device */
      if (!gst_v4l2_object_stop (v4l2src->v4l2object))

      if (v4l2src->probed_caps) {
        gst_caps_unref (v4l2src->probed_caps);
        v4l2src->probed_caps = NULL;

The difference now is that clear_formats belongs to v4l2object.c and it's not public so I moved it in gst_v4l2_object_stop that is called anyway in the READY to NULL transition. On the other hand probed_caps belongs to v4l2src so cannot be unreferenced in gst_v4l2_object_stop.
Comment 9 Filippo Argiolas 2009-08-14 08:56:34 UTC
commit a3a61f89403cd39fd08f2f1d0e1475f55b0a48f4
Author: Filippo Argiolas <>
Date:   Fri Aug 14 10:11:25 2009 +0200

    v4l2src: clear format list in READY->NULL
    Clear format list and probed caps when going to NULL so if a new device
    is set we'll probe the formats again instead of using previously
    detected ones. Fixes bug #591747.