-
Clarification of ->flush() I have some questiongs regarding the specification of flush(), # "plugin.h"
// Call start processing before processing.
// [audio-thread & active_state & !processing_state]
bool (*start_processing)(const struct clap_plugin *plugin);
// Call stop processing before sending the plugin to sleep.
// [audio-thread & active_state & processing_state]
void (*stop_processing)(const struct clap_plugin *plugin); # "params.h"
// Flushes a set of parameter changes.
// This method must not be called concurrently to clap_plugin->process().
// This method must not be used if the plugin is processing.
//
// [active && !processing : audio-thread]
// [!active : main-thread]
void (*flush)(const clap_plugin_t *plugin,
const clap_input_events_t *in,
const clap_output_events_t *out);
[...];
// Request the host to call clap_plugin_params->fush().
// This is useful if the plugin has parameters value changes to report to the host but the plugin
// is not processing.
//
// eg. the plugin has a USB socket to some hardware controllers and receives a parameter change
// while it is not processing.
//
// This must not be called on the [audio-thread].
//
// [thread-safe]
void (*request_flush)(const clap_host_t *host); The questions: A) Is B) Is C) Shouldn't there be a way to flush parameters from the main thread, after D) Once
E) AFAICS for I'd particularly like to see input from @abique on these questions, sorry if they sound a bit redundant. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 4 replies
-
I'm also having trouble working this all out. Here a copy of my post in Surge's Discord, How exactly are you meant to report parameter changes from your plugin's UI to the host? |
Beta Was this translation helpful? Give feedback.
-
a) Yes. |
Beta Was this translation helpful? Give feedback.
-
Clap 1.0.3 addresses some of the issues mentioned in this discussion, but not the request_flush one. Here's a comment addressing 1.0.3: // This function is always safe to use and must not be called on the [audio-thread].
// [thread-safe,!audio-thread]
void (*request_flush)(const clap_host_t *host); When it's thread-safe, it should be callable from any and all threads. Can we just say the plugin may call this at any time and from any thread? |
Beta Was this translation helpful? Give feedback.
-
I'd like to close this (mark as answered) but the reply from @signaldust cannot be marked as such. // Request a parameter flush. Note that this is not useful to call from an
// [audio-thread], because a plugin executing within any [audio-thread] is either:
// 1. within process() (which may include clap_plugin_thread_pool->exec)
// 2. within flush()
//
// The host will then schedule a call to either:
// - clap_plugin.process()
// - clap_plugin_params->flush()
//
// This function is always safe to use and must not be called on the [audio-thread].
// [thread-safe,!audio-thread]
void (*request_flush)(const clap_host_t *host); |
Beta Was this translation helpful? Give feedback.
I'd like to close this (mark as answered) but the reply from @signaldust cannot be marked as such.
So here is the relevant snippet from #131 that should clear things up: