GNOME Bugzilla – Bug 786246
qmlglsink: Add itemInitialized signal
Last modified: 2017-08-14 11:52:47 UTC
This is useful for autoplay for example. With autoplay, it is necessary to wait until the scene graph is fully set up. This signal is emitted once the QML item node is ready. So, inside a connected slot, the pipeline's state can be set to PLAYING to automatically start playback as soon as the QML script is loaded. There is the sceneGraphInitialized signal, but it is not suitable for this, since the GLVideoItem still has to get and wrap the GL context before it is ready for playback. This is done in QtGLVideoItem::onSceneGraphInitialized(). Having a dedicated itemInitialized signal in the QML item not only makes autoplay easier to accomplish, it is also a more futureproof solution, since it would make refactoring of the item code easier. Suppose for example that the initialization process is heavily changed for some reason, and the item now becomes ready to play at some other moment compared to now. With the signal in place, all that needs to be done is to simply move the "emit itemInitialized();" line to wherever the initialization is finished.
Created attachment 357521 [details] [review] qmlglsink patch for new itemInitialized signal
Comment on attachment 357521 [details] [review] qmlglsink patch for new itemInitialized signal Is there no existing signal for this already that we could re-use? Seems like a common thing to want to get notified about.
None that I've found. There is sceneGraphInitialized(), but it is emitted by the window, and suffers from the race condition I described. From what I've seen, it is *not* common for a QQuickItem to grab the context like qmlglsink does. The basic problem is that in Qt5, the scene graph and the QML tree are not always in sync, and other than this signal, I see no clean way of knowing when autoplay can be done. Also note what I wrote about it being futureproof. If you rely on other signals that were not designed for this purpose, you might risk regressions later on.
(In reply to Sebastian Dröge (slomo) from comment #2) > Is there no existing signal for this already that we could re-use? Seems > like a common thing to want to get notified about. I don't think so. Performing these acrobatics is not something every QQuickItem will need to do. There is the windowChanged() signal that the item already uses internally to do this exact setup depending on if the scene graph is initialized. https://cgit.freedesktop.org/gstreamer/gst-plugins-bad/tree/ext/qt/qtitem.cc#n351 Requiring every user to implement similar logic isn't that user-friendly so an extra signal is a good idea.
Ok, then let's go for this? Any things you'd like to have different, Matthew?
commit a13e8b3efa0e35d7dac7c57504339ac75aeae71e (HEAD -> master, origin/master, origin/HEAD) Author: Carlos Rafael Giani <dv@pseudoterminal.org> Date: Sun May 21 16:01:14 2017 +0200 qmlglsink: Add itemInitialized signal to QML item This is useful for autoplay for example. With autoplay, it is necessary to wait until the scene graph is fully set up. This signal is emitted once the QML item node is ready. So, inside a connected slot, the pipeline's state can be set to PLAYING to automatically start playback as soon as the QML script is loaded. https://bugzilla.gnome.org/show_bug.cgi?id=786246