Skip to content

Commit

Permalink
Store missed latency call and report after activate()
Browse files Browse the repository at this point in the history
  • Loading branch information
Schroedingers-Cat committed Feb 26, 2024
1 parent 91b1d32 commit 2ecf4a2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/wrapasvst3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ tresult PLUGIN_API ClapAsVst3::setActive(TBool state)
componentHandler, this, supportsnoteexpression,
_expressionmap & clap_supported_note_expressions::AS_VST3_NOTE_EXPRESSION_TUNING);
updateAudioBusses();

if (missedLatencyRequest) {
latency_changed();
}

_os_attached.on();
}
Expand Down Expand Up @@ -132,11 +136,19 @@ tresult PLUGIN_API ClapAsVst3::getState(IBStream* state)

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

if (!_active)
{
missedLatencyRequest = true;
return 0;
}

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

uint32 PLUGIN_API ClapAsVst3::getTailSamples()
Expand Down
1 change: 1 addition & 0 deletions src/wrapasvst3.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ 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 2ecf4a2

Please sign in to comment.