Make sure "default" builtin effects are always registered
This appears to be a little overboard, but it makes the registration of defaults a little more generic.
This commit is contained in:
parent
07f965a057
commit
186cdb1248
|
@ -56,6 +56,8 @@ class PluginManagerInterface
|
|||
public:
|
||||
virtual ~PluginManagerInterface() {};
|
||||
|
||||
virtual bool IsPluginRegistered(const PluginID & ID) = 0;
|
||||
|
||||
virtual const PluginID & RegisterPlugin(ModuleInterface *module) = 0;
|
||||
virtual const PluginID & RegisterPlugin(ModuleInterface *provider, EffectIdentInterface *effect) = 0;
|
||||
virtual const PluginID & RegisterPlugin(ModuleInterface *provider, ImporterInterface *importer) = 0;
|
||||
|
|
|
@ -395,7 +395,6 @@ public:
|
|||
// constructors and destructors
|
||||
PluginRegistrationDialog(ProviderMap & map);
|
||||
virtual ~PluginRegistrationDialog();
|
||||
void RegisterDefaultEffects();
|
||||
|
||||
private:
|
||||
void Populate();
|
||||
|
@ -887,58 +886,6 @@ void PluginRegistrationDialog::OnOK(wxCommandEvent & WXUNUSED(evt))
|
|||
EndModal(mCancelClicked ? wxID_CANCEL : wxID_OK);
|
||||
}
|
||||
|
||||
void PluginRegistrationDialog::RegisterDefaultEffects()
|
||||
{
|
||||
PluginManager & pm = PluginManager::Get();
|
||||
ModuleManager & mm = ModuleManager::Get();
|
||||
|
||||
int i = 0;
|
||||
for (ProviderMap::iterator iter = mMap.begin(); iter != mMap.end(); ++iter, i++)
|
||||
{
|
||||
wxFileName fname = iter->first;
|
||||
wxString name = fname.GetName();
|
||||
wxString path = iter->first;
|
||||
|
||||
// Create a placeholder descriptor to show we've seen this plugin before and not
|
||||
// to show it as new the next time Audacity starts.
|
||||
//
|
||||
// Placeholder descriptors have a plugin type of PluginTypeNone and the ID is the
|
||||
// path.
|
||||
PluginDescriptor & plug = pm.mPlugins[path];
|
||||
|
||||
plug.SetID(path);
|
||||
plug.SetPath(path);
|
||||
plug.SetEnabled(false);
|
||||
plug.SetValid(false);
|
||||
|
||||
// This is just a proof of concept to show we can get a list of default effects.
|
||||
// Here we take the Builtin ones, and remove several optional ones, so that they become
|
||||
// opt-in.
|
||||
bool bAddIt = fname.GetVolume().StartsWith( wxString( BUILTIN_EFFECT_PREFIX).BeforeFirst(':') );
|
||||
wxLogDebug(wxT("Name: [%s]"), fname.GetName().c_str() );
|
||||
bAddIt &= !fname.GetName().StartsWith( wxT(" Leveller") );
|
||||
bAddIt &= !fname.GetName().StartsWith( wxT(" Auto Duck") );
|
||||
bAddIt &= !fname.GetName().StartsWith( wxT(" Paulstretch") );
|
||||
bAddIt &= !fname.GetName().StartsWith( wxT(" Time Scale") );
|
||||
bAddIt &= !fname.GetName().StartsWith( wxT(" Classic Filters") );
|
||||
|
||||
// Built in effects get registered...
|
||||
if (bAddIt)
|
||||
{
|
||||
wxArrayString providers = mMap[path];
|
||||
for (size_t j = 0, cnt = providers.GetCount(); j < cnt; j++)
|
||||
{
|
||||
if (mm.RegisterPlugin(providers[j], path))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
wxYield();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void PluginRegistrationDialog::OnCancel(wxCommandEvent & WXUNUSED(evt))
|
||||
{
|
||||
mCancelClicked = true;
|
||||
|
@ -1271,6 +1218,16 @@ void PluginDescriptor::SetImporterExtensions(const wxArrayString & extensions)
|
|||
//
|
||||
// ============================================================================
|
||||
|
||||
bool PluginManager::IsPluginRegistered(const PluginID & ID)
|
||||
{
|
||||
if (mPlugins.find(ID) == mPlugins.end())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
const PluginID & PluginManager::RegisterPlugin(ModuleInterface *module)
|
||||
{
|
||||
PluginDescriptor & plug = CreatePlugin(GetID(module), module, PluginTypeModule);
|
||||
|
@ -1615,11 +1572,7 @@ void PluginManager::Initialize()
|
|||
ModuleManager::Get().DiscoverProviders();
|
||||
|
||||
// And finally check for updates
|
||||
// CheckForUpdates will prompt for what to add normally.
|
||||
// If it is told kJUST_STANDARD_EFFECTS then it doesn't prompt.
|
||||
#ifdef EXPERIMENTAL_EFFECT_MANAGEMENT
|
||||
CheckForUpdates(kJUST_STANDARD_EFFECTS);
|
||||
#else
|
||||
#ifndef EXPERIMENTAL_EFFECT_MANAGEMENT
|
||||
CheckForUpdates();
|
||||
#endif
|
||||
}
|
||||
|
@ -2089,13 +2042,8 @@ void PluginManager::CheckForUpdates(eItemsToUpdate UpdateWhat)
|
|||
if (map.size() != 0)
|
||||
{
|
||||
PluginRegistrationDialog dlg(map);
|
||||
// If just standard effects, then no dialog needed.
|
||||
if( UpdateWhat == kJUST_STANDARD_EFFECTS )
|
||||
{
|
||||
dlg.RegisterDefaultEffects();
|
||||
gPrefs->Write(wxT("/Plugins/Rescan"), false);
|
||||
}
|
||||
else if (dlg.ShowModal() == wxID_OK)
|
||||
|
||||
if (dlg.ShowModal() == wxID_OK)
|
||||
{
|
||||
gPrefs->Write(wxT("/Plugins/Rescan"), false);
|
||||
}
|
||||
|
@ -2106,6 +2054,27 @@ void PluginManager::CheckForUpdates(eItemsToUpdate UpdateWhat)
|
|||
return;
|
||||
}
|
||||
|
||||
// Here solely for the purpose of Nyquist Workbench until
|
||||
// a better solution is devised.
|
||||
const PluginID & PluginManager::RegisterPlugin(EffectIdentInterface *effect)
|
||||
{
|
||||
PluginDescriptor & plug = CreatePlugin(GetID(effect), effect, PluginTypeEffect);
|
||||
|
||||
plug.SetEffectType(effect->GetType());
|
||||
plug.SetEffectFamily(effect->GetFamily());
|
||||
plug.SetEffectInteractive(effect->IsInteractive());
|
||||
plug.SetEffectDefault(effect->IsDefault());
|
||||
plug.SetEffectRealtime(effect->SupportsRealtime());
|
||||
plug.SetEffectAutomatable(effect->SupportsAutomation());
|
||||
|
||||
plug.SetInstance(effect);
|
||||
plug.SetEffectLegacy(true);
|
||||
plug.SetEnabled(true);
|
||||
plug.SetValid(true);
|
||||
|
||||
return plug.GetID();
|
||||
}
|
||||
|
||||
int PluginManager::GetPluginCount(PluginType type)
|
||||
{
|
||||
int num = 0;
|
||||
|
@ -2212,35 +2181,6 @@ const PluginDescriptor *PluginManager::GetNextPluginForEffectType(EffectType typ
|
|||
return NULL;
|
||||
}
|
||||
|
||||
bool PluginManager::IsRegistered(const PluginID & ID)
|
||||
{
|
||||
if (mPlugins.find(ID) == mPlugins.end())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
const PluginID & PluginManager::RegisterPlugin(EffectIdentInterface *effect)
|
||||
{
|
||||
PluginDescriptor & plug = CreatePlugin(GetID(effect), effect, PluginTypeEffect);
|
||||
|
||||
plug.SetEffectType(effect->GetType());
|
||||
plug.SetEffectFamily(effect->GetFamily());
|
||||
plug.SetEffectInteractive(effect->IsInteractive());
|
||||
plug.SetEffectDefault(effect->IsDefault());
|
||||
plug.SetEffectRealtime(effect->SupportsRealtime());
|
||||
plug.SetEffectAutomatable(effect->SupportsAutomation());
|
||||
|
||||
plug.SetInstance(effect);
|
||||
plug.SetEffectLegacy(true);
|
||||
plug.SetEnabled(true);
|
||||
plug.SetValid(true);
|
||||
|
||||
return plug.GetID();
|
||||
}
|
||||
|
||||
bool PluginManager::IsPluginEnabled(const PluginID & ID)
|
||||
{
|
||||
if (mPlugins.find(ID) == mPlugins.end())
|
||||
|
@ -2305,17 +2245,6 @@ IdentInterface *PluginManager::GetInstance(const PluginID & ID)
|
|||
return plug.GetInstance();
|
||||
}
|
||||
|
||||
// TODO: This goes away when all effects have been converted
|
||||
void PluginManager::SetInstance(const PluginID & ID, IdentInterface *instance)
|
||||
{
|
||||
if (mPlugins.find(ID) == mPlugins.end())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
return mPlugins[ID].SetInstance(instance);
|
||||
}
|
||||
|
||||
PluginID PluginManager::GetID(ModuleInterface *module)
|
||||
{
|
||||
return wxString::Format(wxT("%s_%s_%s_%s_%s"),
|
||||
|
|
|
@ -167,7 +167,6 @@ class PluginRegistrationDialog;
|
|||
|
||||
enum eItemsToUpdate {
|
||||
kCHECK_ALL,
|
||||
kJUST_STANDARD_EFFECTS,
|
||||
kPROMPT_TO_ADD_EFFECTS
|
||||
};
|
||||
|
||||
|
@ -180,6 +179,8 @@ public:
|
|||
|
||||
// PluginManagerInterface implementation
|
||||
|
||||
virtual bool IsPluginRegistered(const PluginID & ID);
|
||||
|
||||
virtual const PluginID & RegisterPlugin(ModuleInterface *module);
|
||||
virtual const PluginID & RegisterPlugin(ModuleInterface *provider, EffectIdentInterface *effect);
|
||||
virtual const PluginID & RegisterPlugin(ModuleInterface *provider, ImporterInterface *importer);
|
||||
|
@ -252,9 +253,6 @@ public:
|
|||
const PluginDescriptor *GetFirstPluginForEffectType(EffectType type);
|
||||
const PluginDescriptor *GetNextPluginForEffectType(EffectType type);
|
||||
|
||||
bool IsRegistered(const PluginID & ID);
|
||||
void RegisterPlugin(const wxString & type, const wxString & path);
|
||||
|
||||
bool IsPluginEnabled(const PluginID & ID);
|
||||
void EnablePlugin(const PluginID & ID, bool enable);
|
||||
|
||||
|
@ -263,12 +261,13 @@ public:
|
|||
// Returns translated string
|
||||
wxString GetName(const PluginID & ID);
|
||||
IdentInterface *GetInstance(const PluginID & ID);
|
||||
void SetInstance(const PluginID & ID, IdentInterface *instance); // TODO: Remove after conversion
|
||||
|
||||
// For builtin effects
|
||||
const PluginID & RegisterPlugin(EffectIdentInterface *effect);
|
||||
void CheckForUpdates(eItemsToUpdate UpdateWhat=kCHECK_ALL);
|
||||
|
||||
// Here solely for the purpose of Nyquist Workbench until
|
||||
// a better solution is devised.
|
||||
const PluginID & RegisterPlugin(EffectIdentInterface *effect);
|
||||
|
||||
private:
|
||||
void Load();
|
||||
void LoadGroup(PluginType type);
|
||||
|
|
|
@ -100,7 +100,7 @@
|
|||
#endif
|
||||
|
||||
//
|
||||
// Define the complete list of effects and how to instantiate each
|
||||
// Define the list of effects that will be autoregistered and how to instantiate each
|
||||
//
|
||||
#define EFFECT_LIST \
|
||||
EFFECT( CHIRP, EffectToneGen(true) ) \
|
||||
|
@ -109,18 +109,15 @@
|
|||
EFFECT( SILENCE, EffectSilence() ) \
|
||||
EFFECT( TONE, EffectToneGen(false) ) \
|
||||
EFFECT( AMPLIFY, EffectAmplify() ) \
|
||||
EFFECT( AUTODUCK, EffectAutoDuck() ) \
|
||||
EFFECT( BASSTREBLE, EffectBassTreble() ) \
|
||||
EFFECT( CHANGESPEED, EffectChangeSpeed() ) \
|
||||
EFFECT( CLICKREMOVAL, EffectClickRemoval() ) \
|
||||
EFFECT( COMPRESSOR, EffectCompressor() ) \
|
||||
EFFECT( ECHO, EffectEcho() ) \
|
||||
EFFECT( PAULSTRETCH, EffectPaulstretch() ) \
|
||||
EFFECT( EQUALIZATION, EffectEqualization() ) \
|
||||
EFFECT( FADEIN, EffectFade(true) ) \
|
||||
EFFECT( FADEOUT, EffectFade(false) ) \
|
||||
EFFECT( INVERT, EffectInvert() ) \
|
||||
EFFECT( LEVELLER, EffectLeveller() ) \
|
||||
EFFECT( NORMALIZE, EffectNormalize() ) \
|
||||
EFFECT( PHASER, EffectPhaser() ) \
|
||||
EFFECT( REPAIR, EffectRepair() ) \
|
||||
|
@ -132,8 +129,16 @@
|
|||
EFFECT( WAHWAH, EffectWahwah() ) \
|
||||
EFFECT( FINDCLIPPING, EffectFindClipping() ) \
|
||||
NOISEREDUCTION_EFFECT \
|
||||
SOUNDTOUCH_EFFECTS
|
||||
|
||||
//
|
||||
// Define the list of effects that do not get autoregistered
|
||||
//
|
||||
#define EXCLUDE_LIST \
|
||||
EFFECT( AUTODUCK, EffectAutoDuck() ) \
|
||||
EFFECT( LEVELLER, EffectLeveller() ) \
|
||||
EFFECT( PAULSTRETCH, EffectPaulstretch() ) \
|
||||
CLASSICFILTER_EFFECT \
|
||||
SOUNDTOUCH_EFFECTS \
|
||||
SBSMS_EFFECTS
|
||||
|
||||
//
|
||||
|
@ -147,6 +152,7 @@
|
|||
enum
|
||||
{
|
||||
EFFECT_LIST
|
||||
EXCLUDE_LIST
|
||||
};
|
||||
|
||||
//
|
||||
|
@ -163,6 +169,14 @@ static const wxChar *kEffectNames[] =
|
|||
EFFECT_LIST
|
||||
};
|
||||
|
||||
//
|
||||
// Create the effect name array of excluded effects
|
||||
//
|
||||
static const wxChar *kExcludedNames[] =
|
||||
{
|
||||
EXCLUDE_LIST
|
||||
};
|
||||
|
||||
//
|
||||
// Redefine EFFECT() to generate a case statement for the lookup switch
|
||||
//
|
||||
|
@ -256,6 +270,11 @@ bool BuiltinEffectsModule::Initialize()
|
|||
mNames.Add(wxString(BUILTIN_EFFECT_PREFIX) + kEffectNames[i]);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < WXSIZEOF(kExcludedNames); i++)
|
||||
{
|
||||
mNames.Add(wxString(BUILTIN_EFFECT_PREFIX) + kExcludedNames[i]);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -265,9 +284,19 @@ void BuiltinEffectsModule::Terminate()
|
|||
return;
|
||||
}
|
||||
|
||||
bool BuiltinEffectsModule::AutoRegisterPlugins(PluginManagerInterface & WXUNUSED(pm))
|
||||
bool BuiltinEffectsModule::AutoRegisterPlugins(PluginManagerInterface & pm)
|
||||
{
|
||||
// Nothing to do here
|
||||
for (size_t i = 0; i < WXSIZEOF(kEffectNames); i++)
|
||||
{
|
||||
PluginID ID(wxString(BUILTIN_EFFECT_PREFIX) + kEffectNames[i]);
|
||||
|
||||
if (!pm.IsPluginRegistered(ID))
|
||||
{
|
||||
RegisterPlugin(pm, ID);
|
||||
}
|
||||
}
|
||||
|
||||
// We still want to be called during the normal registration process
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -320,6 +349,7 @@ Effect *BuiltinEffectsModule::Instantiate(const wxString & path)
|
|||
switch (mNames.Index(path))
|
||||
{
|
||||
EFFECT_LIST;
|
||||
EXCLUDE_LIST;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
|
Loading…
Reference in New Issue