aboutsummaryrefslogtreecommitdiffstats
path: root/lv2/state/state.h
diff options
context:
space:
mode:
Diffstat (limited to 'lv2/state/state.h')
-rw-r--r--lv2/state/state.h46
1 files changed, 36 insertions, 10 deletions
diff --git a/lv2/state/state.h b/lv2/state/state.h
index ffc40d1..cea4037 100644
--- a/lv2/state/state.h
+++ b/lv2/state/state.h
@@ -17,6 +17,7 @@
/**
@defgroup state State
+ @ingroup lv2
An interface for LV2 plugins to save and restore state, see
<http://lv2plug.in/ns/ext/state> for details.
@@ -27,17 +28,19 @@
#ifndef LV2_STATE_H
#define LV2_STATE_H
+#include "lv2/core/lv2.h"
+
+#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
-#include "lv2/core/lv2.h"
-
#define LV2_STATE_URI "http://lv2plug.in/ns/ext/state" ///< http://lv2plug.in/ns/ext/state
#define LV2_STATE_PREFIX LV2_STATE_URI "#" ///< http://lv2plug.in/ns/ext/state#
#define LV2_STATE__State LV2_STATE_PREFIX "State" ///< http://lv2plug.in/ns/ext/state#State
#define LV2_STATE__interface LV2_STATE_PREFIX "interface" ///< http://lv2plug.in/ns/ext/state#interface
#define LV2_STATE__loadDefaultState LV2_STATE_PREFIX "loadDefaultState" ///< http://lv2plug.in/ns/ext/state#loadDefaultState
+#define LV2_STATE__freePath LV2_STATE_PREFIX "freePath" ///< http://lv2plug.in/ns/ext/state#freePath
#define LV2_STATE__makePath LV2_STATE_PREFIX "makePath" ///< http://lv2plug.in/ns/ext/state#makePath
#define LV2_STATE__mapPath LV2_STATE_PREFIX "mapPath" ///< http://lv2plug.in/ns/ext/state#mapPath
#define LV2_STATE__state LV2_STATE_PREFIX "state" ///< http://lv2plug.in/ns/ext/state#state
@@ -46,11 +49,10 @@
#ifdef __cplusplus
extern "C" {
-#else
-# include <stdbool.h>
#endif
typedef void* LV2_State_Handle; ///< Opaque handle for state save/restore
+typedef void* LV2_State_Free_Path_Handle; ///< Opaque handle for state:freePath feature
typedef void* LV2_State_Map_Path_Handle; ///< Opaque handle for state:mapPath feature
typedef void* LV2_State_Make_Path_Handle; ///< Opaque handle for state:makePath feature
@@ -193,7 +195,7 @@ typedef const void* (*LV2_State_Retrieve_Function)(
authors should consider this possibility, and always store sensible data
with meaningful types to avoid such problems in the future.
*/
-typedef struct _LV2_State_Interface {
+typedef struct {
/**
Save plugin state using a host-provided `store` callback.
@@ -293,8 +295,8 @@ typedef struct {
not necessarily the same original path) using absolute_path().
This function may only be called within the context of
- LV2_State_Interface methods. The caller is responsible for freeing the
- returned value with free().
+ LV2_State_Interface methods. The caller must free the returned value
+ with LV2_State_Free_Path.free_path().
*/
char* (*abstract_path)(LV2_State_Map_Path_Handle handle,
const char* absolute_path);
@@ -309,8 +311,8 @@ typedef struct {
use any paths loaded from plugin state.
This function may only be called within the context of
- LV2_State_Interface methods. The caller is responsible for freeing the
- returned value with free().
+ LV2_State_Interface methods. The caller must free the returned value
+ with LV2_State_Free_Path.free_path().
*/
char* (*absolute_path)(LV2_State_Map_Path_Handle handle,
const char* abstract_path);
@@ -346,12 +348,36 @@ typedef struct {
LV2_State_Interface.save(), it may only be called within the dynamic
scope of that function call.
- The caller is responsible for freeing the returned value with free().
+ The caller must free the returned value with
+ LV2_State_Free_Path.free_path().
*/
char* (*path)(LV2_State_Make_Path_Handle handle,
const char* path);
} LV2_State_Make_Path;
+/**
+ Feature data for state:freePath (@ref LV2_STATE__freePath).
+*/
+typedef struct {
+ /**
+ Opaque host data.
+ */
+ LV2_State_Free_Path_Handle handle;
+
+ /**
+ Free a path returned by a state feature.
+
+ @param handle MUST be the `handle` member of this struct.
+ @param path The path previously returned by a state feature.
+
+ This function can be used by plugins to free paths allocated by the host
+ and returned by state features (LV2_State_Map_Path.abstract_path(),
+ LV2_State_Map_Path.absolute_path(), and LV2_State_Make_Path.path()).
+ */
+ void (*free_path)(LV2_State_Free_Path_Handle handle,
+ char* path);
+} LV2_State_Free_Path;
+
#ifdef __cplusplus
} /* extern "C" */
#endif