Conversation
defiantnerd
left a comment
There was a problem hiding this comment.
clarification is a good thing.
|
I think it is OK to call deactivate without stop processing. stop processing sends the plugin to sleep but the plugin is still active. Here's is the clap helpers: template <MisbehaviourHandler h, CheckingLevel l>
void Plugin<h, l>::clapDeactivate(const clap_plugin *plugin) noexcept {
auto &self = from(plugin);
self.ensureInitialized("deactivate");
self.ensureMainThread("clap_plugin.deactivate");
if (l >= CheckingLevel::Minimal) {
if (!self._isActive) {
self.hostMisbehaving("The plugin was deactivated twice.");
return;
}
}
self.deactivate();
self._isActive = false;
self._sampleRate = 0;
}
template <MisbehaviourHandler h, CheckingLevel l>
void Plugin<h, l>::clapStopProcessing(const clap_plugin *plugin) noexcept {
auto &self = from(plugin);
self.ensureInitialized("stop_processing");
self.ensureAudioThread("clap_plugin.stop_processing");
if (l >= CheckingLevel::Minimal) {
if (!self._isActive) {
self.hostMisbehaving(
"Host called clap_plugin.stop_processing() on a deactivated plugin");
return;
}
if (!self._isProcessing) {
self.hostMisbehaving("Host called clap_plugin.stop_processing() twice");
return;
}
}
self.stopProcessing();
self._isProcessing = false;
}And as you can see you can deactivate even if the plugin is still processing. A possible improvement would be to set |
|
The clap-helpers implement the docs, but the docs are imprecise and most of us think it should be mandatory to stop processing before deactivate. it is a proper way to communicate the transition, especially since it is from audio thread to main thread. |
|
yeah what does it mean to be an 'inactive processing' unit? |
The mistake here is to read the processing state when inactive. |
|
but this exactly is not clear by the documentation. therefore the enhancement of the documentation making it mandatory. CLAP is not VST2. making it super-obvious will clear the confusion and provide a reference point. |
Here's two alternatives. Alternative 1: A call to As a result, there are two paths in the state diagram from Alternative 2:
I know which I prefer, but either Alternative 1 or Alternative 2 should be the spec and in the documentation. The 'leave it ambiguous' or 'leave it implicit' is bad. |
|
@Quant1um please update
Please update About requiring the host to call
That wasn't a requirement before, so there are valid clap host that may not do it; because of that I don't think we can require hosts built against older CLAP version to implement it. The only thing you could do is to require host built using CLAP > 1.x to honor this behavior, and plugins would have to check the CLAP version to know which behavior to expect from the host??? I can't see that as a good solution, and it seems to me that it is simpler as a plugin to check in As a reminder, both If you really really really want to enforce In regards to host validation, I think it is fine to report a missing call to EDIT: Thanks 👍 |
…ent, add state/concurrency comment
|
@abique Done! Removed the |
|
I am not happy with this. |
|
I personally prefer the In my opinion it's not a big deal (a plugin can track processing state internally and emit a stop_processing on deactivate if needed), but it still should be specified in docs one way or the other. |
Currently,
deactivateis "allowed" to be called without astop_processingcall, which is likely not intentional as most implementations (including clap-helpers) rely on all state transitions being explicit.This PR adds a
!processingrequirement todeactivate, which requires hosts to callstop_processingexplicitly beforedeactivate.#515