/ VST Home / Technical Documentation
Provide a RunLoop on Linux
On this page:
On Linux, there is no global event run loop like on Windows and macOS. For this reason, the plug-in can query for an Linux::IRunLoop which must be provided by the host application in two different ways.
Query IRunLoop from IPlugFrame
The host application must provide the Linux::IRunLoop via Steinberg:: IPlugFrame (by calling Steinberg:: IPlugView::setFrame).
// Plug-in implementation
tresult PLUGIN_API MyPlugView::setFrame (Steinberg::IPlugFrame* frame)
{
...
if (auto runLoop = Steinberg::U::cast<Steinberg::Linux::IRunLoop> (plugFrame))
{
runLoop->registerEventHandler (...);
}
...
}
Query IRunLoop from the host context of IPluginFactory3
A plug-in also needs a way to query for an Linux::IRunLoop without Steinberg:: IPlugFrame. This allows to register timers in case the editor is closed or unavailable.
These timers can be used inside Vst:: IAudioProcessor for extra computations or sending messages within the UI thread, like any method of Edit Controller in UI Thread (see Edit Controller Call Sequence).
The host application must call Steinberg:: IPluginFactory3::setHostContext (context) for this and provide a context
. This context
can be used to query an Linux::IRunLoop interface.
// Plug-in implementation
tresult PLUGIN_API MyPlugFactory::setHostContext (FUnknown* context)
{
...
if (auto runLoop = Steinberg::U::cast<Steinberg::Linux::IRunLoop> (context))
{
runLoop->registerTimer (...);
}
...
}