From 3eada28582b144519e95a44ee3adc3f46d39036e Mon Sep 17 00:00:00 2001 From: cbdev Date: Thu, 5 Dec 2019 21:05:14 +0100 Subject: Add flags parameter to channel parser plugin API (Fixes #31) --- midimonster.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'midimonster.h') diff --git a/midimonster.h b/midimonster.h index 1192d6a..5ce0c73 100644 --- a/midimonster.h +++ b/midimonster.h @@ -87,8 +87,11 @@ struct _managed_fd; * Parse instance configuration from the user-supplied configuration * file. Returning a non-zero value fails config parsing. * * mmbackend_channel - * Parse a channel-spec to be mapped to/from. Returning NULL signals an - * out-of-memory condition and terminates the program. + * Parse a channel-spec to be mapped to/from. The `falgs` parameter supplies + * additional information to the parser, such as whether the channel is being + * queried for use as input (to the MIDIMonster core) and/or output + * (from the MIDIMonster core) channel (on a per-query basis). + * Returning NULL signals an out-of-memory condition and terminates the program. * * mmbackend_start * Called after all instances have been created and all mappings * have been set up. Only backends for which instances have been configured @@ -121,7 +124,7 @@ struct _managed_fd; */ 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 struct _backend_channel* (*mmbackend_parse_channel)(struct _backend_instance* instance, char* spec); +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); typedef int (*mmbackend_configure_instance)(struct _backend_instance* instance, char* option, char* value); @@ -130,6 +133,12 @@ typedef int (*mmbackend_start)(); typedef uint32_t (*mmbackend_interval)(); typedef int (*mmbackend_shutdown)(); +/* Bit masks for the `flags` parameter to mmbackend_parse_channel */ +typedef enum { + mmchannel_input = 0x1, + mmchannel_output = 0x2 +} mmbe_channel_flags; + /* Channel event value, .normalised is used by backends to determine channel values */ typedef struct _channel_value { union { -- cgit v1.2.3 From e517dbe783e65fdd1c80f5c917f8f924e2adfe8d Mon Sep 17 00:00:00 2001 From: cbdev Date: Tue, 10 Dec 2019 23:28:02 +0100 Subject: Implement rudimentary argument parsing --- midimonster.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'midimonster.h') diff --git a/midimonster.h b/midimonster.h index 5ce0c73..677eeee 100644 --- a/midimonster.h +++ b/midimonster.h @@ -5,6 +5,11 @@ #include #include +/* Core version unless set by the build process */ +#ifndef MIDIMONSTER_VERSION + #define MIDIMONSTER_VERSION "v0.3-dist" +#endif + /* API call attributes and visibilities */ #ifndef MM_API #ifdef _WIN32 -- cgit v1.2.3 From f65fb8baaba285f5ff4b02af111420ba4479f5d9 Mon Sep 17 00:00:00 2001 From: cbdev Date: Wed, 11 Dec 2019 23:02:22 +0100 Subject: Simplify plugin_start API --- midimonster.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'midimonster.h') diff --git a/midimonster.h b/midimonster.h index 677eeee..bf30e8c 100644 --- a/midimonster.h +++ b/midimonster.h @@ -134,7 +134,7 @@ 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 nfds, struct _managed_fd* fds); -typedef int (*mmbackend_start)(); +typedef int (*mmbackend_start)(size_t ninstances, struct _backend_instance** inst); typedef uint32_t (*mmbackend_interval)(); typedef int (*mmbackend_shutdown)(); -- cgit v1.2.3 From f6d6eefe9bb9934f4fa3e665734d746f02471cdb Mon Sep 17 00:00:00 2001 From: cbdev Date: Wed, 11 Dec 2019 23:20:34 +0100 Subject: Simplify plugin_stop API --- midimonster.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'midimonster.h') diff --git a/midimonster.h b/midimonster.h index bf30e8c..1f5c936 100644 --- a/midimonster.h +++ b/midimonster.h @@ -136,7 +136,7 @@ typedef int (*mmbackend_configure_instance)(struct _backend_instance* instance, typedef int (*mmbackend_process_fd)(size_t nfds, struct _managed_fd* fds); typedef int (*mmbackend_start)(size_t ninstances, struct _backend_instance** inst); typedef uint32_t (*mmbackend_interval)(); -typedef int (*mmbackend_shutdown)(); +typedef int (*mmbackend_shutdown)(size_t ninstances, struct _backend_instance** inst); /* Bit masks for the `flags` parameter to mmbackend_parse_channel */ typedef enum { -- cgit v1.2.3 From 4b063b0017ff262e3d6757062a297082a808a3e2 Mon Sep 17 00:00:00 2001 From: cbdev Date: Sat, 14 Dec 2019 23:49:40 +0100 Subject: Fix minor bug in plugin path setup --- midimonster.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'midimonster.h') diff --git a/midimonster.h b/midimonster.h index 1f5c936..eb19409 100644 --- a/midimonster.h +++ b/midimonster.h @@ -92,7 +92,7 @@ struct _managed_fd; * Parse instance configuration from the user-supplied configuration * file. Returning a non-zero value fails config parsing. * * mmbackend_channel - * Parse a channel-spec to be mapped to/from. The `falgs` parameter supplies + * Parse a channel-spec to be mapped to/from. The `flags` parameter supplies * additional information to the parser, such as whether the channel is being * queried for use as input (to the MIDIMonster core) and/or output * (from the MIDIMonster core) channel (on a per-query basis). -- cgit v1.2.3 From 062c93b1f718730c71bc4d2a1e53e0107dd236ad Mon Sep 17 00:00:00 2001 From: cbdev Date: Fri, 20 Dec 2019 21:29:18 +0100 Subject: Route all backend debug logging through a macro --- midimonster.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'midimonster.h') diff --git a/midimonster.h b/midimonster.h index eb19409..5844bb9 100644 --- a/midimonster.h +++ b/midimonster.h @@ -10,6 +10,11 @@ #define MIDIMONSTER_VERSION "v0.3-dist" #endif +/* Set backend name if unset */ +#ifndef BACKEND_NAME + #define BACKEND_NAME "unspec" +#endif + /* API call attributes and visibilities */ #ifndef MM_API #ifdef _WIN32 @@ -37,13 +42,15 @@ /* Debug messages only compile in when DEBUG is set */ #ifdef DEBUG - #define DBGPF(format, ...) fprintf(stderr, (format), __VA_ARGS__) - #define DBG(message) fprintf(stderr, "%s", (message)) + #define DBGPF(format, ...) fprintf(stderr, "debug/%s\t" format "\n", (BACKEND_NAME), __VA_ARGS__) #else #define DBGPF(format, ...) - #define DBG(message) #endif +/* Log messages should be routed through these macros to ensure interoperability with different core implementations */ +#define LOGPF(format, ...) fprintf(stderr, "%s\t" format "\n", (BACKEND_NAME), __VA_ARGS__) +#define LOG(message) fprintf(stderr, "%s\t%s\n", (BACKEND_NAME), (message)) + /* Stop compilation if the build system reports an error */ #ifdef BUILD_ERROR #error The build system reported an error, compilation stopped. Refer to the invocation for this compilation unit for more information. -- cgit v1.2.3