[linux-audio-dev] [PATCH] liblo & pattern matching callback

Martin Habets errandir_news at mph.eclipse.co.uk
Sat Mar 26 12:43:45 UTC 2005


Hi Steve,

Was testing this scenario today, which may look familiar to you:

- I created a server with some methods: '/ping/documentation' and
'/osc-schema/documentation', both of which use the same handler 'doc'.
- I send query '/*/documentation' to the server.
- 'doc' got called twice with path '/*/documentation'.

The unexpanded path makes it impossible for the handler to determine
what container was intended. In my interpretation the OSC spec is not
completely explicit on this point, but I think the intention was to
send the expanded path to the handler. The spec is specific in stating
that '*' is invalid in an OSC method, and it talks about the "OSC Address
of a OSC Method".

Initially I hacked liblo to always send the expanded path. However, the
result was also that the generic method handler (oh, I used that too :)
got called with a NULL path. Since that is useless to that handler it
seems best to me to use the unexpanded path for this case.

The resulting patch is applied. Please let me know your view on this.

Cheers,
-- 
Martin
---------------------------------------------------------------------------

Index: liblo/src/server.c
===================================================================
--- liblo.orig/src/server.c	2005-03-02 19:15:47.000000000 +0000
+++ liblo/src/server.c	2005-03-26 11:33:41.000000000 +0000
@@ -463,6 +463,7 @@
     lo_address src = lo_address_new(NULL, NULL);
     char hostname[LO_HOST_SIZE];
     char portname[32];
+    const char *pptr;
 
     free(msg->types);
     msg->types = types;
@@ -542,7 +543,13 @@
 		    }
 		}
 
-		ret = it->handler(path, types, argv, argc, msg,
+		/* Send wildcard path to generic handler, expanded path
+		   to others.
+		 */
+		pptr = path;
+		if (it->path) pptr = it->path;
+
+		ret = it->handler(pptr, types, argv, argc, msg,
 				      it->user_data);
 
 	    } else if (lo_can_coerce_spec(types, it->typespec)) {
@@ -572,7 +579,13 @@
 		}
 		endian_fixed = 1;
 
-		ret = it->handler(path, it->typespec, argv, argc, msg,
+		/* Send wildcard path to generic handler, expanded path
+		   to others.
+		 */
+		pptr = path;
+		if (it->path) pptr = it->path;
+
+		ret = it->handler(pptr, it->typespec, argv, argc, msg,
 				      it->user_data);
 		free(argv);
 		free(data_co);



More information about the Linux-audio-dev mailing list