1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-11-21 08:27:13 +01:00

Revert "Bug 2431 - Mac: Real-time effects - Enable checkbox has no effect"

... so I can make a more general fix, for more than only AudioUnit effects

This reverts commit 5e8cfb0c5a.
This commit is contained in:
Paul Licameli
2020-05-29 20:42:18 -04:00
parent a4b0635dd5
commit 9894abc4f4
2 changed files with 36 additions and 99 deletions

View File

@@ -87,13 +87,9 @@ BlackList[] =
}; };
struct CFReleaser struct CFReleaser
{ { void operator () (const void *p) const { if (p) CFRelease(p); } };
void operator () (const void *p) const template <typename T>
{ using CFunique_ptr = std::unique_ptr<T, CFReleaser>;
if (p) CFRelease(p);
}
};
template <typename T> using CFunique_ptr = std::unique_ptr<T, CFReleaser>;
// Uncomment to include parameter IDs in the final name. Only needed if it's // Uncomment to include parameter IDs in the final name. Only needed if it's
// discovered that many effects have duplicate names. It could even be done // discovered that many effects have duplicate names. It could even be done
@@ -363,20 +359,16 @@ unsigned AudioUnitEffectsModule::DiscoverPluginsAtPath(
} }
if(callback) if(callback)
{
callback(this, &effect); callback(this, &effect);
}
return 1; return 1;
} }
bool AudioUnitEffectsModule::IsPluginValid(const PluginPath & path, bool bFast) bool AudioUnitEffectsModule::IsPluginValid(
const PluginPath & path, bool bFast)
{ {
if( bFast ) if( bFast )
{
return true; return true;
}
wxString name; wxString name;
return FindAudioUnit(path, name) != NULL; return FindAudioUnit(path, name) != NULL;
} }
@@ -860,8 +852,6 @@ AudioUnitEffect::AudioUnitEffect(const PluginPath & path,
mUnitInitialized = false; mUnitInitialized = false;
mEventListenerRef = NULL; mEventListenerRef = NULL;
mReady = false;
} }
AudioUnitEffect::~AudioUnitEffect() AudioUnitEffect::~AudioUnitEffect()
@@ -1357,18 +1347,14 @@ bool AudioUnitEffect::RealtimeAddProcessor(unsigned numChannels, float sampleRat
{ {
auto slave = std::make_unique<AudioUnitEffect>(mPath, mName, mComponent, this); auto slave = std::make_unique<AudioUnitEffect>(mPath, mName, mComponent, this);
if (!slave->SetHost(NULL)) if (!slave->SetHost(NULL))
{
return false; return false;
}
slave->SetBlockSize(mBlockSize); slave->SetBlockSize(mBlockSize);
slave->SetChannelCount(numChannels); slave->SetChannelCount(numChannels);
slave->SetSampleRate(sampleRate); slave->SetSampleRate(sampleRate);
if (!CopyParameters(mUnit, slave->mUnit)) if (!CopyParameters(mUnit, slave->mUnit))
{
return false; return false;
}
auto pSlave = slave.get(); auto pSlave = slave.get();
mSlaves.push_back(std::move(slave)); mSlaves.push_back(std::move(slave));
@@ -1379,9 +1365,7 @@ bool AudioUnitEffect::RealtimeAddProcessor(unsigned numChannels, float sampleRat
bool AudioUnitEffect::RealtimeFinalize() bool AudioUnitEffect::RealtimeFinalize()
{ {
for (size_t i = 0, cnt = mSlaves.size(); i < cnt; i++) for (size_t i = 0, cnt = mSlaves.size(); i < cnt; i++)
{
mSlaves[i]->ProcessFinalize(); mSlaves[i]->ProcessFinalize();
}
mSlaves.clear(); mSlaves.clear();
mMasterIn.reset(); mMasterIn.reset();
@@ -1392,36 +1376,18 @@ bool AudioUnitEffect::RealtimeFinalize()
bool AudioUnitEffect::RealtimeSuspend() bool AudioUnitEffect::RealtimeSuspend()
{ {
if (!BypassEffect(true))
{
return false;
}
for (size_t i = 0, cnt = mSlaves.size(); i < cnt; i++)
{
if (!mSlaves[i]->BypassEffect(true))
{
return false;
}
}
return true; return true;
} }
bool AudioUnitEffect::RealtimeResume() bool AudioUnitEffect::RealtimeResume()
{ {
if (!BypassEffect(false)) OSStatus result;
{
return false;
}
for (size_t i = 0, cnt = mSlaves.size(); i < cnt; i++) result = AudioUnitReset(mUnit, kAudioUnitScope_Global, 0);
{ if (result != noErr)
if (!mSlaves[i]->BypassEffect(false))
{ {
return false; return false;
} }
}
return true; return true;
} }
@@ -1429,9 +1395,7 @@ bool AudioUnitEffect::RealtimeResume()
bool AudioUnitEffect::RealtimeProcessStart() bool AudioUnitEffect::RealtimeProcessStart()
{ {
for (size_t i = 0; i < mAudioIns; i++) for (size_t i = 0; i < mAudioIns; i++)
{
memset(mMasterIn[i].get(), 0, mBlockSize * sizeof(float)); memset(mMasterIn[i].get(), 0, mBlockSize * sizeof(float));
}
mNumSamples = 0; mNumSamples = 0;
@@ -1459,23 +1423,21 @@ size_t AudioUnitEffect::RealtimeProcess(int group,
bool AudioUnitEffect::RealtimeProcessEnd() bool AudioUnitEffect::RealtimeProcessEnd()
{ {
ProcessBlock(reinterpret_cast<float**>(mMasterIn.get()), ProcessBlock(
reinterpret_cast<float**>(mMasterIn.get()),
reinterpret_cast<float**>(mMasterOut.get()), reinterpret_cast<float**>(mMasterOut.get()),
mNumSamples); mNumSamples);
return true; return true;
} }
bool AudioUnitEffect::ShowInterface(wxWindow &parent, bool AudioUnitEffect::ShowInterface(
const EffectDialogFactory &factory, wxWindow &parent, const EffectDialogFactory &factory, bool forceModal)
bool forceModal)
{ {
if (mDialog) if (mDialog)
{ {
if( mDialog->Close(true) ) if( mDialog->Close(true) )
{
mDialog = nullptr; mDialog = nullptr;
}
return false; return false;
} }
@@ -1483,10 +1445,7 @@ bool AudioUnitEffect::ShowInterface(wxWindow &parent,
auto cleanup = valueRestorer( mDialog ); auto cleanup = valueRestorer( mDialog );
if ( factory ) if ( factory )
{
mDialog = factory(parent, mHost, this); mDialog = factory(parent, mHost, this);
}
if (!mDialog) if (!mDialog)
{ {
return false; return false;
@@ -2688,24 +2647,4 @@ void AudioUnitEffect::GetChannelCounts()
return; return;
} }
bool AudioUnitEffect::BypassEffect(bool bypass)
{
OSStatus result;
UInt32 value = (bypass ? 1 : 0);
result = AudioUnitSetProperty(mUnit,
kAudioUnitProperty_BypassEffect,
kAudioUnitScope_Global,
0,
&value,
sizeof(value));
if (result != noErr)
{
return false;
}
return true;
}
#endif #endif

View File

@@ -172,8 +172,6 @@ private:
bool CreatePlain(wxWindow *parent); bool CreatePlain(wxWindow *parent);
#endif #endif
bool BypassEffect(bool bypass);
private: private:
PluginPath mPath; PluginPath mPath;