commit a7c60237c6d294ab56dba7ebf09ed71d1f61e3bb
parent f488b030a131d611b1914a7142ee55cdf0fc1aed
Author: Alexandre Bique <bique.alexandre@gmail.com>
Date: Mon, 11 Jul 2022 15:10:50 +0200
Change the state context extension so it only provide a load method
Diffstat:
1 file changed, 9 insertions(+), 25 deletions(-)
diff --git a/include/clap/ext/draft/state-context.h b/include/clap/ext/draft/state-context.h
@@ -6,23 +6,10 @@
/// @page state-context extension
/// @brief extended state handling
///
-/// This extension let the host specify how the plugin state should be saved or loaded
-/// by setting a context prior to the save or load operation.
+/// This extension let the host specify how the plugin state should be loaded.
///
-/// If unspecified, then the context is `CLAP_STATE_CONTEXT_FULL`.
-///
-/// Save and Load operations may have a different context.
-/// Only the following sequences are specified:
-///
-/// | save ctx | load ctx | result |
-/// +------------+------------+-----------+
-/// | full | full | full |
-/// | full | preset | preset |
-/// | full | duplicate | duplicate |
-/// | duplicate | duplicate | duplicate |
-/// | duplicate | full | duplicate |
-/// | preset | full | preset |
-/// | preset | preset | preset |
+/// Briefly, when loading a preset or duplicating a device, the plugin may want to partially load
+/// the state and initialize certain things differently.
#ifdef __cplusplus
extern "C" {
@@ -31,21 +18,18 @@ extern "C" {
static CLAP_CONSTEXPR const char CLAP_EXT_STATE_CONTEXT[] = "clap.state-context.draft/1";
enum clap_plugin_state_context_type {
- // saves and loads *everything*
- CLAP_STATE_CONTEXT_FULL = 1,
-
// suitable for duplicating a plugin instance
- CLAP_STATE_CONTEXT_FOR_DUPLICATE = 2,
+ CLAP_STATE_CONTEXT_FOR_DUPLICATE = 1,
- // suitable for saving and loading a preset state
- CLAP_STATE_CONTEXT_FOR_PRESET = 3,
+ // suitable for loading a state as a preset
+ CLAP_STATE_CONTEXT_FOR_PRESET = 2,
};
typedef struct clap_plugin_state_context {
- // Assign the context for subsequent calls to clap_plugin_state->save() or
- // clap_plugin_state->load() of the clap_plugin_state extension.
+ // Loads the plugin state from stream.
+ // Returns true if the state was correctly restored.
// [main-thread]
- void (*set)(const clap_plugin_t *plugin, uint32_t context_type);
+ void (*load)(const clap_plugin_t *plugin, const clap_istream_t *stream, uint32_t context_type);
} clap_plugin_state_context_t;
#ifdef __cplusplus