GNOME Bugzilla – Bug 324725
gst_element_set_locked_state() doesn't have effect
Last modified: 2006-05-17 13:42:54 UTC
according to the documentation, when setting an element to locked state by calling gst_element_set_locked_state(element, TRUE), the state of the element in question should not change, unless explicilty changed. but unfortunately it seems the above call has no effect on the elements.
Created attachment 56266 [details] see the source file demonstrating the problem in the source file, a simple pipeline is assembled: filesrc ! mad ! audioconver ! alsasink. before setting the pipeline to PLAYING, the mad element is locked. but despite this lock, it is set into PLAYING state when the pipeline is set to PLAYING. it should remain in NULL state, because of the lock. but does not.
Two problems: 1) the debug output is deceiving, the element does not actually change state, we just report success to the caller, which prints that the state changed. 2) pad are initially created in the non-flushing state so that you can stream data to them before they are activated. mad happens to work fine in the NULL state and so this pipeline works fine. The proper fix is to initialize a newly created pad in the flushing state. It unfortunatly made ghostpads fail right before the 0.10 release, need to reinvestigate.
Created attachment 56433 [details] sample code showing that setting pads to flushing doesn't solve the problem see the sample code that shows that setting pads to flushing mode doesn't solve the problem either. the sample code contains a { filesrc ! mad ! audioconvert ! alsasink } pipeline. both mad and audioconvert are locked, and their pads are set to flushing. but this does not prevent the pipeline to play right from the start. the intended scenario for the sample code would be to stay silent for 2 seconds, and then start to play, when the audioconvert and mad plugins are set into PLAYING state. (before that they are in PAUSED).
ping - is this still ongoing?
AFAIK yes
in 0.10 elements starts streaming in PAUSED. The PAUSED state only blocks for sinks. If the purpose is to preroll the pipeline, then wait for 2 seconds before starting playback, just do PAUSED, _usleep (2 * seconds), PLAYING. Can you explain the use case if there is something else you would like to do?
sure. the use case is that I assemble a complex pipeline, with multiple sources. here is one switcher element (not the 'official' one), that selects one from the sources connected to it, and plays that one. from time to time, it selects other sources, and plays from that source. naturally, all sources should block when not selected. so if source 1 is first selected, then source 2, then back to source 1, it should continue exactly where it left off. (this is contrary to the 'official' switcher element in that it lets all sources flow all the time.
ok, sounds like gnonlin could be of great help to you. Other pointers for implementing this: Set the sources to PAUSED, blocking the source pads. Then link/unblock them when needed and block/unlink when not needed anymore.
I looked at gnonlin, but it seems way over-complicated for me. (or I'm just too dumb :) as for your suggestion: this is my very problem: even if I set them to PAUSED, they get reset when the whole pipeline is set to PLAYING. this is what locking should prevent from happening, isn't it? if not, I'd need a kind of locking that would :)
yes, locking does not change the state of the element when the state of the container changes. so setting an element locked, then to PAUSED, will leave it in paused whatever you do to the state of the parent bin. Can this bug be closed?
I'm not sure if I understand you. the effect I see is that even though I lock an element, its state _does_ change, for example when changing the state of the parent bin. you seem to be saying the opposite...
What effect do you see that makes you believe the state changes regardless of the locked state of the element?
Closing this bug report as no further information has been provided. Please feel free to reopen this bug if you can provide the information asked for. Thanks!