I’m hoping someone can help me figure this out. I no longer have any hair.
I’ve created a VST Host DLL for our audio application, but I’m not sure I have the initialization sequence correct. Some plugins don’t load correctly, and other will crash.
The following is the diagnostic output from my load routine for 2 differnt plugins. The first seems to load correctly, but the second crashes:
Yvan, Thanks for the info. I made the changes you suggested and I’m still crashing inside connectionproxy.cpp here: tresult res = srcConnection→connect(this);
New source code below.
Thanks for your help, Russ…
// create component (IComponent)
TRACE("Calling factory.createInstance to create component\n");
component = factory.createInstance<IComponent>(procInfo->ID());
if (!component)
{
TRACE("Failed to create component instance -> %d\n", status);
return false;
}
TRACE("Component creation success\n");
// Initialize the component with your host context
TRACE(_T("calling component->initialize\n"));
hostCtx = new MyHostApp();
if (auto plugBase = U::cast<IPluginBase>(component))
{
status = plugBase->initialize(hostCtx);
if (status != kResultOk)
{
TRACE(_T("Failed to initialize component\n"));
return false;
}
}
else
{
TRACE(_T("Failed to get IPluginBase from component\n"));
return false;
}
TRACE("Getting controller from classID\n");
TUID ctrlTuid = { 0 };
// try to create the controller part from the component
// (for Plug-ins which did not succeed to separate component from controller)
if (component->queryInterface(IEditController::iid, (void**)&controller) == kResultTrue)
{
isSingleComponent = true;
}
else
{
// ask for the associated controller class ID
if (component->getControllerClassId(ctrlTuid) == kResultTrue)
{
// create its controller part created from the factory
controller = factory.createInstance<IEditController>(VST3::UID(ctrlTuid));
if (controller)
{
// initialize the component with our context
if (auto plugCtrlBase = U::cast<IPluginBase>(controller))
{
status = plugCtrlBase->initialize(hostCtx);
if (status != kResultOk)
{
TRACE(_T("Failed to initialize controller!\n"));
}
}
else
{
TRACE(_T("Failed to get IPluginBase from controller\n"));
return false;
}
}
}
else
{
TRACE(_T("Component does not provide a required controller class ID\n"));
}
}
if (status != kResultOk)
{
component.reset();
controller.reset();
}
else
{
// --- Connect controller <-> component
if (!isSingleComponent)
{
if (component && controller)
{
TRACE("Connecting controller <-> component\n");
//auto compICP = U::cast<IConnectionPoint>(component);
//auto contrICP = U::cast<IConnectionPoint>(controller);
FUnknownPtr<Steinberg::Vst::IConnectionPoint> compICP{ nullptr };
FUnknownPtr<Steinberg::Vst::IConnectionPoint> contrICP{ nullptr };
compICP = FUnknownPtr<Steinberg::Vst::IConnectionPoint>(component);
contrICP = FUnknownPtr<Steinberg::Vst::IConnectionPoint>(controller);
if (!compICP || !contrICP)
return false;
componentCP = owned(new ConnectionProxy(compICP));
controllerCP = owned(new ConnectionProxy(contrICP));
status = componentCP->connect(contrICP);
if (status != kResultTrue)
{
TRACE("componentCP->connect -> %d\n", status);
return false;
}
status = controllerCP->connect(compICP);
if (status != kResultTrue)
{
TRACE("controllerCP->connect -> %d\n", status);
return false;
}
}
}
}