[LV2] RFC: Options, a generic interface for plugin configuration

David Robillard d at drobilla.net
Sun Sep 16 10:15:40 PDT 2012


Hello all,

As mentioned before, current svn contains new extension:
"morph" (changeable port types) and "buf-size" (information about block
length and buffer sizes).

I realized these APIs had many things in common, and other problems
would also be solved by using a more general interface for this sort of
thing.  So, I have added this to the options extension, and neither
morph nor buf-size contain API any more.  The jist of the API is this
(see options.h in svn for details):

typedef enum {
	LV2_OPTIONS_INSTANCE,
	LV2_OPTIONS_RESOURCE,
	LV2_OPTIONS_BLANK,
	LV2_OPTIONS_PORT
} LV2_Options_Context;

typedef struct _LV2_Options_Option {
	LV2_Options_Context context;  /**< Context (type of subject). */
	uint32_t            subject;  /**< Subject. */
	LV2_URID            key;      /**< Key (property). */
	uint32_t            size;     /**< Size of value in bytes. */
	LV2_URID            type;     /**< Type of value (datatype). */
	const void*         value;    /**< Pointer to value (object). */
} LV2_Options_Option;

typedef struct _LV2_Options_Interface {
    /**
       Get the given options.

       Each element of the passed options array MUST have
       type, subject, and key set.  All other fields (size,
       type, value) MUST be initialised to zero, and are set
       to the option value if such an option is found.

       This function is in the "instantiation" LV2 threading
       class, so no other instance functions may be called
       concurrently.

       @return Bitwise OR of LV2_Options_Status values.
    */
    uint32_t (*get)(LV2_Handle          instance,
                    LV2_Options_Option* options);

    /**
       Set the given options.

       This function is in the "instantiation" LV2 threading
       class, so no other instance functions may be called
       concurrently.

       @return Bitwise OR of LV2_Options_Status values.
    */
    uint32_t (*set)(LV2_Handle                instance,
                    const LV2_Options_Option* options);
} LV2_Options_Interface;

The idea is that this interface can be used to set and get options (i.e.
properties) for the plugin instance, ports, or arbitrary resources.
Basic use is simple key/value stuff, though it is possible to convey any
description, so this API should suffice for any kind of plugin
configuration stuff anybody encounters in the future.

It is slightly more cumbersome to use than the old morph_port (which was
much like connect_port), but not much, and is pretty simple.  I am quite
happy with this solution vs. adding special API for every little thing,
since this means plugin and hosts authors can add configuration options
as needed without centralized coordination.

Comments?

-dr

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part
URL: <http://lists.lv2plug.in/pipermail/devel-lv2plug.in/attachments/20120916/fdcd445c/attachment.pgp>


More information about the Devel mailing list