1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-11-23 17:30:17 +01:00

Module manager (#549)

* Eliminate ModuleManagerInterface...

... It was there only to provide RegisterModule(), but that was not used
anywhere.  So simplify.

* Remove nested #include of ModuleInterface.h
This commit is contained in:
Paul Licameli
2020-05-29 11:48:52 -04:00
committed by GitHub
parent 5bede69d11
commit 9360359e9d
22 changed files with 35 additions and 99 deletions

View File

@@ -20,6 +20,7 @@ i.e. an alternative to the usual interface, for Audacity.
#include "Audacity.h"
#include "ModuleManager.h"
#include "audacity/ModuleInterface.h"
#include "Experimental.h"
@@ -446,7 +447,7 @@ void ModuleManager::InitializeBuiltins()
for (auto moduleMain : builtinModuleList())
{
ModuleInterfaceHandle module {
moduleMain(this, NULL), ModuleInterfaceDeleter{}
moduleMain(nullptr), ModuleInterfaceDeleter{}
};
if (module->Initialize())
@@ -480,7 +481,7 @@ ModuleInterface *ModuleManager::LoadModule(const PluginPath & path)
if (success && audacityMain)
{
ModuleInterfaceHandle handle {
audacityMain(this, &path), ModuleInterfaceDeleter{}
audacityMain(&path), ModuleInterfaceDeleter{}
};
if (handle)
{
@@ -518,27 +519,6 @@ void ModuleInterfaceDeleter::operator() (ModuleInterface *pInterface) const
}
}
void ModuleManager::RegisterModule(ModuleInterface *inModule)
{
std::unique_ptr<ModuleInterface> module{ inModule };
PluginID id = PluginManager::GetID(module.get());
if (mDynModules.find(id) != mDynModules.end())
{
// TODO: Should we complain about a duplicate registration????
// PRL: Don't leak resources!
module->Terminate();
return;
}
mDynModules[id] = ModuleInterfaceHandle {
module.release(), ModuleInterfaceDeleter{}
};
PluginManager::Get().RegisterPlugin(inModule);
}
PluginPaths ModuleManager::FindPluginsForProvider(const PluginID & providerID,
const PluginPath & path)
{