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 115886 - gst_caps_has_(fixed_)property() prints an assertion before returning false
gst_caps_has_(fixed_)property() prints an assertion before returning false
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
0.6.2
Other All
: Normal minor
: 0.6.x
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2003-06-24 21:17 UTC by Laurent Sansonetti
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch (1.50 KB, patch)
2003-06-30 21:59 UTC, Ronald Bultje
none Details | Review
this (3.02 KB, patch)
2003-07-01 08:20 UTC, Ronald Bultje
none Details | Review
that (3.01 KB, patch)
2003-07-01 08:24 UTC, Ronald Bultje
none Details | Review
it's gst_caps_has_fixed_property, not property_fixed! (3.00 KB, patch)
2003-07-01 08:27 UTC, Ronald Bultje
none Details | Review

Description Laurent Sansonetti 2003-06-24 21:17:11 UTC
gst_caps_has_property() and gst_caps_has_fixed_property() are predicate
macros which can be used to check if a given GstCaps object handles a named
property.

The problem here is that an assertion failure is printed each time these
macros are called with a property name the caps does not handle.

It is not critical since these macros return false anyway.

Here is a test program which illustrates this problem:

  #include <gst/gst.h>
 
  int main(int argc, char *argv[]) {
      GstElementFactory *factory;
      GstPadTemplate *pad_template;
      GstCaps *caps;
     
      gst_init(&argc, &argv);
     
      factory = gst_element_factory_find("mad");
      pad_template = (GstPadTemplate *) factory->padtemplates->data;
      caps = pad_template->caps;
     
      printf("%d\n", gst_caps_has_property(caps, "does_not_exist"));
      printf("%d\n", gst_caps_has_fixed_property(caps, "does_not_exist"));
     
      return 0;
  }

And its output (on 0.6.2):

  INFO (10110: 0) Initializing GStreamer Core Library version 0.6.2
  INFO (10110: 0) CPU features: (00000000) MMX SSE
  INFO (10110: 0) registry: loaded global_registry in 0.220729 seconds
            (/usr/X11R6/share/gnome/cache/gstreamer-0.6/registry.xml)
 
  (process:10110): GStreamer-CRITICAL **: file gstprops.c: line 1001
(gst_props_get_entry): assertion `props != NULL' failed
0
 
  (process:10110): GStreamer-CRITICAL **: file gstprops.c: line 1001
(gst_props_get_entry): assertion `props != NULL' failed
0

This has been tested on both Gentoo GNU/Linux and FreeBSD.
Comment 1 Ronald Bultje 2003-06-30 21:59:08 UTC
Created attachment 17940 [details] [review]
patch
Comment 2 Ronald Bultje 2003-06-30 22:00:47 UTC
There's several ways to fix this:

* change gstprops.c gst_props_has_property*() functions to check for
props != NULL. This is ugly, imho, because that's what the caller
should check.
* change the macros to caps->properties != NULL && ..., which is ugly
because you should never use variables-in-macros twice, they could be
functions
* fix this by making the macros inline functions

The above patch implements the third fixage method.
Comment 3 David Schleef 2003-06-30 23:12:36 UTC
I vote for the third option, too.  However, they should be real
functions, not inline.  We don't do inline functions in headers.

I mostly got a consensus on IRC that gst_caps_*() code should properly
handle caps==NULL and caps->properties==NULL, but gst_props_*()
functions can expect (and assert) that they are called with props !=
NULL.  This is because the props code is almost exclusively used by
caps, whereas caps is used by plugins and apps.
Comment 4 Ronald Bultje 2003-07-01 08:18:30 UTC
I just had the thought that we might want to make it obligatory to
make every caps have a GstProps, even though it might be empty
(gst_props_new_empty ()). This would need some plugin fixage, but it'd
fix the issue, too.

If we want to stick to allowing NULL as valid caps->props, then here's
a patch that does what dave asked for.
Comment 5 Ronald Bultje 2003-07-01 08:20:02 UTC
Created attachment 17951 [details] [review]
this
Comment 6 Ronald Bultje 2003-07-01 08:24:04 UTC
Hm, the above has some typos.
s/gst_caps_get_properties/gst_caps_get_props/ and
s/gst_props_has_property_fixed/gst_props_has_fixed_property/ makes it
compile. ;).

Mental note: test patches before proposing them...
Comment 7 Ronald Bultje 2003-07-01 08:24:59 UTC
Created attachment 17952 [details] [review]
that
Comment 8 Ronald Bultje 2003-07-01 08:27:58 UTC
Created attachment 17953 [details] [review]
it's gst_caps_has_fixed_property, not property_fixed!
Comment 9 Ronald Bultje 2003-07-29 12:01:19 UTC
Applied to HEAD CVS.