Skip to content

macos: Add wrapper API to run a NSApplication in the main thread

Piotr Brzeziński requested to merge thewildtree/gstreamer:macos-eventloop into main

Follow-up to cerbero!1023 (merged), closes cerbero#323 (closed)

Adds a wrapper API called gst_macos_main(), which aims to wrap a standard main() entry function with an NSApplication call, which ensures an NSRunLoop runs in the main thread. This is needed on macOS to allow the application to display windows (glimagesink most importantly) and in some cases other things like system prompts and such.

In the past we had this solved via a Cerbero patch for glib - that however was unsustainable in the long run, as such patch would never be accepted in the long run, and it was blocking us from updating glib for a long time now (see cerbero#323 (closed)). It also wasn't exactly complete - things compiled in the devenv didn't use that patch, so tutorials for example were broken on macOS anyway. AFAIK Homebrew-installed GStreamer also didn't have GL output working correctly.

Similar approach is already used in the gstreamer-rs versions of tutorials - this patch aims to bring that onto the main codebase and make it a public API so that everyone can use it as a drop-in solution. Updated tutorials show the intended way to use it.

Merge request reports