Pump an alternative loop? (glib, gstreamer)

I want to use Gstreamer with Juce and can’t see how to integrate the two loops. I’d rather use Juce as the main loop, and I have found g_main_context_iteration on that side, to run the gmainloop that it uses, but I can’t find where to run it with the MessageManager so it gets pumped once per pass.

I can certainly use a thread, but since it’s the main part of the app, and GStreamer already puts out threads as needed, that seems redundant and will cause a lot of inter-thread blocking anyway.

I have a feeling someone will say - use a Timer - but really?

Can I, for instance, run my own loop and service Juce (like a plug-in host would) and glib too?


I assume your on linux? If yes, then you can technically run the main JUCE message thread on a completely separate thread while your main thread can run the glib message loop. You’ll need to tweak the START_JUCE_APPLICATION macro and run juce::JUCEApplicationBase::main on a different thread. I haven’t tried this and I’m sure there will be some subtle problems.

Thanks. I want to run on Linux and on Mac and probably iOS too.

I’d actually rather run both on one thread. Is there no way to run the GStreamer function ‘as often as possible’? I forget - does Juce not have a main thread so to speak and rely on the OS event loop?

No ‘run on idle’ callback I can override?


I don’t know enough about GStreamer if this is possible. You can certainly add Timer callbacks to the JUCE event-loop which will be called regularly on the message thread.