mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-11 09:31:13 +02: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:
parent
5bede69d11
commit
9360359e9d
@ -135,20 +135,6 @@ public:
|
||||
virtual void DeleteInstance(ComponentInterface *instance) = 0;
|
||||
};
|
||||
|
||||
// ============================================================================
|
||||
//
|
||||
// ModuleManagerInterface class
|
||||
//
|
||||
// ============================================================================
|
||||
|
||||
class ModuleManagerInterface /* not final */
|
||||
{
|
||||
public:
|
||||
|
||||
// Modules call this to register their interface
|
||||
virtual void RegisterModule(ModuleInterface *module) = 0;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// The default entry point name and the name that will be searched for during
|
||||
// load if the module has been built as a external library.
|
||||
@ -158,8 +144,7 @@ public:
|
||||
// ----------------------------------------------------------------------------
|
||||
// The module entry point prototype
|
||||
// ----------------------------------------------------------------------------
|
||||
typedef ModuleInterface *(*ModuleMain)(ModuleManagerInterface *moduleManager,
|
||||
const wxString *path);
|
||||
typedef ModuleInterface *(*ModuleMain)(const wxString *path);
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// If BUILDING_AUDACITY is defined during the current build, it is assumed
|
||||
@ -172,7 +157,7 @@ typedef ModuleInterface *(*ModuleMain)(ModuleManagerInterface *moduleManager,
|
||||
// be declared static so as not to interfere with other modules during link.
|
||||
// ----------------------------------------------------------------------------
|
||||
#define DECLARE_MODULE_ENTRY(name) \
|
||||
static ModuleInterface * name(ModuleManagerInterface *moduleManager, const wxString *path)
|
||||
static ModuleInterface * name(const wxString *path)
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// This will create a class and instnace that will register the module entry
|
||||
@ -214,8 +199,7 @@ void name::Register() \
|
||||
// ----------------------------------------------------------------------------
|
||||
#define DECLARE_MODULE_ENTRY(name) \
|
||||
extern "C" __declspec(dllexport) \
|
||||
ModuleInterface * name(ModuleManagerInterface *moduleManager, \
|
||||
const wxString *path)
|
||||
ModuleInterface * name(const wxString *path)
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Define these as empty will effectively remove the embedded registration
|
||||
|
@ -46,7 +46,6 @@
|
||||
#include "audacity/EffectInterface.h"
|
||||
#include "audacity/ComponentInterface.h"
|
||||
#include "audacity/ImporterInterface.h"
|
||||
#include "audacity/ModuleInterface.h"
|
||||
|
||||
|
||||
class ModuleInterface;
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -16,11 +16,13 @@
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#include "audacity/ModuleInterface.h"
|
||||
#include "audacity/Types.h"
|
||||
|
||||
class wxArrayString;
|
||||
class wxDynamicLibrary;
|
||||
class CommandHandler;
|
||||
class ComponentInterface;
|
||||
class ModuleInterface;
|
||||
|
||||
wxWindow * MakeHijackPanel();
|
||||
|
||||
@ -73,14 +75,9 @@ typedef std::map<wxString, ModuleInterfaceHandle> ModuleMap;
|
||||
typedef std::map<ModuleInterface *, std::unique_ptr<wxDynamicLibrary>> LibraryMap;
|
||||
using PluginIDs = wxArrayString;
|
||||
|
||||
class ModuleManager final : public ModuleManagerInterface
|
||||
class ModuleManager final
|
||||
{
|
||||
public:
|
||||
// -------------------------------------------------------------------------
|
||||
// ModuleManagerInterface implementation
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
void RegisterModule(ModuleInterface *module) override;
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// ModuleManager implementation
|
||||
|
@ -40,6 +40,7 @@ for shared and private configs - which need to move out.
|
||||
#include <wx/utils.h>
|
||||
|
||||
#include "audacity/EffectInterface.h"
|
||||
#include "audacity/ModuleInterface.h"
|
||||
|
||||
#include "FileNames.h"
|
||||
#include "ModuleManager.h"
|
||||
|
@ -18,7 +18,6 @@
|
||||
|
||||
#include "audacity/EffectInterface.h"
|
||||
#include "audacity/ImporterInterface.h"
|
||||
#include "audacity/ModuleInterface.h"
|
||||
#include "audacity/PluginInterface.h"
|
||||
|
||||
class wxArrayString;
|
||||
|
@ -55,7 +55,7 @@ DECLARE_MODULE_ENTRY(AudacityModule)
|
||||
{
|
||||
// Create and register the importer
|
||||
// Trust the module manager not to leak this
|
||||
return safenew BuiltinCommandsModule(moduleManager, path);
|
||||
return safenew BuiltinCommandsModule(path);
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
@ -69,10 +69,8 @@ DECLARE_BUILTIN_MODULE(BuiltinsCommandBuiltin);
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
BuiltinCommandsModule::BuiltinCommandsModule(ModuleManagerInterface *moduleManager,
|
||||
const wxString *path)
|
||||
BuiltinCommandsModule::BuiltinCommandsModule(const wxString *path)
|
||||
{
|
||||
mModMan = moduleManager;
|
||||
if (path)
|
||||
{
|
||||
mPath = *path;
|
||||
|
@ -27,7 +27,7 @@ class AudacityCommand;
|
||||
class BuiltinCommandsModule final : public ModuleInterface
|
||||
{
|
||||
public:
|
||||
BuiltinCommandsModule(ModuleManagerInterface *moduleManager, const wxString *path);
|
||||
BuiltinCommandsModule(const wxString *path);
|
||||
virtual ~BuiltinCommandsModule();
|
||||
|
||||
using Factory = std::function< std::unique_ptr<AudacityCommand> () >;
|
||||
@ -80,7 +80,6 @@ private:
|
||||
static void DoRegistration(
|
||||
const ComponentInterfaceSymbol &name, const Factory &factory );
|
||||
|
||||
ModuleManagerInterface *mModMan;
|
||||
wxString mPath;
|
||||
|
||||
using CommandHash = std::unordered_map< wxString, const Entry* > ;
|
||||
|
@ -53,7 +53,7 @@ DECLARE_MODULE_ENTRY(AudacityModule)
|
||||
{
|
||||
// Create and register the importer
|
||||
// Trust the module manager not to leak this
|
||||
return safenew BuiltinEffectsModule(moduleManager, path);
|
||||
return safenew BuiltinEffectsModule(path);
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
@ -67,10 +67,8 @@ DECLARE_BUILTIN_MODULE(BuiltinsEffectBuiltin);
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
BuiltinEffectsModule::BuiltinEffectsModule(ModuleManagerInterface *moduleManager,
|
||||
const wxString *path)
|
||||
BuiltinEffectsModule::BuiltinEffectsModule(const wxString *path)
|
||||
{
|
||||
mModMan = moduleManager;
|
||||
if (path)
|
||||
{
|
||||
mPath = *path;
|
||||
|
@ -26,7 +26,7 @@ class Effect;
|
||||
class BuiltinEffectsModule final : public ModuleInterface
|
||||
{
|
||||
public:
|
||||
BuiltinEffectsModule(ModuleManagerInterface *moduleManager, const wxString *path);
|
||||
BuiltinEffectsModule(const wxString *path);
|
||||
virtual ~BuiltinEffectsModule();
|
||||
|
||||
using Factory = std::function< std::unique_ptr<Effect> () >;
|
||||
@ -79,7 +79,6 @@ private:
|
||||
const ComponentInterfaceSymbol &name, const Factory &factory,
|
||||
bool excluded );
|
||||
|
||||
ModuleManagerInterface *mModMan;
|
||||
PluginPath mPath;
|
||||
|
||||
struct Entry;
|
||||
|
@ -143,7 +143,7 @@ DECLARE_MODULE_ENTRY(AudacityModule)
|
||||
{
|
||||
// Create our effects module and register
|
||||
// Trust the module manager not to leak this
|
||||
return safenew VSTEffectsModule(moduleManager, path);
|
||||
return safenew VSTEffectsModule(path);
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
@ -306,10 +306,8 @@ public:
|
||||
// VSTEffectsModule
|
||||
//
|
||||
// ============================================================================
|
||||
VSTEffectsModule::VSTEffectsModule(ModuleManagerInterface *moduleManager,
|
||||
const wxString *path)
|
||||
VSTEffectsModule::VSTEffectsModule(const wxString *path)
|
||||
{
|
||||
mModMan = moduleManager;
|
||||
if (path)
|
||||
{
|
||||
mPath = *path;
|
||||
|
@ -403,7 +403,7 @@ private:
|
||||
class VSTEffectsModule final : public ModuleInterface
|
||||
{
|
||||
public:
|
||||
VSTEffectsModule(ModuleManagerInterface *moduleManager, const wxString *path);
|
||||
VSTEffectsModule(const wxString *path);
|
||||
virtual ~VSTEffectsModule();
|
||||
|
||||
// ComponentInterface implementation
|
||||
@ -440,7 +440,6 @@ public:
|
||||
static void Check(const wxChar *path);
|
||||
|
||||
private:
|
||||
ModuleManagerInterface *mModMan;
|
||||
PluginPath mPath;
|
||||
};
|
||||
|
||||
|
@ -232,7 +232,7 @@ DECLARE_MODULE_ENTRY(AudacityModule)
|
||||
{
|
||||
// Create and register the importer
|
||||
// Trust the module manager not to leak this
|
||||
return safenew AudioUnitEffectsModule(moduleManager, path);
|
||||
return safenew AudioUnitEffectsModule(path);
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
@ -246,10 +246,8 @@ DECLARE_BUILTIN_MODULE(AudioUnitEffectsBuiltin);
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
AudioUnitEffectsModule::AudioUnitEffectsModule(ModuleManagerInterface *moduleManager,
|
||||
const wxString *path)
|
||||
AudioUnitEffectsModule::AudioUnitEffectsModule(const wxString *path)
|
||||
{
|
||||
mModMan = moduleManager;
|
||||
if (path)
|
||||
{
|
||||
mPath = *path;
|
||||
|
@ -232,7 +232,7 @@ private:
|
||||
class AudioUnitEffectsModule final : public ModuleInterface
|
||||
{
|
||||
public:
|
||||
AudioUnitEffectsModule(ModuleManagerInterface *moduleManager, const wxString *path);
|
||||
AudioUnitEffectsModule(const wxString *path);
|
||||
virtual ~AudioUnitEffectsModule();
|
||||
|
||||
// ComponentInterface implementation
|
||||
@ -273,7 +273,6 @@ public:
|
||||
OSType ToOSType(const wxString & type);
|
||||
|
||||
private:
|
||||
ModuleManagerInterface *mModMan;
|
||||
wxString mPath;
|
||||
};
|
||||
|
||||
|
@ -85,7 +85,7 @@ DECLARE_MODULE_ENTRY(AudacityModule)
|
||||
{
|
||||
// Create and register the importer
|
||||
// Trust the module manager not to leak this
|
||||
return safenew LadspaEffectsModule(moduleManager, path);
|
||||
return safenew LadspaEffectsModule(path);
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
@ -99,10 +99,8 @@ DECLARE_BUILTIN_MODULE(LadspaBuiltin);
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
LadspaEffectsModule::LadspaEffectsModule(ModuleManagerInterface *moduleManager,
|
||||
const wxString *path)
|
||||
LadspaEffectsModule::LadspaEffectsModule(const wxString *path)
|
||||
{
|
||||
mModMan = moduleManager;
|
||||
if (path)
|
||||
{
|
||||
mPath = *path;
|
||||
|
@ -208,7 +208,7 @@ private:
|
||||
class LadspaEffectsModule final : public ModuleInterface
|
||||
{
|
||||
public:
|
||||
LadspaEffectsModule(ModuleManagerInterface *moduleManager, const wxString *path);
|
||||
LadspaEffectsModule(const wxString *path);
|
||||
virtual ~LadspaEffectsModule();
|
||||
|
||||
// ComponentInterface implementation
|
||||
@ -245,7 +245,6 @@ public:
|
||||
FilePaths GetSearchPaths();
|
||||
|
||||
private:
|
||||
ModuleManagerInterface *mModMan;
|
||||
wxString mPath;
|
||||
};
|
||||
|
||||
|
@ -59,7 +59,7 @@ DECLARE_MODULE_ENTRY(AudacityModule)
|
||||
{
|
||||
// Create and register the importer
|
||||
// Trust the module manager not to leak this
|
||||
return safenew LV2EffectsModule(moduleManager, path);
|
||||
return safenew LV2EffectsModule(path);
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
@ -76,10 +76,8 @@ using UriHash = std::unordered_map<wxString, LilvNode*>;
|
||||
|
||||
LilvWorld *gWorld = NULL;
|
||||
|
||||
LV2EffectsModule::LV2EffectsModule(ModuleManagerInterface *moduleManager,
|
||||
const wxString *path)
|
||||
LV2EffectsModule::LV2EffectsModule(const wxString *path)
|
||||
{
|
||||
mModMan = moduleManager;
|
||||
if (path)
|
||||
{
|
||||
mPath = *path;
|
||||
|
@ -163,7 +163,7 @@
|
||||
class LV2EffectsModule final : public ModuleInterface
|
||||
{
|
||||
public:
|
||||
LV2EffectsModule(ModuleManagerInterface *moduleManager, const wxString *path);
|
||||
LV2EffectsModule(const wxString *path);
|
||||
virtual ~LV2EffectsModule();
|
||||
|
||||
// ComponentInterface implementation
|
||||
@ -201,7 +201,6 @@ private:
|
||||
const LilvPlugin *GetPlugin(const PluginPath & path);
|
||||
|
||||
private:
|
||||
ModuleManagerInterface *mModMan;
|
||||
PluginPath mPath;
|
||||
};
|
||||
|
||||
|
@ -66,7 +66,7 @@ DECLARE_MODULE_ENTRY(AudacityModule)
|
||||
{
|
||||
// Create and register the importer
|
||||
// Trust the module manager not to leak this
|
||||
return safenew NyquistEffectsModule(moduleManager, path);
|
||||
return safenew NyquistEffectsModule(path);
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
@ -80,10 +80,8 @@ DECLARE_BUILTIN_MODULE(NyquistsEffectBuiltin);
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
NyquistEffectsModule::NyquistEffectsModule(ModuleManagerInterface *moduleManager,
|
||||
const wxString *path)
|
||||
NyquistEffectsModule::NyquistEffectsModule(const wxString *path)
|
||||
{
|
||||
mModMan = moduleManager;
|
||||
if (path)
|
||||
{
|
||||
mPath = *path;
|
||||
|
@ -21,7 +21,7 @@
|
||||
class NyquistEffectsModule final : public ModuleInterface
|
||||
{
|
||||
public:
|
||||
NyquistEffectsModule(ModuleManagerInterface *moduleManager, const wxString *path);
|
||||
NyquistEffectsModule(const wxString *path);
|
||||
virtual ~NyquistEffectsModule();
|
||||
|
||||
// ComponentInterface implementation
|
||||
@ -57,6 +57,5 @@ public:
|
||||
// NyquistEffectModule implementation
|
||||
|
||||
private:
|
||||
ModuleManagerInterface *mModMan;
|
||||
PluginPath mPath;
|
||||
};
|
||||
|
@ -37,7 +37,7 @@ DECLARE_MODULE_ENTRY(AudacityModule)
|
||||
{
|
||||
// Create and register the importer
|
||||
// Trust the module manager not to leak this
|
||||
return safenew VampEffectsModule(moduleManager, path);
|
||||
return safenew VampEffectsModule(path);
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
@ -51,10 +51,8 @@ DECLARE_BUILTIN_MODULE(VampsEffectBuiltin);
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
VampEffectsModule::VampEffectsModule(ModuleManagerInterface *moduleManager,
|
||||
const wxString *path)
|
||||
VampEffectsModule::VampEffectsModule(const wxString *path)
|
||||
{
|
||||
mModMan = moduleManager;
|
||||
if (path)
|
||||
{
|
||||
mPath = *path;
|
||||
|
@ -29,7 +29,7 @@
|
||||
class VampEffectsModule final : public ModuleInterface
|
||||
{
|
||||
public:
|
||||
VampEffectsModule(ModuleManagerInterface *moduleManager, const wxString *path);
|
||||
VampEffectsModule(const wxString *path);
|
||||
virtual ~VampEffectsModule();
|
||||
|
||||
// ComponentInterface implementation
|
||||
@ -69,7 +69,6 @@ private:
|
||||
bool & hasParameters);
|
||||
|
||||
private:
|
||||
ModuleManagerInterface *mModMan;
|
||||
PluginPath mPath;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user