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 322587 - [API 0.11] change gst_value_union() return value to void
[API 0.11] change gst_value_union() return value to void
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
git master
Other Linux
: Normal enhancement
: 0.11.x
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2005-11-27 19:48 UTC by Tim-Philipp Müller
Modified: 2012-01-24 14:21 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gstvalue: enforce identical basic types in lists, arrays (11.21 KB, patch)
2011-11-04 18:28 UTC, Vincent Penquerc'h
none Details | Review
tests: check return value of append routines (1.76 KB, patch)
2011-11-04 18:29 UTC, Vincent Penquerc'h
none Details | Review
gstvalue: enforce identical basic types in lists, arrays (7.07 KB, patch)
2011-11-11 12:47 UTC, Vincent Penquerc'h
none Details | Review
gstvalue: enforce identical basic types in lists, arrays (6.38 KB, patch)
2011-11-29 13:01 UTC, Vincent Penquerc'h
committed Details | Review

Description Tim-Philipp Müller 2005-11-27 19:48:34 UTC
gst_value_union() always succeeds and always returns TRUE, so we might just as
well change the return value to void.
Comment 1 Michael Smith 2005-11-28 12:08:16 UTC
Shouldn't it fail and return FALSE if the values are of incompatible type, such
that we can't represent a union of them? (i.e. isn't this an implementation bug,
not an API problem?)
Comment 2 Andy Wingo 2006-01-16 15:32:04 UTC
Right now if the values are of incompatible types it puts them in a list. So yes it does always succeed. Question would be, does putting different types in a list make sense. Can't change this now though -- probably best off putting a maybe-fixme in the source linking to this bug, because 0.11 is a ways off.
Comment 3 Tim-Philipp Müller 2011-10-27 11:43:22 UTC
Ok, so I think we should keep the return value and enforce that lists + arrays always contain elements of the same type for 0.11.
Comment 4 Vincent Penquerc'h 2011-11-04 18:28:27 UTC
Created attachment 200701 [details] [review]
gstvalue: enforce identical basic types in lists, arrays
Comment 5 Vincent Penquerc'h 2011-11-04 18:29:09 UTC
Created attachment 200702 [details] [review]
tests: check return value of append routines

as they now can fail.
Comment 6 Tim-Philipp Müller 2011-11-07 23:17:36 UTC
I'd say put it in and see if there's any fallout :)

However, on second thought I wonder if we shouldn't just declare it a programming error to put values of different types into a list/array ? (ie. just add guards for it that print nasty warnings, instead of adding return values no one in the world will ever check anyway)
Comment 7 Tim-Philipp Müller 2011-11-07 23:18:32 UTC
Unless someone can think of a use case where that's useful. (bindings maybe?)
Comment 8 Sebastian Dröge (slomo) 2011-11-08 07:40:51 UTC
Yes, make it a programming error and document that this shouldn't be done.
Comment 9 Vincent Penquerc'h 2011-11-10 18:39:05 UTC
Now, there's one extra reason why a union call might fail:
if one tries to union [0..3] with [6..9], say.
A theoretical solution would be to expand that into {0, 1, 2, 3, 6, 7, 8, 9}, but that does not scale very well at all.
Not sure what to do here. Erroring out above a certain "resulting list size" threshold seems wrong.
Alternatively, keep the return codes for such cases, but fail hard on type mismatches instead of returning errors. Not sure I like that either.
Comment 10 Tim-Philipp Müller 2011-11-10 18:49:52 UTC
What's wrong with the 'return a list of the two values' approach then? We are still talking about values of the same type after all.

Might be trickier if you wanted to union   [0, 3] and { 15000, 19000 } with the new requirements.
Comment 11 Vincent Penquerc'h 2011-11-10 19:08:35 UTC
That's exactly that. I'm thinking of ranges such as [16..4096] which are large, and common in video width/height. Unlikely to be unioned with a non intersecting range, though.

Audio might have separate caps for 1, 2, and more channels, so you might end up unioning 1 and [3..255].

For audio sampling rate, the values would go even higher. What if you try to union caps for wideband audio and narrowband audio ? You'd end up with a LOT of values.
Comment 12 Sebastian Dröge (slomo) 2011-11-11 10:41:12 UTC
I don't think an union of [3,255] and 1 should fail, instead it should just do nothing and keep the two separate structures
Comment 13 Vincent Penquerc'h 2011-11-11 11:18:32 UTC
What do you mean ?
Doing nothing means not initializing the returned GValue to anything.
It is akin to failing.
Comment 14 Tim-Philipp Müller 2011-11-11 11:26:35 UTC
Just so I understand correctly:

The Problem is that we've changed our list to only accept child values of the same type, right? That means that the _union() function can't union an int range and an int list any longer by just putting those two into a list, because then you'd have different child types (int range + list of ints), right?
Comment 15 Sebastian Dröge (slomo) 2011-11-11 11:30:50 UTC
(In reply to comment #13)
> What do you mean ?
> Doing nothing means not initializing the returned GValue to anything.
> It is akin to failing.

Nevermind, I thought we're talking about gst_caps_union(). There's a problem for gst_value_union() here now and it should fail. OTOH nothing will have ever worked with the result of such a union before so it shouldn't be a problem to fail now.
Comment 16 Vincent Penquerc'h 2011-11-11 11:46:25 UTC
(In reply to comment #14)
> Just so I understand correctly:
> 
> The Problem is that we've changed our list to only accept child values of the
> same type, right? That means that the _union() function can't union an int
> range and an int list any longer by just putting those two into a list, because
> then you'd have different child types (int range + list of ints), right?

I'm not 100% sure, but I don't think you could have a list of lists of ranges and such other complex setups, could you ? Well, you *could*, but I don't think it would work with intersection, union, etc.

If it does, then yes, I can just return a list of ranges or whatever.
Comment 17 Vincent Penquerc'h 2011-11-11 12:47:17 UTC
Created attachment 201223 [details] [review]
gstvalue: enforce identical basic types in lists, arrays

Need to decide what to do for disjoint union/union, otherwise
the rest is ready.
Comment 18 Vincent Penquerc'h 2011-11-29 13:01:14 UTC
Talking to slomo on IRC, we want something like the union of ranges 1-10 and 20-30 to fail, instead of returning a list of ranges. Such cases are returned as FALSE return value.

Mismatch in basic types is not, but asserted instead, as it is deemed a programming error.

New patch coming up.
Comment 19 Vincent Penquerc'h 2011-11-29 13:01:48 UTC
Created attachment 202367 [details] [review]
gstvalue: enforce identical basic types in lists, arrays
Comment 20 Vincent Penquerc'h 2012-01-24 14:21:11 UTC
commit b6abb9794c8100bf206b62ff863097343ba854c7
Author: Vincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Date:   Fri Nov 4 18:26:15 2011 +0000

    gstvalue: enforce identical basic types in lists, arrays
    
    https://bugzilla.gnome.org/show_bug.cgi?id=322587