From 1cbf63996a51a67bdd221257d74adec61f03ea32 Mon Sep 17 00:00:00 2001 From: cbdev Date: Tue, 6 Jun 2017 00:08:06 +0200 Subject: Implement MIDI backend event fetching --- midimonster.h | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'midimonster.h') diff --git a/midimonster.h b/midimonster.h index d548528..bd42d8f 100644 --- a/midimonster.h +++ b/midimonster.h @@ -10,21 +10,24 @@ struct _channel_value; struct _backend_channel; struct _backend_instance; +struct _managed_fd; -typedef int (*mmbackend_handle_event)(size_t channels, struct _backend_channel* c, struct _channel_value* v); +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 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); +typedef int (*mmbackend_process_fd)(size_t nfds, struct _managed_fd* fds); typedef int (*mmbackend_start)(); -typedef uint32_t (*mmbackend_max_interval)(); +typedef uint32_t (*mmbackend_interval)(); typedef int (*mmbackend_shutdown)(); typedef struct _channel_value { - double raw_double; - uint64_t raw_u64; + union { + double dbl; + uint64_t u64; + } raw; double normalised; } channel_value; @@ -39,11 +42,12 @@ typedef struct /*_mm_backend*/ { mmbackend_start start; mmbackend_shutdown shutdown; mmbackend_free_channel channel_free; + mmbackend_interval interval; } backend; typedef struct _backend_instance { backend* backend; - uint64_t ident; /*FIXME needed? identification provided by name*/ + uint64_t ident; void* impl; char* name; } instance; @@ -56,7 +60,7 @@ typedef struct _backend_channel { //FIXME might be replaced by struct pollfd //FIXME who frees impl -typedef struct /*_mm_managed_fd*/ { +typedef struct _managed_fd { int fd; backend* backend; void* impl; @@ -86,6 +90,14 @@ int mm_backend_register(backend b); * all instances for the backend. */ instance* mm_instance(); +/* + * 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. + */ +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. @@ -109,6 +121,7 @@ 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. + * *i will need to be freed by the caller. */ int mm_backend_instances(char* backend, size_t* n, instance*** i); int mm_map_channel(channel* from, channel* to); -- cgit v1.2.3