aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorcbdev <cb@cbcdn.com>2019-03-16 15:32:52 +0100
committercbdev <cb@cbcdn.com>2019-03-16 15:32:52 +0100
commit34a194cc101d7c77202b79a06e285573541d823f (patch)
treefce7f64732a558946e1c518ac1ad43c0bbe03673
parent90a99a3c095aa634e8768914e34d2cb84586615f (diff)
downloadmidimonster-34a194cc101d7c77202b79a06e285573541d823f.tar.gz
midimonster-34a194cc101d7c77202b79a06e285573541d823f.tar.bz2
midimonster-34a194cc101d7c77202b79a06e285573541d823f.zip
Only start backends with active instances
-rw-r--r--backend.c10
-rw-r--r--midimonster.h9
2 files changed, 15 insertions, 4 deletions
diff --git a/backend.c b/backend.c
index e9b12df..ed5e6db 100644
--- a/backend.c
+++ b/backend.c
@@ -251,8 +251,16 @@ int mm_backend_register(backend b){
int backends_start(){
int rv = 0, current;
- size_t u;
+ size_t u, p;
for(u = 0; u < nbackends; u++){
+ //only start backends that have instances
+ for(p = 0; p < ninstances && instances[p]->backend != backends + u; p++){
+ }
+ if(p == ninstances){
+ fprintf(stderr, "Skipping start of backend %s\n", backends[u].name);
+ continue;
+ }
+
current = backends[u].start();
if(current){
fprintf(stderr, "Failed to start backend %s\n", backends[u].name);
diff --git a/midimonster.h b/midimonster.h
index 98d8459..a3e5e1f 100644
--- a/midimonster.h
+++ b/midimonster.h
@@ -29,7 +29,7 @@ struct _managed_fd;
* * int init()
* The only function that should be exported by the shared object.
* Called when the shared object is attached. Should register
- * a backend structure with the core.
+ * a backend structure containing callable entry points with the core.
* Returning anything other than zero causes midimonster to fail the
* startup checks.
* * mmbackend_configure
@@ -46,7 +46,8 @@ struct _managed_fd;
* out-of-memory condition and terminates the program.
* * mmbackend_start
* Called after all instances have been created and all mappings
- * have been set up. May be used to connect to backing hardware
+ * have been set up. Only backends for which instances have been configured
+ * receive the start call. May be used to connect to backing hardware
* or to update runtime-specific data in the various data structures.
* Returning a non-zero value signals an error starting the backend
* and stops further progress.
@@ -68,7 +69,9 @@ struct _managed_fd;
* Return the maximum sleep interval for this backend in milliseconds.
* If not implemented, a maximum interval of one second is used.
* * mmbackend_shutdown
- * Clean up all allocations, finalize all hardware connections.
+ * Clean up all allocations, finalize all hardware connections. All registered
+ * backends receive the shutdown call, regardless of whether they have been
+ * started previously.
* 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);