From 871bc1568f94ee4026fd64df062572b91d45d462 Mon Sep 17 00:00:00 2001 From: cbdev Date: Sat, 4 Jan 2020 18:39:04 +0100 Subject: Add input_channel call to Lua backend --- midimonster.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'midimonster.h') diff --git a/midimonster.h b/midimonster.h index 5844bb9..c5a6cf5 100644 --- a/midimonster.h +++ b/midimonster.h @@ -7,7 +7,7 @@ /* Core version unless set by the build process */ #ifndef MIDIMONSTER_VERSION - #define MIDIMONSTER_VERSION "v0.3-dist" + #define MIDIMONSTER_VERSION "v0.4-dist" #endif /* Set backend name if unset */ -- cgit v1.2.3 From e08b473d0eeb467ad358ba5314157753b4f37c18 Mon Sep 17 00:00:00 2001 From: cbdev Date: Sun, 5 Jan 2020 23:26:04 +0100 Subject: Implement commandline config override (Fixes #26) --- midimonster.h | 24 ------------------------ 1 file changed, 24 deletions(-) (limited to 'midimonster.h') diff --git a/midimonster.h b/midimonster.h index c5a6cf5..d6f04e7 100644 --- a/midimonster.h +++ b/midimonster.h @@ -189,29 +189,6 @@ typedef struct _backend_instance { char* name; } instance; -/* - * Channel specification glob - */ -typedef struct /*_mm_channel_glob*/ { - size_t offset[2]; - union { - void* impl; - uint64_t u64[2]; - } limits; - uint64_t values; -} channel_glob; - -/* - * (Multi-)Channel specification - */ -typedef struct /*_mm_channel_spec*/ { - char* spec; - uint8_t internal; - size_t channels; - size_t globs; - channel_glob* glob; -} channel_spec; - /* * Instance channel structure * Backends may either manage their own channel registry @@ -283,7 +260,6 @@ MM_API instance* mm_instance_find(char* backend, uint64_t ident); * function. */ MM_API channel* mm_channel(instance* i, uint64_t ident, uint8_t create); -//TODO channel* mm_channel_find() /* * Register (manage = 1) or unregister (manage = 0) a file descriptor -- cgit v1.2.3 From 78b21a9ac3f975f35ec7b61108531e1495eb91c0 Mon Sep 17 00:00:00 2001 From: cbdev Date: Sun, 12 Jan 2020 17:34:14 +0100 Subject: Rework instance creation --- midimonster.h | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) (limited to 'midimonster.h') diff --git a/midimonster.h b/midimonster.h index d6f04e7..bb1eb24 100644 --- a/midimonster.h +++ b/midimonster.h @@ -93,8 +93,9 @@ struct _managed_fd; * Parse backend-global configuration options from the user-supplied * configuration file. Returning a non-zero value fails config parsing. * * mmbackend_instance - * Allocate space for a backend instance. Returning NULL signals an out-of-memory - * condition and terminates the program. + * Allocate the backend-specific data parts of the supplied instance + * structure. Returning non-zero signals an error condition and + * terminates the program. * * mmbackend_configure_instance * Parse instance configuration from the user-supplied configuration * file. Returning a non-zero value fails config parsing. @@ -135,7 +136,7 @@ struct _managed_fd; * Return value is currently ignored. */ typedef int (*mmbackend_handle_event)(struct _backend_instance* inst, size_t channels, struct _backend_channel** c, struct _channel_value* v); -typedef struct _backend_instance* (*mmbackend_create_instance)(); +typedef int (*mmbackend_create_instance)(struct _backend_instance* inst); typedef struct _backend_channel* (*mmbackend_parse_channel)(struct _backend_instance* instance, char* spec, uint8_t flags); typedef void (*mmbackend_free_channel)(struct _backend_channel* c); typedef int (*mmbackend_configure)(char* option, char* value); @@ -222,20 +223,6 @@ typedef struct /*_mm_channel_mapping*/ { */ MM_API 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. - */ -MM_API instance* mm_instance(); - /* * Finds an instance matching the specified backend and identifier. * Since setting an identifier for an instance is optional, -- cgit v1.2.3 From 8c32598449895e506b4d0eab71be0abf219a62da Mon Sep 17 00:00:00 2001 From: cbdev Date: Mon, 13 Jan 2020 22:49:33 +0100 Subject: Hide core-internal structures --- midimonster.h | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'midimonster.h') diff --git a/midimonster.h b/midimonster.h index bb1eb24..2c29956 100644 --- a/midimonster.h +++ b/midimonster.h @@ -202,7 +202,7 @@ typedef struct _backend_channel { } channel; /* - * File descriptor management structure + * File descriptor structure passed for backend handling * Register for the core event loop using mm_manage_fd() */ typedef struct _managed_fd { @@ -211,13 +211,6 @@ typedef struct _managed_fd { void* impl; } managed_fd; -/* Internal channel mapping structure - Core use only */ -typedef struct /*_mm_channel_mapping*/ { - channel* from; - size_t destinations; - channel** to; -} channel_mapping; - /* * Register a new backend. */ -- cgit v1.2.3 From 4ebcda3a1b0d90c44e91a5dfe455ad59fe694cbe Mon Sep 17 00:00:00 2001 From: cbdev Date: Mon, 9 Mar 2020 21:31:54 +0100 Subject: Update README and example config --- midimonster.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'midimonster.h') diff --git a/midimonster.h b/midimonster.h index 2c29956..bad83c7 100644 --- a/midimonster.h +++ b/midimonster.h @@ -7,7 +7,7 @@ /* Core version unless set by the build process */ #ifndef MIDIMONSTER_VERSION - #define MIDIMONSTER_VERSION "v0.4-dist" + #define MIDIMONSTER_VERSION "v0.5-dist" #endif /* Set backend name if unset */ -- cgit v1.2.3 From abb1ffd367f4046d77ac62b0b017b407997bc43b Mon Sep 17 00:00:00 2001 From: cbdev Date: Wed, 11 Mar 2020 21:53:14 +0100 Subject: Add codesmell statistics to CI --- midimonster.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'midimonster.h') diff --git a/midimonster.h b/midimonster.h index bad83c7..dc0e255 100644 --- a/midimonster.h +++ b/midimonster.h @@ -234,10 +234,12 @@ MM_API instance* mm_instance_find(char* backend, uint64_t ident); * matching `ident`, a pointer to it is returned. * 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. + * channel store is possible. When returning pointers from a + * backend-local channel store, the returned pointers must stay + * valid over the lifetime of the instance. * For each channel with a non-NULL `impl` field registered using * this function, the backend will receive a call to its channel_free - * function. + * function (if it exists). */ MM_API channel* mm_channel(instance* i, uint64_t ident, uint8_t create); -- cgit v1.2.3 From 846a49199ba011a00e4814bacac524a6fe9b299a Mon Sep 17 00:00:00 2001 From: cbdev Date: Mon, 16 Mar 2020 22:19:27 +0100 Subject: Hash-index event routing table --- midimonster.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'midimonster.h') diff --git a/midimonster.h b/midimonster.h index dc0e255..61467c1 100644 --- a/midimonster.h +++ b/midimonster.h @@ -247,6 +247,8 @@ MM_API channel* mm_channel(instance* i, uint64_t ident, uint8_t create); * Register (manage = 1) or unregister (manage = 0) a file descriptor * to be selected on. The backend will be notified when the descriptor * becomes ready to read via its registered mmbackend_process_fd call. + * The `impl` argument will be provided within the corresponding + * managed_fd structure upon callback. */ MM_API int mm_manage_fd(int fd, char* backend, int manage, void* impl); -- cgit v1.2.3 From 5cc2ea308632c335f347d7a1002123c7152fd851 Mon Sep 17 00:00:00 2001 From: cbdev Date: Sat, 21 Mar 2020 02:01:43 +0100 Subject: Refactor global channel store --- midimonster.h | 54 ++++++++++++++++++++++++++---------------------------- 1 file changed, 26 insertions(+), 28 deletions(-) (limited to 'midimonster.h') diff --git a/midimonster.h b/midimonster.h index 61467c1..75eb30a 100644 --- a/midimonster.h +++ b/midimonster.h @@ -192,8 +192,8 @@ typedef struct _backend_instance { /* * Instance channel structure - * Backends may either manage their own channel registry - * or use the memory returned by mm_channel() + * Backends may either manage their own channel registry or use the global + * channel store via the mm_channel() API */ typedef struct _backend_channel { instance* instance; @@ -218,25 +218,24 @@ MM_API int mm_backend_register(backend b); /* * Finds an instance matching the specified backend and identifier. - * Since setting an identifier for an instance is optional, - * this may not work depending on the backend. - * Instance identifiers may for example be set in the backends - * mmbackend_start call. + * Since setting an identifier for an instance is optional, this may not work + * depending on the backend. Instance identifiers may for example be set in the + * backends mmbackend_start call. */ MM_API instance* mm_instance_find(char* backend, uint64_t ident); /* - * Provides a pointer to a channel structure, pre-filled with - * the provided instance reference and identifier. - * The `create` parameter is a boolean flag indicating whether - * a channel matching the `ident` parameter should be created if - * none exists. If the instance already registered a channel - * matching `ident`, a pointer to it is returned. - * 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. When returning pointers from a - * backend-local channel store, the returned pointers must stay - * valid over the lifetime of the instance. + * Provides a pointer to a channel structure, pre-filled with the provided + * instance reference and identifier. + * The `create` parameter is a boolean flag indicating whether a channel + * matching the `ident` parameter should be created in the global channel store + * if none exists yet. If the instance already registered a channel matching + * `ident`, a pointer to the existing channel is returned. + * This API is just a convenience function. Creating and managing a + * backend-internal channel store is possible (and encouraged for performance + * reasons). When returning pointers from a backend-local channel store, the + * returned pointers must stay valid over the lifetime of the instance and + * provide valid `instance` members, as they are used for callbacks. * For each channel with a non-NULL `impl` field registered using * this function, the backend will receive a call to its channel_free * function (if it exists). @@ -244,17 +243,16 @@ MM_API instance* mm_instance_find(char* backend, uint64_t ident); MM_API channel* mm_channel(instance* i, uint64_t ident, uint8_t create); /* - * Register (manage = 1) or unregister (manage = 0) a file descriptor - * to be selected on. The backend will be notified when the descriptor - * becomes ready to read via its registered mmbackend_process_fd call. - * The `impl` argument will be provided within the corresponding - * managed_fd structure upon callback. + * Register (manage = 1) or unregister (manage = 0) a file descriptor to be + * selected on. The backend will be notified when the descriptor becomes ready + * to read via its registered mmbackend_process_fd call. The `impl` argument + * will be provided within the corresponding managed_fd structure upon callback. */ MM_API int mm_manage_fd(int fd, char* backend, int manage, void* impl); /* - * Notifies the core of a channel event. Called by backends to - * inject events gathered from their backing implementation. + * Notifies the core of a channel event. Called by backends to inject events + * gathered from their backing implementation. */ MM_API int mm_channel_event(channel* c, channel_value v); @@ -266,14 +264,14 @@ MM_API int mm_backend_instances(char* backend, size_t* n, instance*** i); /* * Query an internal timestamp, which is updated every core iteration. - * This timestamp should not be used as a performance counter, but can be - * used for timeouting. Resolution is milliseconds. + * This timestamp should not be used as a performance counter, but can be used + * for timeouting. Resolution is milliseconds. */ MM_API uint64_t mm_timestamp(); /* - * Create a channel-to-channel mapping. This API should not - * be used by backends. It is only exported for core modules. + * Create a channel-to-channel mapping. This API should not be used by backends. + * It is only exported for core modules. */ int mm_map_channel(channel* from, channel* to); #endif -- cgit v1.2.3