Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply latency active patch #59

Merged
merged 1 commit into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading