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 791338 - v4l2videoenc: calling S_FMT after REQBUFS fails
v4l2videoenc: calling S_FMT after REQBUFS fails
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-good
git master
Other Linux
: Normal normal
: 1.13.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2017-12-07 12:27 UTC by Philipp Zabel
Modified: 2018-01-08 22:34 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
v4l2videoenc: do not activate capture pool during negotiation (2.13 KB, patch)
2017-12-19 11:14 UTC, Philipp Zabel
none Details | Review
v4l2videoenc: Delay capture pool activation (1.60 KB, patch)
2017-12-22 03:33 UTC, Nicolas Dufresne (ndufresne)
committed Details | Review
v4l2videoenc: Remove dead code (1.05 KB, patch)
2017-12-22 03:58 UTC, Nicolas Dufresne (ndufresne)
committed Details | Review
v4l2videoenc: Call stop on object before renegotiation (946 bytes, patch)
2017-12-22 03:58 UTC, Nicolas Dufresne (ndufresne)
committed Details | Review

Description Philipp Zabel 2017-12-07 12:27:12 UTC
S_FMT may return -EBUSY if buffers are already allocated with REQBUFS.
Some drivers return -EBUSY on S_FMT if buffers are allocated [1].
This can cause negotiation to fail when the capture pool is activated too early.
The attached patch stops activating the pool during negotiation and instead defers the pool activation until the first frame arrives.
Comment 1 Nicolas Dufresne (ndufresne) 2017-12-07 14:12:39 UTC
Did you push send too soon? What is the link for [1]. I think it makes sense to try and allocate the output buffers as late as possible, in order to get the size right. Specially that we don't yet implement any king of output buffers reallocation if the required size increases.
Comment 2 Philipp Zabel 2017-12-07 14:30:32 UTC
Copy & paste error. I wanted to link to the documentation, which describes the possible EBUSY return value:

[1] https://linuxtv.org/downloads/v4l-dvb-apis-new/uapi/v4l/vidioc-g-fmt.html#return-value
Comment 3 Philipp Zabel 2017-12-19 11:14:16 UTC
Created attachment 365741 [details] [review]
v4l2videoenc: do not activate capture pool during negotiation

And here is the missing patch.
Comment 4 Nicolas Dufresne (ndufresne) 2017-12-19 13:18:41 UTC
Review of attachment 365741 [details] [review]:

So this happens if the is a renegotiation ? Why not fixing that case instead ? Check is something have actually changed, if not  return TRUE, then run the allocation (to drain) stop the pools, and then set the new format. Just ignoring the caps seems rather bad.
Comment 5 Nicolas Dufresne (ndufresne) 2017-12-19 13:18:41 UTC
Review of attachment 365741 [details] [review]:

So this happens if the is a renegotiation ? Why not fixing that case instead ? Check is something have actually changed, if not  return TRUE, then run the allocation (to drain) stop the pools, and then set the new format. Just ignoring the caps seems rather bad.
Comment 6 Nicolas Dufresne (ndufresne) 2017-12-22 03:33:27 UTC
Created attachment 365867 [details] [review]
v4l2videoenc: Delay capture pool activation

This is to support CODA driver which prevents setting the output format if
the capture is streaming.

I haven't tested this one, but I think it should do pretty much the same,
without breaking renegotiation and without calling set_active() for every
frames coming in. I'm obsoleting the previous one because it's a regression
on Venus driver.
Comment 7 Nicolas Dufresne (ndufresne) 2017-12-22 03:58:53 UTC
Created attachment 365869 [details] [review]
v4l2videoenc: Remove dead code

gst_v4l2_object_stop() will free and nullify the pool, so the
following if will never be true.
Comment 8 Nicolas Dufresne (ndufresne) 2017-12-22 03:58:57 UTC
Created attachment 365870 [details] [review]
v4l2videoenc: Call stop on object before renegotiation

Otherwise renegotiation fails as we are still streaming.
Comment 9 Philipp Zabel 2018-01-02 10:49:29 UTC
Review of attachment 365867 [details] [review]:

Thank you, this does indeed have the same effect on CODA.
Comment 10 Nicolas Dufresne (ndufresne) 2018-01-08 22:33:34 UTC
Attachment 365867 [details] pushed as 4aa5298 - v4l2videoenc: Delay capture pool activation
Attachment 365869 [details] pushed as a46756b - v4l2videoenc: Remove dead code
Attachment 365870 [details] pushed as d90b6ec - v4l2videoenc: Call stop on object before renegotiation