[LAU] Editing zynadsuxfx/yoshimi patches?

Lieven Moors lievenmoors at gmail.com
Tue May 3 20:07:49 UTC 2011


On Tue, May 03, 2011 at 04:38:48AM +1000, cal wrote:
> On 03/05/11 00:45, Julien Claassen wrote:
> >[ ... ]
> >Only slight problem there is, that one has to write the documentation oneself and I
> > believe, that the other commands have to have some kind of server/responder developer
> > involvement as well. But let's start small.
> 
> I've been looking at this aspect in yoshimi.  Small is good for now.
> 
> cheers.

Yes that is a problem. I wrote a simple patch for oscsend
that starts a server, and prints out the reply it gets.
I've tested this with ardour and dssi plugins, and they don't
seem to respond to any of the possible queries like #type-signature
or #documentation. It would be nice to have at least one program
patched, (or make a program that does nothing, but responds to
everything descently), so we have a test case...

greetings,

lieven

P.S. This patch does not filter messages yet, because I first
wanted to see what applications are responding to.
It seems that the applications I tested don't even reply 
#error messages, when a query cannot be replied to.
So that's probably all up to de developers...



diff --git a/src/tools/oscsend.c b/src/tools/oscsend.c
index 61ee1ee..66f3a5c 100644
--- a/src/tools/oscsend.c
+++ b/src/tools/oscsend.c
@@ -231,6 +231,26 @@ lo_message create_message(char **argv)
     return NULL;
 }
 
+void error_handler(int num, const char *msg, const char *where)
+{
+    fprintf(stderr, "errno:%i\nmsg:%s\nwhere:%s\n", num, msg, where);
+}
+
+int query_print_reply(const char *path, const char *types, lo_arg **argv, int argc, lo_message msg, void *user_data)
+{
+    fprintf(stdout, "path: %s\n", path);
+    fprintf(stdout, "types: %s\n", types);
+    fprintf(stdout, "argv[0]: ");
+    lo_arg_pp(types[0], argv[0]);
+    fprintf(stdout, "\n");
+    fprintf(stdout, "argv[1]-argv[argc]: ");
+    unsigned int i;
+    for(i = 1; i < argc; i++){
+        lo_arg_pp(types[i], argv[i]);
+    }
+    fprintf(stdout, "\n");
+}
+
 int main(int argc, char **argv)
 {
     lo_address target;
@@ -251,14 +271,21 @@ int main(int argc, char **argv)
         exit(1);
     }
 
-    target = lo_address_new(argv[1], argv[2]);
-    if (target == NULL) {
-        fprintf(stderr, "Failed to open %s:%s\n", argv[1], argv[2]);
+    if (argv[3] == NULL) {
+        fprintf(stderr, "No path is given.\n");
         exit(1);
     }
 
-    if (argv[3] == NULL) {
-        fprintf(stderr, "No path is given.\n");
+    lo_server_thread server_thread  = lo_server_thread_new(NULL, error_handler);
+    lo_method method = lo_server_thread_add_method(server_thread, NULL, NULL, query_print_reply, NULL);
+    lo_server server = lo_server_thread_get_server(server_thread);
+
+    if(lo_server_thread_start(server_thread) != 0)
+        fprintf(stderr, "Could not start server thread.");
+
+    target = lo_address_new(argv[1], argv[2]);
+    if (target == NULL) {
+        fprintf(stderr, "Failed to open %s:%s\n", argv[1], argv[2]);
         exit(1);
     }
 
@@ -277,5 +304,9 @@ int main(int argc, char **argv)
         exit(1);
     }
 
+    if(lo_server_wait(server, 20)){
+        lo_server_recv(server);
+    }
+
     return 0;
 }



More information about the Linux-audio-user mailing list