GNOME Bugzilla – Bug 318116
new state change patch
Last modified: 2005-11-14 17:58:40 UTC
current state change design is rather awkward for the programmer. When doing a state change to PLAYING, for example, the set_state() function stops performing the state change as soon as it receives ASYNC. The programmer is then supposed to perform the next state changes manually. GstPipeline also does a blocking wait to reach the final state change, which might be infinite in case of errors. Performing downward state changes might block indefinatly in a similar way and require the application programmer to be prepared to handle ASYNC state changes. GstBin and subclasses also don't post state change messages automatically after completing the state change unless explicitly polled for with gst_element_get_state() which is again blocking. Various hacks exist to work around these problems in gstutils.c (gst_element_set_state_async and gst_bin_watch_for_state_change which both spawn threads).
Created attachment 53113 [details] [review] proposed patch this patch makes sure set_state() never blocks. It can return ASYNC and will then asynchronously move itself to the target state at which point it will post a message. A get_state() call blocks until the desired target state is reached. The pending state in the get_state() call now returns the target value of the state change. A get_state() can thus return current:READY pending:PLAYING if the element is currently going from READY to PAUSED but was requested to go to PLAYING after that. Downward state changes also never block and will ignore all intermediate ASYNC state changes up to the final state. Error conditions are also handled better so that no lockups can occur when trying to recover from an error.
Created attachment 53193 [details] [review] Improved patch
Created attachment 53220 [details] [review] updated patch
Created attachment 53233 [details] [review] updated patch
Created attachment 53277 [details] [review] updated patch
Created attachment 53293 [details] [review] Merged cosmetic changes, what's left is meat
Created attachment 53294 [details] [review] Patch after merging static mutex waiting, recursive state lock
Applied to CVS a long while ago