diff options
author | cbdev <cb@cbcdn.com> | 2017-06-04 22:49:27 +0200 |
---|---|---|
committer | cbdev <cb@cbcdn.com> | 2017-06-04 22:49:27 +0200 |
commit | c47b0765a8605b9afcc6205a6d2396ccbe3d5e05 (patch) | |
tree | 6cea50c068b08f67039649ef0f76ad9df68b3d85 /midimonster.h | |
parent | 11e9dec049e64989c5f3656415d00c6c69851e8e (diff) | |
download | midimonster-c47b0765a8605b9afcc6205a6d2396ccbe3d5e05.tar.gz midimonster-c47b0765a8605b9afcc6205a6d2396ccbe3d5e05.tar.bz2 midimonster-c47b0765a8605b9afcc6205a6d2396ccbe3d5e05.zip |
Implement channel mapping
Diffstat (limited to 'midimonster.h')
-rw-r--r-- | midimonster.h | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/midimonster.h b/midimonster.h index 9026222..b2af7a3 100644 --- a/midimonster.h +++ b/midimonster.h @@ -13,6 +13,7 @@ struct _backend_instance; typedef int (*mmbackend_handle_event)(size_t channels, struct _backend_channel* c, struct _channel_value* v); typedef struct _backend_instance* (*mmbackend_create_instance)(); typedef struct _backend_channel* (*mmbackend_parse_channel)(struct _backend_instance* instance, char* spec); +typedef void (*mmbackend_free_channel)(struct _backend_channel* c); typedef int (*mmbackend_configure)(char* option, char* value); typedef int (*mmbackend_configure_instance)(struct _backend_instance* instance, char* option, char* value); typedef int (*mmbackend_process_fd)(size_t fds, int* fd, void** impl); @@ -36,6 +37,7 @@ typedef struct /*_mm_backend*/ { mmbackend_process_fd process; mmbackend_start start; mmbackend_shutdown shutdown; + mmbackend_free_channel channel_free; } backend; typedef struct _backend_instance { @@ -58,9 +60,48 @@ typedef struct /*_mm_managed_fd*/ { void* impl; } managed_fd; +typedef struct /*_mm_channel_mapping*/ { + channel* from; + size_t destinations; + channel** to; +} channel_mapping; + +/* + * Register a new backend. + */ int mm_backend_register(backend b); + +/* + * Provides a pointer to a newly (zero-)allocated instance. + * All instance pointers need to be allocated via this API + * in order to be assignable from the configuration parser. + * This API should be called from the mmbackend_create_instance + * call of your backend. + * + * Instances returned from this call are freed by midimonster. + * The contents of the impl members should be freed in the + * mmbackend_shutdown procedure of the backend, eg. by querying + * all instances for the backend. + */ instance* mm_instance(); +/* + * Provides a pointer to a channel structure, pre-filled with + * the provided instance reference and identifier. + * Will return previous allocations if the provided fields + * match. + * This API is just a convenience function. The array + * of channels is only used for mapping internally, + * creating and managing your own channel store is + * possible. + * For each channel with a non-NULL impl field, the backend + * will receive a call to its channel_free function. + */ +channel* mm_channel(instance* i, uint64_t ident); int mm_manage_fd(int fd, char* backend, int manage, void* impl); int mm_channel_event(channel* c, channel_value v); +/* + * Query all active instances for a given backend. + */ int mm_backend_instances(char* backend, size_t* n, instance*** i); +int mm_map_channel(channel* from, channel* to); #endif |