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 590941 - API: add gst_pad_get_caps() variant that avoids unneeded caps copies
API: add gst_pad_get_caps() variant that avoids unneeded caps copies
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
git master
Other Linux
: Normal normal
: 0.10.26
Assigned To: Stefan Sauer (gstreamer, gtkdoc dev)
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2009-08-06 12:48 UTC by Stefan Sauer (gstreamer, gtkdoc dev)
Modified: 2009-11-05 22:53 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
adds and uses non-copying gst_caps function (10.62 KB, patch)
2009-08-06 12:49 UTC, Stefan Sauer (gstreamer, gtkdoc dev)
none Details | Review
adds and uses non-copying gst_caps function (10.62 KB, patch)
2009-10-07 08:46 UTC, Stefan Sauer (gstreamer, gtkdoc dev)
none Details | Review

Description Stefan Sauer (gstreamer, gtkdoc dev) 2009-08-06 12:48:09 UTC
gst_pad_get_caps (and therefore also gst_pad_peer_get_caps) promisses to return writable caps. To ensure that it copies caps in most cases. This has two bad side-effects:
* copying is often not needed (e.g. when using the caps to calculating an intersection)
* when caps are copied we cannot compare pointers to benefit from quickly leaving some operations

The attached patch adds variants that don't copy and makes use of them in core. I am not entierly happy with the naming. Any ideas?
Comment 1 Stefan Sauer (gstreamer, gtkdoc dev) 2009-08-06 12:49:11 UTC
Created attachment 140016 [details] [review]
adds and uses non-copying gst_caps function
Comment 2 Stefan Sauer (gstreamer, gtkdoc dev) 2009-08-29 19:31:49 UTC
as of irc discussion - _get_caps_nocopy() seem to be the favorite. I'll redo the patch.
Comment 3 Stefan Sauer (gstreamer, gtkdoc dev) 2009-09-08 15:19:19 UTC
Well _get_caps_nocopy() is not good, as gst_pad_get_caps(9 not neccesarily copies.
Comment 4 Stefan Sauer (gstreamer, gtkdoc dev) 2009-10-07 08:46:48 UTC
Created attachment 144935 [details] [review]
adds and uses non-copying gst_caps function

update for latest git-head
Comment 5 Stefan Sauer (gstreamer, gtkdoc dev) 2009-10-07 19:56:19 UTC
commit fcc5d783df0a8461250da1e0434132d580ec8adf
Author: Stefan Kost <ensonic@users.sf.net>
Date:   Wed Oct 7 11:43:54 2009 +0300

    pad: add variants of gst_pad_get_caps() that don't copy caps. Fixes #590941
    
    In most places in core and baseclasses we just need the caps to do caps-
    intersections. In that case ref'ed caps are enough (no need to copy).
    This patch also switches the code to use the new functions.
    API: gst_pad_get_caps_refed(), gst_pad_peer_get_caps_refed()
Comment 6 Tim-Philipp Müller 2009-10-20 09:59:37 UTC
Hrm, I quite dislike _refed(). It just looks wrong to me. At the very least we should rename it to _reffed() IMHO. Re-opening to collect some more opinions (sorry).
Comment 7 Stefan Sauer (gstreamer, gtkdoc dev) 2009-10-20 20:27:30 UTC
Why reffed with a doubled 'ff'. It comes from 'referenced' as in http://www.merriam-webster.com/dictionary/referenced

Also what looks wrong to you - the naming or the functionality? We discussed the nameing before. _nocopy would suggest that gst_pad_get_caps always copies (which it does not).

Ideally we would rename gst_pad_get_caps() to gst_pad_get_writable_caps() if we want to have such a utility function at all. gst_pad_get_caps_refed() is what the actual gst_pad_get_caps() should have been.
Comment 8 Stefan Sauer (gstreamer, gtkdoc dev) 2009-10-20 20:29:04 UTC
Also as a very non scientific approch to the spelling:
http://www.googlefight.com/index.php?lang=en_GB&word1=reffed&word2=refed
Comment 9 Tim-Philipp Müller 2009-10-21 08:36:31 UTC
> Also as a very non scientific approch to the spelling:
> http://www.googlefight.com/index.php?lang=en_GB&word1=reffed&word2=refed

Yes, that's because it's used a lot in connection with words like 'birds', 'rats' and 'feeding' ;-)
Comment 10 Sebastian Dröge (slomo) 2009-10-21 08:54:31 UTC
What about gst_pad_get_caps_nocopy() ?
Comment 11 Stefan Sauer (gstreamer, gtkdoc dev) 2009-10-21 18:09:44 UTC
(In reply to comment #10)
> What about gst_pad_get_caps_nocopy() ?

See comment #3 and comment #7.
Comment 12 Stefan Sauer (gstreamer, gtkdoc dev) 2009-11-05 22:53:28 UTC
Just for the record, its now _reffed.