summaryrefslogtreecommitdiff
path: root/guile-osc.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2023-04-16 15:51:54 +0200
committerThomas White <taw@physics.org>2023-04-16 15:52:17 +0200
commit6ad376342fd56fcac702956e7046e6dc5adbd5ad (patch)
treef69ee5de787fa39353c5ef45a9b865f10f68efa2 /guile-osc.c
parenta4757aef677eac2e991db7e72fecc14a68bb1770 (diff)
Add initial (osc-send ...)
Diffstat (limited to 'guile-osc.c')
-rw-r--r--guile-osc.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/guile-osc.c b/guile-osc.c
index 5e69738..7c09637 100644
--- a/guile-osc.c
+++ b/guile-osc.c
@@ -28,6 +28,7 @@
static SCM osc_server_thread_type;
static SCM osc_method_type;
+static SCM osc_address_type;
static void error_callback(int num, const char *msg, const char *path)
@@ -54,6 +55,24 @@ static void finalize_osc_server_thread(SCM obj)
}
+static SCM make_osc_address(SCM port_obj)
+{
+ lo_address addr;
+ const char *port = scm_to_utf8_stringn(port_obj, NULL);
+ addr = lo_address_new(NULL, port);
+ return scm_make_foreign_object_1(osc_address_type, addr);
+}
+
+
+static void finalize_osc_address(SCM addr_obj)
+{
+ lo_address addr;
+ scm_assert_foreign_object_type(osc_address_type, addr_obj);
+ addr = scm_foreign_object_ref(addr_obj, 0);
+ lo_address_free(addr);
+}
+
+
struct method_callback_data
{
SCM proc;
@@ -123,6 +142,20 @@ static SCM add_osc_method(SCM server_obj, SCM path_obj, SCM proc)
}
+static SCM osc_send(SCM addr_obj, SCM path_obj, SCM rest)
+{
+ lo_address addr;
+ char *path;
+
+ scm_assert_foreign_object_type(osc_address_type, addr_obj);
+ addr = scm_foreign_object_ref(addr_obj, 0);
+ path = scm_to_utf8_stringn(path_obj, NULL);
+ lo_send(addr, path, "");
+
+ return SCM_UNSPECIFIED;
+}
+
+
void init_guile_osc()
{
SCM name, slots;
@@ -137,8 +170,14 @@ void init_guile_osc()
slots = scm_list_1(scm_from_utf8_symbol("data"));
osc_method_type = scm_make_foreign_object_type(name, slots, NULL);
+ name = scm_from_utf8_symbol("OSCAddress");
+ slots = scm_list_1(scm_from_utf8_symbol("data"));
+ osc_address_type = scm_make_foreign_object_type(name, slots, finalize_osc_address);
+
scm_c_define_gsubr("make-osc-server-thread", 1, 0, 0, make_osc_server_thread);
scm_c_define_gsubr("add-osc-method", 3, 0, 0, add_osc_method);
+ scm_c_define_gsubr("make-osc-address", 1, 0, 0, make_osc_address);
+ scm_c_define_gsubr("osc-send", 2, 0, 1, osc_send);
scm_add_feature("guile-osc");
}