GNOME Bugzilla – Bug 591747
[v4l2src] should clear formats list when it closes the device
Last modified: 2009-08-14 09:19:02 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.
Well, probably better to call it in the actual READY to NULL state change.
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.
Created attachment 140707 [details] [review] Super quick patch that tries to address the issue
Looks good, feel free to commit it if you want to get it in for the release.
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.
Created attachment 140744 [details] [review] Updated patch for current tree
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.
Actually it all happens in the state change function: case GST_STATE_CHANGE_READY_TO_NULL: /* close the device */ if (!gst_v4l2_object_stop (v4l2src->v4l2object)) return GST_STATE_CHANGE_FAILURE; 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.
commit a3a61f89403cd39fd08f2f1d0e1475f55b0a48f4 Author: Filippo Argiolas <filippo.argiolas@gmail.com> 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.