Skip to content

Commit

Permalink
Apply latency active patch (#59)
Browse files Browse the repository at this point in the history
Authored by David Schornsheim <[email protected]>
Reviewed by abique and me
  • Loading branch information
baconpaul committed Feb 20, 2024
1 parent 5d64e46 commit ea88647
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions include/clap/helpers/plugin.hh
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,7 @@ namespace clap { namespace helpers {
// state
bool _wasInitialized = false;
bool _isActive = false;
bool _isBeingActivated = false;
bool _isProcessing = false;
bool _isBeingDestroyed = false;
double _sampleRate = 0;
Expand Down
5 changes: 4 additions & 1 deletion include/clap/helpers/plugin.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -319,12 +319,15 @@ namespace clap { namespace helpers {
assert(!self._isActive);
assert(self._sampleRate == 0);

self._isBeingActivated = true;
if (!self.activate(sample_rate, minFrameCount, maxFrameCount)) {
self._isBeingActivated = false;
assert(!self._isActive);
assert(self._sampleRate == 0);
return false;
}

self._isBeingActivated = false;
self._isActive = true;
self._sampleRate = sample_rate;
return true;
Expand Down Expand Up @@ -506,7 +509,7 @@ namespace clap { namespace helpers {
self.ensureMainThread("clap_plugin_latency.get");

if (l >= CheckingLevel::Minimal) {
if (!self._isActive)
if (!self._isActive && !self._isBeingActivated)
self.hostMisbehaving("It is wrong to query the latency before the plugin is activated, "
"because if the plugin dosen't know the sample rate, it can't "
"know the number of samples of latency.");
Expand Down

0 comments on commit ea88647

Please sign in to comment.