Skip to content

Commit

Permalink
Revert "Check active state before querying latency. Fixes #229 (#230)"
Browse files Browse the repository at this point in the history
This reverts commit c8d35cc.
  • Loading branch information
defiantnerd committed Mar 10, 2024
1 parent c8d35cc commit 0c51f12
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 31 deletions.
35 changes: 5 additions & 30 deletions src/wrapasvst3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@ tresult PLUGIN_API ClapAsVst3::terminate()
if (_plugin)
{
_os_attached.off(); // ensure we are detached
if (_active)
{
_plugin->deactivate();
}
_plugin->terminate();
_plugin.reset();
}
Expand Down Expand Up @@ -91,11 +87,6 @@ tresult PLUGIN_API ClapAsVst3::setActive(TBool state)
_expressionmap & clap_supported_note_expressions::AS_VST3_NOTE_EXPRESSION_TUNING);
updateAudioBusses();

if (_missedLatencyRequest)
{
latency_changed();
}

_os_attached.on();
}
if (!state)
Expand All @@ -115,11 +106,6 @@ tresult PLUGIN_API ClapAsVst3::setActive(TBool state)

tresult PLUGIN_API ClapAsVst3::process(Vst::ProcessData& data)
{
if (!_active || !_processing)
{
return kNotInitialized;
}

auto thisFn = _plugin->AlwaysAudioThread();
this->_processAdapter->process(data);
return kResultOk;
Expand All @@ -146,19 +132,11 @@ tresult PLUGIN_API ClapAsVst3::getState(IBStream* state)

uint32 PLUGIN_API ClapAsVst3::getLatencySamples()
{
if (!_plugin->_ext._latency)
{
return 0;
}

if (!_active)
if (_plugin->_ext._latency)
{
_missedLatencyRequest = true;
return 0;
return _plugin->_ext._latency->get(_plugin->_plugin);
}

_missedLatencyRequest = false;
return _plugin->_ext._latency->get(_plugin->_plugin);
return 0;
}

uint32 PLUGIN_API ClapAsVst3::getTailSamples()
Expand Down Expand Up @@ -782,9 +760,7 @@ void ClapAsVst3::request_callback()

void ClapAsVst3::restartPlugin()
{
if (componentHandler)
componentHandler->restartComponent(Vst::RestartFlags::kIoChanged |
Vst::RestartFlags::kLatencyChanged);
if (componentHandler) componentHandler->restartComponent(Vst::RestartFlags::kReloadComponent);
}

void ClapAsVst3::onBeginEdit(clap_id id)
Expand Down Expand Up @@ -897,13 +873,12 @@ void ClapAsVst3::onIdle()
std::lock_guard lock(_processingLock);

_requestedFlush = false;
if (!_active)
if (!_processing)
{
// setup a ProcessAdapter just for flush with no audio
Clap::ProcessAdapter pa;
pa.setupProcessing(_plugin->_plugin, _plugin->_ext._params, audioInputs, audioOutputs, 0, 0, 0,
this->parameters, componentHandler, nullptr, false, false);
auto thisFn = _plugin->AlwaysMainThread();
pa.flush();
}
}
Expand Down
1 change: 0 additions & 1 deletion src/wrapasvst3.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,6 @@ class ClapAsVst3 : public Steinberg::Vst::SingleComponentEffect,
std::mutex _processingLock;
std::atomic_bool _requestedFlush = false;
std::atomic_bool _requestUICallback = false;
bool _missedLatencyRequest = false;

// the queue from audiothread to UI thread
ClapWrapper::detail::shared::fixedqueue<queueEvent, 8192> _queueToUI;
Expand Down

0 comments on commit 0c51f12

Please sign in to comment.