mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-31 16:09:28 +02:00
Slightly better error handling during effect initialization
It at least detects load failures now. ;-)
This commit is contained in:
parent
b20cadd01f
commit
3d8de17c22
@ -67,65 +67,6 @@ wxString Effect::StripAmpersand(const wxString& str)
|
|||||||
|
|
||||||
// Legacy (or full blown effect)
|
// Legacy (or full blown effect)
|
||||||
Effect::Effect()
|
Effect::Effect()
|
||||||
{
|
|
||||||
CommonInit();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Effect hosting an effect client
|
|
||||||
Effect::Effect(EffectClientInterface *client)
|
|
||||||
{
|
|
||||||
CommonInit();
|
|
||||||
|
|
||||||
mClient = client;
|
|
||||||
mClient->SetHost(this);
|
|
||||||
mClient->Startup();
|
|
||||||
|
|
||||||
mNumAudioIn = mClient->GetAudioInCount();
|
|
||||||
mNumAudioOut = mClient->GetAudioOutCount();
|
|
||||||
|
|
||||||
mInBuffer = NULL;
|
|
||||||
mOutBuffer = NULL;
|
|
||||||
mInBufPos = NULL;
|
|
||||||
mOutBufPos = NULL;
|
|
||||||
|
|
||||||
mBufferSize = 0;
|
|
||||||
mBlockSize = 0;
|
|
||||||
mNumChannels = 0;
|
|
||||||
|
|
||||||
int flags = PLUGIN_EFFECT;
|
|
||||||
switch (mClient->GetType())
|
|
||||||
{
|
|
||||||
case EffectTypeGenerate:
|
|
||||||
flags |= INSERT_EFFECT;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EffectTypeProcess:
|
|
||||||
flags |= PROCESS_EFFECT;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EffectTypeAnalyze:
|
|
||||||
flags |= INSERT_EFFECT;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
SetEffectFlags(flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
Effect::~Effect()
|
|
||||||
{
|
|
||||||
if (mClient)
|
|
||||||
{
|
|
||||||
mClient->Shutdown();
|
|
||||||
delete mClient;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mWarper != NULL)
|
|
||||||
{
|
|
||||||
delete mWarper;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Effect::CommonInit()
|
|
||||||
{
|
{
|
||||||
mClient = NULL;
|
mClient = NULL;
|
||||||
|
|
||||||
@ -142,6 +83,31 @@ void Effect::CommonInit()
|
|||||||
// Can change effect flags later (this is the new way)
|
// Can change effect flags later (this is the new way)
|
||||||
// OR using the old way, over-ride GetEffectFlags().
|
// OR using the old way, over-ride GetEffectFlags().
|
||||||
mFlags = BUILTIN_EFFECT | PROCESS_EFFECT | ADVANCED_EFFECT;
|
mFlags = BUILTIN_EFFECT | PROCESS_EFFECT | ADVANCED_EFFECT;
|
||||||
|
|
||||||
|
mNumAudioIn = 0;
|
||||||
|
mNumAudioOut = 0;
|
||||||
|
|
||||||
|
mInBuffer = NULL;
|
||||||
|
mOutBuffer = NULL;
|
||||||
|
mInBufPos = NULL;
|
||||||
|
mOutBufPos = NULL;
|
||||||
|
|
||||||
|
mBufferSize = 0;
|
||||||
|
mBlockSize = 0;
|
||||||
|
mNumChannels = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Effect::~Effect()
|
||||||
|
{
|
||||||
|
if (mClient)
|
||||||
|
{
|
||||||
|
mClient->Shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mWarper != NULL)
|
||||||
|
{
|
||||||
|
delete mWarper;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// EffectIdentInterface implementation
|
// EffectIdentInterface implementation
|
||||||
@ -416,6 +382,42 @@ bool Effect::SetPrivateConfig(const wxString & group, const wxString & key, cons
|
|||||||
|
|
||||||
// Effect implementation
|
// Effect implementation
|
||||||
|
|
||||||
|
bool Effect::Startup(EffectClientInterface *client)
|
||||||
|
{
|
||||||
|
// Need to set host now so client startup can use our services
|
||||||
|
client->SetHost(this);
|
||||||
|
|
||||||
|
// Bail if the client startup fails
|
||||||
|
if (!client->Startup())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Let destructor know we need to be shutdown
|
||||||
|
mClient = client;
|
||||||
|
|
||||||
|
mNumAudioIn = mClient->GetAudioInCount();
|
||||||
|
mNumAudioOut = mClient->GetAudioOutCount();
|
||||||
|
|
||||||
|
int flags = PLUGIN_EFFECT;
|
||||||
|
switch (mClient->GetType())
|
||||||
|
{
|
||||||
|
case EffectTypeGenerate:
|
||||||
|
flags |= INSERT_EFFECT;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EffectTypeProcess:
|
||||||
|
flags |= PROCESS_EFFECT;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EffectTypeAnalyze:
|
||||||
|
flags |= INSERT_EFFECT;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetEffectFlags(flags);
|
||||||
|
}
|
||||||
|
|
||||||
// All legacy effects should have this overridden
|
// All legacy effects should have this overridden
|
||||||
wxString Effect::GetEffectName()
|
wxString Effect::GetEffectName()
|
||||||
{
|
{
|
||||||
|
@ -74,7 +74,6 @@ class AUDACITY_DLL_API Effect : public EffectHostInterface
|
|||||||
// The constructor is called once by each subclass at the beginning of the program.
|
// The constructor is called once by each subclass at the beginning of the program.
|
||||||
// Avoid allocating memory or doing time-consuming processing here.
|
// Avoid allocating memory or doing time-consuming processing here.
|
||||||
Effect();
|
Effect();
|
||||||
Effect(EffectClientInterface *client);
|
|
||||||
virtual ~Effect();
|
virtual ~Effect();
|
||||||
|
|
||||||
// IdentInterface implementation
|
// IdentInterface implementation
|
||||||
@ -131,6 +130,7 @@ class AUDACITY_DLL_API Effect : public EffectHostInterface
|
|||||||
virtual bool SetPrivateConfig(const wxString & group, const wxString & key, const sampleCount & value);
|
virtual bool SetPrivateConfig(const wxString & group, const wxString & key, const sampleCount & value);
|
||||||
|
|
||||||
// Effect implementation
|
// Effect implementation
|
||||||
|
virtual bool Startup(EffectClientInterface *client);
|
||||||
|
|
||||||
// Each subclass of Effect should override this method.
|
// Each subclass of Effect should override this method.
|
||||||
// This name will go in the menu bar;
|
// This name will go in the menu bar;
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
|
#include <wx/msgdlg.h>
|
||||||
#include <wx/stopwatch.h>
|
#include <wx/stopwatch.h>
|
||||||
#include <wx/tokenzr.h>
|
#include <wx/tokenzr.h>
|
||||||
|
|
||||||
@ -633,20 +634,26 @@ Effect *EffectManager::GetEffect(const PluginID & ID)
|
|||||||
// TODO: This is temporary and should be redone when all effects are converted
|
// TODO: This is temporary and should be redone when all effects are converted
|
||||||
if (mEffectPlugins.Index(wxString(ID)) == wxNOT_FOUND)
|
if (mEffectPlugins.Index(wxString(ID)) == wxNOT_FOUND)
|
||||||
{
|
{
|
||||||
// This will instantiate the effect client if it hasn't already been done
|
effect = new Effect();
|
||||||
EffectClientInterface *client = static_cast<EffectClientInterface *>(PluginManager::Get().GetInstance(ID));
|
if (effect)
|
||||||
if (client)
|
|
||||||
{
|
{
|
||||||
effect = new Effect(client);
|
// This will instantiate the effect client if it hasn't already been done
|
||||||
if (effect)
|
EffectClientInterface *client = static_cast<EffectClientInterface *>(PluginManager::Get().GetInstance(ID));
|
||||||
|
if (client && effect->Startup(client))
|
||||||
{
|
{
|
||||||
effect->SetEffectID(mNumEffects++);
|
effect->SetEffectID(mNumEffects++);
|
||||||
PluginManager::Get().SetInstance(ID, effect);
|
PluginManager::Get().SetInstance(ID, effect);
|
||||||
mEffectPlugins.Add(ID);
|
mEffectPlugins.Add(ID);
|
||||||
|
return effect;
|
||||||
}
|
}
|
||||||
|
|
||||||
return effect;
|
delete effect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxMessageBox(wxString::Format(_("Attempting to initialize the following effect failed:\n\n%s\n\nMore information may be available in Help->Show Log"),
|
||||||
|
PluginManager::Get().GetName(ID)),
|
||||||
|
_("Effect failed to initialize"));
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user