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 571559 - [API] add GST_PARAM_MUTABLE_PLAYING etc. to indicate valid states for changing property
[API] add GST_PARAM_MUTABLE_PLAYING etc. to indicate valid states for changin...
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
git master
Other Linux
: Normal enhancement
: 0.10.23
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2009-02-12 22:43 UTC by David Schleef
Modified: 2009-04-14 19:43 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch (4.30 KB, patch)
2009-02-12 22:43 UTC, David Schleef
committed Details | Review

Description David Schleef 2009-02-12 22:43:04 UTC
Patch (preliminary) for adding flags GST_PARAM_MUTABLE_PLAYING, etc, to the GParamSpec of properties on GstElements.  Combined with the convenience function gst_param_spec_is_mutable(pspec,element), set_property() functions can quickly check if it is valid for a property to be changed in the given state.  Also, applications can check in a similar way before attempting to change the property.

Not yet done:

 - Print out this info in gst-inspect.

 - Fix all the elements.  Everywhere.
Comment 1 David Schleef 2009-02-12 22:43:53 UTC
Created attachment 128600 [details] [review]
patch
Comment 2 Sebastian Dröge (slomo) 2009-02-13 09:19:24 UTC
Looks good and sounds like a good idea to add this :)
But you could simply check for <= _PAUSED, etc. instead of all the different comparisons. Also you should probably handle GST_STATE_VOID_PENDING, which is even smaller than _NULL ;)
Comment 3 Tim-Philipp Müller 2009-02-13 11:03:52 UTC
Not a bad idea at all, but wouldn't it make just as much sense to make all properties that can be manipulated while the pipeline is running controllable? That seems more user-friendly to me, since the user is likely to care only about 'pipeline is in NULL state' and 'pipeline is running', but not about the technical details of the states in between. (They wouldn't *have* to use the GstController API to change the property of course).

Also, some of our state stuff is just inconsistent and unintuitive, e.g. why wouldn't filesrc open the device in NULL->READY? It's not really READY if the device isn't open yet, is it? But other devices are opened in NULL->READY. Do we really want to expose all of this even more?

(Not against this at all, just thinking out loud)
Comment 4 Sebastian Dröge (slomo) 2009-02-14 09:12:43 UTC
CONTROLLABLE is a bit different IMHO. You can change some properties while PLAYING but it is quite expensive (all the properties in audiowsinclimit for example) so you usually don't want to change them every 20 milliseconds and don't want them controlled by a GstController.

IMHO this difference between CONTROLLABLE and MUTABLE_PLAYING is important ;)
Comment 5 Tim-Philipp Müller 2009-02-14 13:50:58 UTC
Fair enough :)
Comment 6 Stefan Sauer (gstreamer, gtkdoc dev) 2009-02-15 11:45:22 UTC
The docs for gst_param_spec_is_mutable() should advice which lock the application needs to take to avoide a race.

Btw. there are still the flags that I proposed in Bug #522205. 
Comment 7 Tim-Philipp Müller 2009-04-05 18:42:08 UTC
What's happening with this one? Let's commit it and get it into 0.10.23 if everyone's happy with the API.
Comment 8 Stefan Sauer (gstreamer, gtkdoc dev) 2009-04-06 12:50:03 UTC
There are some comments above that could go into the patch.
Comment 9 David Schleef 2009-04-13 01:40:39 UTC
> The docs for gst_param_spec_is_mutable() should advice which lock the
> application needs to take to avoide a race.

Stefan, please add what you think is appropriate to the documentation after this is pushed.
Comment 10 David Schleef 2009-04-13 01:48:27 UTC
commit 1ecf114c0ecb7477cbdf9f8b5c772d2e93489064
Author: David Schleef <ds@schleef.org>
Date:   Fri Feb 20 11:09:19 2009 -0800

    Add param spec flags for when a property can be changed
    
    Adds GST_PARAM_MUTABLE* flags to indicate in which states a
    property can be changed and take effect.  Fixes #571559

Comment 11 Stefan Sauer (gstreamer, gtkdoc dev) 2009-04-14 07:16:58 UTC
I am not sure what the solution is. Lets imagine one has this code in the app:

g_object_set(element, "param", value, NULL);

Now, one should do:

GParamSpec *pspec;
GstElementClass element_class;

element_class = GST_ELEMENT_GET_CLASS (element);
pspec = g_object_class_find_property(element_class, "param");
if (gst_param_spec_is_mutable (pspec, element)) {
  g_object_set(element, "param", value, NULL);
}

This is ofcourse racy, as one needs to take a lock. The gst_param_spec_is_mutable() already takes GST_OBJECT_LOCK(), so the app can't use that. Should we rather have 
gboolean gst_param_spec_set_if_mutable(element_class, "param", value);
?

Also we should add another API
gst_element_property_is_mutable (element, property_name)
for convinience.
Comment 12 David Schleef 2009-04-14 18:08:55 UTC
I understand now.  gst_param_spec_is_mutable() should be changed to have locked and unlocked versions.  The function was not meant to be used by applications.  I'm not sure it would be useful in applications, since applications should be checking the flags directly.
Comment 13 Stefan Sauer (gstreamer, gtkdoc dev) 2009-04-14 18:57:02 UTC
Out of curiosity whats the use case you where thinking about? 

One non-application use case I will do, is to make binding a controller to a object property that can't change in playing fail. There I should access the flags directly.
Comment 14 David Schleef 2009-04-14 19:29:29 UTC
Inside set_property() functions in plugins, as in the filesrc part of the patch above.

I suppose gst_param_spec_is_mutable() should not take the lock, since it should be called with the lock held inside the critical section of set_property() functions.  Fixing.

commit 8dd2b4b591b7650cfabad2ffc79af7f20d673012
Author: David Schleef <ds@schleef.org>
Date:   Tue Apr 14 12:20:37 2009 -0700

    Fix locking in gst_param_spec_is_mutable


Keep in mind that these flags are only advisory right now, so binding a controller should only fail if MUTABLE_PAUSED or MUTABLE_READY is set, but not MUTABLE_PLAYING.  If none are set, the old behavior (that is, "fail randomly") should remain.

Somebody please save us from GObject properties in 0.11.
Comment 15 Wim Taymans 2009-04-14 19:43:55 UTC
It's still very tricky to use, you basically force elements to use the object lock to protect their properties, which is, more often than not, impossible.