mirror of
https://github.com/cookiengineer/audacity
synced 2025-11-23 09:20:16 +01:00
ModuleInterface.h needn't distinguish built-in from external usage...
... All is set up so that plug-in providers can be modules that register their instance-creating function pointers directly with RegisterProvider; no special symbol name needs to be exported. That is, they now just need to export ModuleDispatch and GetVersionString, just like other modules for other purposes. Duplication of logic from ModuleManager::InitializeBuiltins() is removed. No examples yet in the previous commits, but it does work in my misc-modules branch.
This commit is contained in:
@@ -461,7 +461,7 @@ void ModuleManager::InitializeBuiltins()
|
||||
moduleMain(nullptr), ModuleInterfaceDeleter{}
|
||||
};
|
||||
|
||||
if (module->Initialize())
|
||||
if (module && module->Initialize())
|
||||
{
|
||||
// Register the provider
|
||||
ModuleInterface *pInterface = module.get();
|
||||
@@ -480,40 +480,6 @@ void ModuleManager::InitializeBuiltins()
|
||||
}
|
||||
}
|
||||
|
||||
ModuleInterface *ModuleManager::LoadModule(const PluginPath & path)
|
||||
{
|
||||
auto lib = std::make_unique<wxDynamicLibrary>();
|
||||
|
||||
if (lib->Load(path, wxDL_NOW))
|
||||
{
|
||||
bool success = false;
|
||||
ModuleMain audacityMain = (ModuleMain) lib->GetSymbol(wxSTRINGIZE_T(MODULE_ENTRY),
|
||||
&success);
|
||||
if (success && audacityMain)
|
||||
{
|
||||
ModuleInterfaceHandle handle {
|
||||
audacityMain(&path), ModuleInterfaceDeleter{}
|
||||
};
|
||||
if (handle)
|
||||
{
|
||||
if (handle->Initialize())
|
||||
{
|
||||
|
||||
auto module = handle.get();
|
||||
mDynModules[PluginManager::GetID(module)] = std::move(handle);
|
||||
mLibs[module] = std::move(lib);
|
||||
|
||||
return module;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lib->Unload();
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void ModuleInterfaceDeleter::operator() (ModuleInterface *pInterface) const
|
||||
{
|
||||
if (pInterface)
|
||||
@@ -567,7 +533,7 @@ ModuleInterface *ModuleManager::CreateProviderInstance(const PluginID & provider
|
||||
return mDynModules[providerID].get();
|
||||
}
|
||||
|
||||
return LoadModule(path);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ComponentInterface *ModuleManager::CreateInstance(const PluginID & providerID,
|
||||
|
||||
@@ -109,7 +109,6 @@ private:
|
||||
ModuleManager &operator=(const ModuleManager&) PROHIBITED;
|
||||
|
||||
void InitializeBuiltins();
|
||||
ModuleInterface *LoadModule(const PluginPath & path);
|
||||
|
||||
private:
|
||||
friend ModuleInterfaceDeleter;
|
||||
|
||||
Reference in New Issue
Block a user