GNOME Bugzilla – Bug 743677
gl: new element caopengllayersink
Last modified: 2015-02-24 08:15:52 UTC
This is a new element that renders to a CAOpenGLLayer. The layer is retrievable through a property on the element that can then be used like a normal CALayer.
Created attachment 295724 [details] [review] new caopengllayersink element
It would be good if _ensure_gl_setup() would be called in NULL->READY state change. Otherwise it would be very difficult for the application to get the layer.
Ah, now I remember why I didn't do that. Calling _ensure_gl_setup() tries to setup the GL context which the cocoa backend needs to run stuff on the main thread. Deadlock ensues due to cocoa waiting for the _ensure_gl_setup to complete which is waiting for the cocoa stuff to initialize in the main thread. One solution is to make Cocoa multi-threaded much like the X11 backend by initializing a dummy NSThread and not do the GL initialisation in the main thread.
Not sure if that is possible, we also call some UI related things which are probably not possible from a non-main thread. But alternatively, just make sure to the emit "notify::layer" signal so applications know when the layer is there. And maybe also a custom GstMessage on the bus so applications don't have to worry about getting signals from random threads.
(In reply to Sebastian Dröge (slomo) from comment #4) > Not sure if that is possible, we also call some UI related things which are > probably not possible from a non-main thread. It is possible, you just need to start a NSThread somewhere and Cocoa becomes multithreaded much like XInitThreads [0]. It's also possible to draw on separate threads [1] although on ios UIView's are main thread only but with CoreAnimation it is all possible to draw on a secondary thread. [0] http://stackoverflow.com/questions/5908728/is-there-any-way-to-enter-cocoa-multithreaded-mode-without-creating-fake-nsthrea [1] http://stackoverflow.com/questions/19954424/multiple-threads-to-draw-in-nsview
Created attachment 296992 [details] [review] new caopengllayersink element
commit e505f6257cb938483f675891967cbb2810c9531c Author: Matthew Waters <matthew@centricular.com> Date: Mon Jan 19 12:43:23 2015 +1100 applemedia: new AVSampleBufferLayerSink Renders buffers using the CALayer subclass AVSampleBufferDisplayLayer which can be placed inside a Core Animation render tree.