1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-08-08 08:01:19 +02:00

ModuleInterface::RegisterPlugin can report an error message

This commit is contained in:
Paul Licameli 2017-12-27 10:40:38 -05:00
parent f3a05540b0
commit 0f8bd45a7c
18 changed files with 75 additions and 23 deletions

View File

@ -88,8 +88,10 @@ public:
// will be made to request registration of that plugin. If the module must create
// an instance of the plugin to register it, then then instance should be deleted
// after registration.
// Error message does not need to mention the path.
virtual bool RegisterPlugin(PluginManagerInterface & pluginManager,
const wxString & path) = 0;
const wxString & path,
wxString &errMsg) = 0;
// For modules providing an interface to other dynamically loaded plugins,
// the module returns true if the plugin is still valid, otherwise false.

View File

@ -539,14 +539,16 @@ wxArrayString ModuleManager::FindPluginsForProvider(const PluginID & providerID,
return mDynModules[providerID]->FindPlugins(PluginManager::Get());
}
bool ModuleManager::RegisterPlugin(const PluginID & providerID, const wxString & path)
bool ModuleManager::RegisterPlugin(const PluginID & providerID, const wxString & path, wxString &errMsg)
{
errMsg.clear();
if (mDynModules.find(providerID) == mDynModules.end())
{
return false;
}
return mDynModules[providerID]->RegisterPlugin(PluginManager::Get(), path);
return mDynModules[providerID]->RegisterPlugin(PluginManager::Get(), path,
errMsg);
}
IdentInterface *ModuleManager::CreateProviderInstance(const PluginID & providerID,

View File

@ -99,7 +99,8 @@ public:
void FindAllPlugins(PluginIDList & providers, wxArrayString & paths);
wxArrayString FindPluginsForProvider(const PluginID & provider, const wxString & path);
bool RegisterPlugin(const PluginID & provider, const wxString & path);
bool RegisterPlugin(const PluginID & provider, const wxString & path,
wxString &errMsg);
IdentInterface *CreateProviderInstance(const PluginID & provider, const wxString & path);
IdentInterface *CreateInstance(const PluginID & provider, const wxString & path);

View File

@ -986,10 +986,14 @@ void PluginRegistrationDialog::OnOK(wxCommandEvent & WXUNUSED(evt))
break;
}
wxString errMsgs;
// Try to register the plugin via each provider until one succeeds
for (size_t j = 0, cnt = item.plugs.GetCount(); j < cnt; j++)
{
if (mm.RegisterPlugin(item.plugs[j]->GetProviderID(), path))
wxString errMsg;
if (mm.RegisterPlugin(item.plugs[j]->GetProviderID(), path,
errMsg))
{
for (size_t j = 0, cnt = item.plugs.GetCount(); j < cnt; j++)
{
@ -997,7 +1001,18 @@ void PluginRegistrationDialog::OnOK(wxCommandEvent & WXUNUSED(evt))
}
break;
}
else
{
if (errMsgs.empty())
errMsgs += '\n';
errMsgs += errMsg;
}
}
if (!errMsgs.empty())
::wxMessageBox( wxString::Format(
_("Effect at %s failed to register:\n%s"),
path, errMsgs
) );
}
else if (item.state == STATE_New)
{

View File

@ -289,13 +289,15 @@ void BuiltinEffectsModule::Terminate()
bool BuiltinEffectsModule::AutoRegisterPlugins(PluginManagerInterface & pm)
{
wxString ignoredErrMsg;
for (size_t i = 0; i < WXSIZEOF(kEffectNames); i++)
{
wxString path(wxString(BUILTIN_EFFECT_PREFIX) + kEffectNames[i]);
if (!pm.IsPluginRegistered(path))
{
RegisterPlugin(pm, path);
// No checking of error ?
RegisterPlugin(pm, path, ignoredErrMsg);
}
}
@ -308,8 +310,11 @@ wxArrayString BuiltinEffectsModule::FindPlugins(PluginManagerInterface & WXUNUSE
return mNames;
}
bool BuiltinEffectsModule::RegisterPlugin(PluginManagerInterface & pm, const wxString & path)
bool BuiltinEffectsModule::RegisterPlugin(PluginManagerInterface & pm,
const wxString & path,
wxString &errMsg)
{
errMsg.clear();
auto effect = Instantiate(path);
if (effect)
{

View File

@ -43,7 +43,8 @@ public:
bool AutoRegisterPlugins(PluginManagerInterface & pm) override;
wxArrayString FindPlugins(PluginManagerInterface & pm) override;
bool RegisterPlugin(PluginManagerInterface & pm, const wxString & path) override;
bool RegisterPlugin(PluginManagerInterface & pm,
const wxString & path, wxString &errMsg) override;
bool IsPluginValid(const wxString & path, bool bFast) override;

View File

@ -466,8 +466,10 @@ wxArrayString VSTEffectsModule::FindPlugins(PluginManagerInterface & pm)
return files;
}
bool VSTEffectsModule::RegisterPlugin(PluginManagerInterface & pm, const wxString & path)
bool VSTEffectsModule::RegisterPlugin(PluginManagerInterface & pm,
const wxString & path, wxString &errMsg)
{
errMsg.clear();
// TODO: Fix this for external usage
const wxString &cmdpath = PlatformCompatibility::GetExecutablePath();

View File

@ -393,7 +393,8 @@ public:
bool AutoRegisterPlugins(PluginManagerInterface & pm) override;
wxArrayString FindPlugins(PluginManagerInterface & pm) override;
bool RegisterPlugin(PluginManagerInterface & pm, const wxString & path) override;
bool RegisterPlugin(PluginManagerInterface & pm,
const wxString & path, wxString &errMsg) override;
bool IsPluginValid(const wxString & path, bool bFast) override;

View File

@ -171,8 +171,11 @@ wxArrayString AudioUnitEffectsModule::FindPlugins(PluginManagerInterface & pm)
return effects;
}
bool AudioUnitEffectsModule::RegisterPlugin(PluginManagerInterface & pm, const wxString & path)
bool AudioUnitEffectsModule::RegisterPlugin(PluginManagerInterface & pm,
const wxString & path,
wxString &errMsg)
{
errMsg.clear();
wxString name;
AudioComponent component = FindAudioUnit(path, name);
if (component == NULL)

View File

@ -245,7 +245,8 @@ public:
bool AutoRegisterPlugins(PluginManagerInterface & pm) override;
wxArrayString FindPlugins(PluginManagerInterface & pm) override;
bool RegisterPlugin(PluginManagerInterface & pm, const wxString & path) override;
bool RegisterPlugin(PluginManagerInterface & pm,
const wxString & path, wxString &errMsg) override;
bool IsPluginValid(const wxString & path, bool bFast) override;

View File

@ -160,6 +160,7 @@ bool LadspaEffectsModule::AutoRegisterPlugins(PluginManagerInterface & pm)
// Audacity. A little simplistic, but it should suffice for now.
wxArrayString pathList = GetSearchPaths();
wxArrayString files;
wxString ignoredErrMsg;
for (int i = 0; i < WXSIZEOF(kShippedEffects); i++)
{
@ -169,7 +170,8 @@ bool LadspaEffectsModule::AutoRegisterPlugins(PluginManagerInterface & pm)
{
if (!pm.IsPluginRegistered(files[j]))
{
RegisterPlugin(pm, files[j]);
// No checking for error ?
RegisterPlugin(pm, files[j], ignoredErrMsg);
}
}
}
@ -203,8 +205,11 @@ wxArrayString LadspaEffectsModule::FindPlugins(PluginManagerInterface & pm)
return files;
}
bool LadspaEffectsModule::RegisterPlugin(PluginManagerInterface & pm, const wxString & path)
bool LadspaEffectsModule::RegisterPlugin(PluginManagerInterface & pm,
const wxString & path,
wxString &errMsg)
{
errMsg.clear();
// Since we now have builtin VST support, ignore the VST bridge as it
// causes duplicate menu entries to appear.
wxFileName ff(path);

View File

@ -225,7 +225,8 @@ public:
bool AutoRegisterPlugins(PluginManagerInterface & pm) override;
wxArrayString FindPlugins(PluginManagerInterface & pm) override;
bool RegisterPlugin(PluginManagerInterface & pm, const wxString & path) override;
bool RegisterPlugin(PluginManagerInterface & pm, const wxString & path,
wxString &errMsg) override;
bool IsPluginValid(const wxString & path, bool bFast) override;

View File

@ -242,8 +242,10 @@ wxArrayString LV2EffectsModule::FindPlugins(PluginManagerInterface & WXUNUSED(pm
return plugins;
}
bool LV2EffectsModule::RegisterPlugin(PluginManagerInterface & pm, const wxString & path)
bool LV2EffectsModule::RegisterPlugin(PluginManagerInterface & pm,
const wxString & path, wxString &errMsg)
{
errMsg.clear();
const LilvPlugin *plug = GetPlugin(path);
if (!plug)
{

View File

@ -90,7 +90,8 @@ public:
bool AutoRegisterPlugins(PluginManagerInterface & pm) override;
wxArrayString FindPlugins(PluginManagerInterface & pm) override;
bool RegisterPlugin(PluginManagerInterface & pm, const wxString & path) override;
bool RegisterPlugin(PluginManagerInterface & pm,
const wxString & path, wxString &errMsg) override;
bool IsPluginValid(const wxString & path, bool bFast) override;

View File

@ -165,10 +165,12 @@ bool NyquistEffectsModule::AutoRegisterPlugins(PluginManagerInterface & pm)
// Audacity. A little simplistic, but it should suffice for now.
wxArrayString pathList = NyquistEffect::GetNyquistSearchPath();
wxArrayString files;
wxString ignoredErrMsg;
if (!pm.IsPluginRegistered(NYQUIST_PROMPT_ID))
{
RegisterPlugin(pm, NYQUIST_PROMPT_ID);
// No checking of error ?
RegisterPlugin(pm, NYQUIST_PROMPT_ID, ignoredErrMsg);
}
for (size_t i = 0; i < WXSIZEOF(kShippedEffects); i++)
@ -179,7 +181,8 @@ bool NyquistEffectsModule::AutoRegisterPlugins(PluginManagerInterface & pm)
{
if (!pm.IsPluginRegistered(files[j]))
{
RegisterPlugin(pm, files[j]);
// No checking of error ?
RegisterPlugin(pm, files[j], ignoredErrMsg);
}
}
}
@ -204,8 +207,11 @@ wxArrayString NyquistEffectsModule::FindPlugins(PluginManagerInterface & pm)
return files;
}
bool NyquistEffectsModule::RegisterPlugin(PluginManagerInterface & pm, const wxString & path)
bool NyquistEffectsModule::RegisterPlugin(PluginManagerInterface & pm,
const wxString & path,
wxString &errMsg)
{
errMsg.clear();
NyquistEffect effect(path);
if (effect.IsOk())
{

View File

@ -40,7 +40,8 @@ public:
bool AutoRegisterPlugins(PluginManagerInterface & pm) override;
wxArrayString FindPlugins(PluginManagerInterface & pm) override;
bool RegisterPlugin(PluginManagerInterface & pm, const wxString & path) override;
bool RegisterPlugin(PluginManagerInterface & pm,
const wxString & path, wxString &errMsg) override;
bool IsPluginValid(const wxString & path, bool bFast) override;

View File

@ -199,8 +199,10 @@ wxArrayString VampEffectsModule::FindPlugins(PluginManagerInterface & WXUNUSED(p
return names;
}
bool VampEffectsModule::RegisterPlugin(PluginManagerInterface & pm, const wxString & path)
bool VampEffectsModule::RegisterPlugin(PluginManagerInterface & pm,
const wxString & path, wxString &errMsg)
{
errMsg.clear();
int output;
bool hasParameters;

View File

@ -44,7 +44,8 @@ public:
bool AutoRegisterPlugins(PluginManagerInterface & pm) override;
wxArrayString FindPlugins(PluginManagerInterface & pm) override;
bool RegisterPlugin(PluginManagerInterface & pm, const wxString & path) override;
bool RegisterPlugin(PluginManagerInterface & pm,
const wxString & path, wxString &errMsg) override;
bool IsPluginValid(const wxString & path, bool bFast) override;