aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorcbdev <cb@cbcdn.com>2019-09-20 17:58:27 +0200
committercbdev <cb@cbcdn.com>2019-09-20 17:58:27 +0200
commite556b1719a8906c14d329eb3c08574428cad0aae (patch)
treeef5c6a782ab772aa162c8aa82cf0fe901d8d06b9
parentfe4a7b538b9b6c53299d883bee258e4d3597be9d (diff)
downloadmidimonster-e556b1719a8906c14d329eb3c08574428cad0aae.tar.gz
midimonster-e556b1719a8906c14d329eb3c08574428cad0aae.tar.bz2
midimonster-e556b1719a8906c14d329eb3c08574428cad0aae.zip
Fix maweb channel ordering
-rw-r--r--backends/maweb.c14
-rw-r--r--backends/maweb.h4
2 files changed, 16 insertions, 2 deletions
diff --git a/backends/maweb.c b/backends/maweb.c
index 450c388..baa516a 100644
--- a/backends/maweb.c
+++ b/backends/maweb.c
@@ -5,6 +5,7 @@
#include <openssl/md5.h>
#endif
+#define DEBUG
#include "libmmbackend.h"
#include "maweb.h"
@@ -235,6 +236,7 @@ static channel* maweb_channel(instance* inst, char* spec){
0
};
char* next_token = NULL;
+ channel* channel_ref = NULL;
size_t n;
if(!strncmp(spec, "page", 4)){
@@ -299,7 +301,9 @@ static channel* maweb_channel(instance* inst, char* spec){
data->channels++;
}
- return mm_channel(inst, maweb_channel_index(data, chan.type, chan.page, chan.index), 1);
+ channel_ref = mm_channel(inst, maweb_channel_index(data, chan.type, chan.page, chan.index), 1);
+ data->channel[maweb_channel_index(data, chan.type, chan.page, chan.index)].chan = channel_ref;
+ return channel_ref;
}
fprintf(stderr, "Failed to parse maweb channel spec %s\n", spec);
@@ -906,6 +910,7 @@ static int maweb_set(instance* inst, size_t num, channel** c, channel_value* v){
fprintf(stderr, "maweb control not yet implemented\n");
return 1;
}
+ DBGPF("maweb command out %s\n", xmit_buffer);
maweb_send_frame(inst, ws_text, (uint8_t*) xmit_buffer, strlen(xmit_buffer));
}
return 0;
@@ -982,7 +987,7 @@ static int maweb_handle(size_t num, managed_fd* fds){
}
static int maweb_start(){
- size_t n, u;
+ size_t n, u, p;
instance** inst = NULL;
maweb_instance_data* data = NULL;
@@ -997,6 +1002,11 @@ static int maweb_start(){
data = (maweb_instance_data*) inst[u]->impl;
qsort(data->channel, data->channels, sizeof(maweb_channel_data), channel_comparator);
+ //re-set channel identifiers
+ for(p = 0; p < data->channels; p++){
+ data->channel[p].chan->ident = p;
+ }
+
if(maweb_connect(inst[u])){
fprintf(stderr, "Failed to open connection to MA Web Remote for instance %s\n", inst[u]->name);
free(inst);
diff --git a/backends/maweb.h b/backends/maweb.h
index b9de68f..14e4755 100644
--- a/backends/maweb.h
+++ b/backends/maweb.h
@@ -72,6 +72,10 @@ typedef struct /*_maweb_channel*/ {
double in;
double out;
+
+ //reverse reference required because the identifiers are not stable
+ //because we sort the backing store...
+ channel* chan;
} maweb_channel_data;
typedef struct /*_maweb_instance_data*/ {