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

Add the ability for plugins to opt-in to asyncronous state calls #310

Open
wants to merge 1 commit into
base: next
Choose a base branch
from
Open
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
19 changes: 16 additions & 3 deletions include/clap/ext/draft/state-context.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
extern "C" {
#endif

static CLAP_CONSTEXPR const char CLAP_EXT_STATE_CONTEXT[] = "clap.state-context.draft/1";
static CLAP_CONSTEXPR const char CLAP_EXT_STATE_CONTEXT[] = "clap.state-context.draft/2";

enum clap_plugin_state_context_type {
// suitable for duplicating a plugin instance
Expand All @@ -43,7 +43,7 @@ typedef struct clap_plugin_state_context {
//
// Note that the result may be loaded by both clap_plugin_state.load() and
// clap_plugin_state_context.load().
// [main-thread]
// [state-thread]
bool(CLAP_ABI *save)(const clap_plugin_t *plugin,
const clap_ostream_t *stream,
uint32_t context_type);
Expand All @@ -53,10 +53,23 @@ typedef struct clap_plugin_state_context {
//
// Note that the state may have been saved by clap_plugin_state.save() or
// clap_plugin_state_context.save() with a different context_type.
// [main-thread]
// [state-thread]
bool(CLAP_ABI *load)(const clap_plugin_t *plugin,
const clap_istream_t *stream,
uint32_t context_type);

// Indicates whether or not the plugin can support having a state-thread
// that is different than the main-thread.
//
// If this returns false, state-thread will always be the same as the
// main-thread.
//
// If this returns true, the state-thread may be a different thread than
// the main-thread.
//
// This must return the same result throughout the lifetime of the plugin.
// [thread-safe]
bool (CLAP_ABI *supports_async_state)(const clap_plugin_t *plugin);
} clap_plugin_state_context_t;

#ifdef __cplusplus
Expand Down
8 changes: 7 additions & 1 deletion include/clap/ext/thread-check.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ extern "C" {

/// @page thread-check
///
/// CLAP defines two symbolic threads:
/// CLAP defines three symbolic threads:
///
/// main-thread:
/// This is the thread in which most of the interaction between the plugin and host happens.
Expand All @@ -32,6 +32,12 @@ extern "C" {
/// including the main-thread as the audio-thread, as long as it can guarantee that only one OS
/// thread is the audio-thread at a time. The audio-thread can be seen as a concurrency guard for
/// all functions marked with [audio-thread].
///
/// state-thread:
/// This thread is used for saving and loading plugin state. For plug-ins that don't support
/// CLAP_EXT_STATE_CONTEXT, as well as plugins that return false from `supports_async_state`,
/// this thread is always the same as the main-thread.
/// For plugins

// This interface is useful to do runtime checks and make
// sure that the functions are called on the correct threads.
Expand Down