diff --git a/include/clap/helpers/plugin.hh b/include/clap/helpers/plugin.hh index 28a1989..2ed3f32 100644 --- a/include/clap/helpers/plugin.hh +++ b/include/clap/helpers/plugin.hh @@ -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; diff --git a/include/clap/helpers/plugin.hxx b/include/clap/helpers/plugin.hxx index c73aaaf..db8d4b2 100644 --- a/include/clap/helpers/plugin.hxx +++ b/include/clap/helpers/plugin.hxx @@ -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; @@ -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.");