1 /* 2 Copyright 2012-2016 David Robillard <http://drobilla.net> 3 Copyright 2018 Ethan Reker <http://cutthroughrecordings.com> 4 5 Permission to use, copy, modify, and/or distribute this software for any 6 purpose with or without fee is hereby granted, provided that the above 7 copyright notice and this permission notice appear in all copies. 8 9 THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 */ 17 18 /** 19 @defgroup options Options 20 21 Instantiation time options, see <http://lv2plug.in/ns/ext/options> for 22 details. 23 24 @{ 25 */ 26 module dplug.lv2.options; 27 28 version(LV2): 29 30 import core.stdc.stdint; 31 32 import dplug.lv2.urid; 33 import dplug.lv2.lv2; 34 35 enum LV2_OPTIONS_URI = "http://lv2plug.in/ns/ext/options"; ///< http://lv2plug.in/ns/ext/options 36 enum LV2_OPTIONS_PREFIX = LV2_OPTIONS_URI ~ "#"; ///< http://lv2plug.in/ns/ext/options# 37 38 enum LV2_OPTIONS__Option = LV2_OPTIONS_PREFIX ~ "Option"; ///< http://lv2plug.in/ns/ext/options#Option 39 enum LV2_OPTIONS__interface = LV2_OPTIONS_PREFIX ~ "interface"; ///< http://lv2plug.in/ns/ext/options#interface 40 enum LV2_OPTIONS__options = LV2_OPTIONS_PREFIX ~ "options"; ///< http://lv2plug.in/ns/ext/options#options 41 enum LV2_OPTIONS__requiredOption = LV2_OPTIONS_PREFIX ~ "requiredOption"; ///< http://lv2plug.in/ns/ext/options#requiredOption 42 enum LV2_OPTIONS__supportedOption = LV2_OPTIONS_PREFIX ~ "supportedOption"; ///< http://lv2plug.in/ns/ext/options#supportedOption 43 44 /** 45 The context of an Option, which defines the subject it applies to. 46 */ 47 alias LV2_Options_Context = int; 48 enum : int 49 { 50 /** 51 This option applies to the instance itself. The subject must be 52 ignored. 53 */ 54 LV2_OPTIONS_INSTANCE, 55 56 /** 57 This option applies to some named resource. The subject is a URI mapped 58 to an integer (a LV2_URID, like the key) 59 */ 60 LV2_OPTIONS_RESOURCE, 61 62 /** 63 This option applies to some blank node. The subject is a blank node 64 identifier, which is valid only within the current local scope. 65 */ 66 LV2_OPTIONS_BLANK, 67 68 /** 69 This option applies to a port on the instance. The subject is the 70 port's index. 71 */ 72 LV2_OPTIONS_PORT 73 } 74 75 /** 76 An option. 77 78 This is a property with a subject, also known as a triple or statement. 79 80 This struct is useful anywhere a statement needs to be passed where no 81 memory ownership issues are present (since the value is a const pointer). 82 83 Options can be passed to an instance via the feature LV2_OPTIONS__options 84 with data pointed to an array of options terminated by a zeroed option, or 85 accessed/manipulated using LV2_Options_Interface. 86 */ 87 struct LV2_Options_Option 88 { 89 LV2_Options_Context context; /**< Context (type of subject). */ 90 uint32_t subject; /**< Subject. */ 91 LV2_URID key; /**< Key (property). */ 92 uint32_t size; /**< Size of value in bytes. */ 93 LV2_URID type; /**< Type of value (datatype). */ 94 const void* value; /**< Pointer to value (object). */ 95 } 96 97 /** A status code for option functions. */ 98 alias LV2_Options_Status = int; 99 enum : int { 100 LV2_OPTIONS_SUCCESS = 0, /**< Completed successfully. */ 101 LV2_OPTIONS_ERR_UNKNOWN = 1, /**< Unknown error. */ 102 LV2_OPTIONS_ERR_BAD_SUBJECT = 1 << 1, /**< Invalid/unsupported subject. */ 103 LV2_OPTIONS_ERR_BAD_KEY = 1 << 2, /**< Invalid/unsupported key. */ 104 LV2_OPTIONS_ERR_BAD_VALUE = 1 << 3 /**< Invalid/unsupported value. */ 105 } 106 107 /** 108 Interface for dynamically setting options (LV2_OPTIONS__interface). 109 */ 110 struct LV2_Options_Interface 111 { 112 nothrow: 113 @nogc: 114 extern(C): 115 /** 116 Get the given options. 117 118 Each element of the passed options array MUST have type, subject, and 119 key set. All other fields (size, type, value) MUST be initialised to 120 zero, and are set to the option value if such an option is found. 121 122 This function is in the "instantiation" LV2 threading class, so no other 123 instance functions may be called concurrently. 124 125 @return Bitwise OR of LV2_Options_Status values. 126 */ 127 uint32_t function(LV2_Handle instance, 128 LV2_Options_Option* options) get; 129 130 /** 131 Set the given options. 132 133 This function is in the "instantiation" LV2 threading class, so no other 134 instance functions may be called concurrently. 135 136 @return Bitwise OR of LV2_Options_Status values. 137 */ 138 uint32_t function(LV2_Handle instance, const(LV2_Options_Option)* options) set; 139 }