Skip to content

Commit

Permalink
Merge branch 'master' into optimize-server2
Browse files Browse the repository at this point in the history
  • Loading branch information
malloch committed Nov 12, 2024
2 parents 86ebf8e + d109a24 commit 0f0c8bd
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 74 deletions.
26 changes: 19 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: install dependencies
Expand All @@ -24,19 +24,20 @@ jobs:
run: make test
- name: make dist
run: make dist
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: tarball
path: |
liblo*.tar.gz
MacOS-Latest:
runs-on: macOS-latest
MacOS:
runs-on: macOS-13
timeout-minutes: 20
env:
CC: clang
CXX: clang++
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: install dependencies
Expand Down Expand Up @@ -90,15 +91,16 @@ jobs:
&& cd ../..
- name: make test
run: make test
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: dylib
path: ./inst/lib/liblo.7.dylib

Windows-Latest:
runs-on: windows-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Run windows build script
Expand All @@ -112,3 +114,13 @@ jobs:
run: |
cd bld\
ctest -V
merge:
runs-on: ubuntu-latest
needs: [Linux, MacOS]
steps:
- name: Merge Artifacts
uses: actions/upload-artifact/merge@v4
with:
name: artifact
delete-merged: true
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
*~
*.lo
*.la
*.DS_Store
.deps
.libs
/Makefile
Expand All @@ -10,6 +11,8 @@
/autom4te.cache/
/build/Makefile
/build/Makefile.in
/cmake/Makefile
/cmake/Makefile.in
/compile
/config.guess
/config.h
Expand Down Expand Up @@ -55,6 +58,7 @@
/src/tools/Makefile.in
/src/tools/oscdump
/src/tools/oscsend
/src/tools/oscsendfile
/stamp-h1
/test
/test-driver
Expand Down
127 changes: 64 additions & 63 deletions src/cpp_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,68 +63,68 @@ void init(lo::Server &s)
int _j;
};

s.add_method("test0", "i", test3(j,"test0"));
s.del_method("test0", "i");
s.add_method("/test0", "i", test3(j,"/test0"));
s.del_method("/test0", "i");

s.add_method("test1", "i", test1, 0);
s.add_method("test2", "i", test2);
s.add_method("test3", "i", test3(j, "test3"));
s.add_method("/test1", "i", test1, 0);
s.add_method("/test2", "i", test2);
s.add_method("/test3", "i", test3(j, "/test3"));

s.add_method("test4", "i",
[j](lo_arg **argv, int argc)
{
printf("test4: %d, %d\n", j, argv[0]->i);
return 0;
});
s.add_method("/test4", "i",
[j](lo_arg **argv, int argc)
{
printf("/test4: %d, %d\n", j, argv[0]->i);
return 0;
});

j *= 2;
s.add_method("test5", "i",
[j](lo_arg **argv, int argc, lo_message msg)
{
printf("test5: %d, %d -- ", j, argv[0]->i);
lo_message_pp(msg);
return 0;
});
s.add_method("/test5", "i",
[j](lo_arg **argv, int argc, lo_message msg)
{
printf("/test5: %d, %d -- ", j, argv[0]->i);
lo_message_pp(msg);
return 0;
});

j *= 2;
s.add_method("test6", "i",
[j](lo_message msg)
{
printf("test6: %d -- ", j);
lo_message_pp(msg);
return 0;
});
s.add_method("/test6", "i",
[j](lo_message msg)
{
printf("/test6: %d -- ", j);
lo_message_pp(msg);
return 0;
});

j *= 2;
s.add_method("test7", "i", [j](){printf("test7: %d\n", j); return 0;});
s.add_method("/test7", "i", [j](){printf("/test7: %d\n", j); return 0;});
j *= 2;
s.add_method("test8", "i", [j](){printf("test8a: %d\n", j);});
s.add_method("/test8", "i", [j](){printf("/test8a: %d\n", j);});
j *= 2;
s.add_method("test8", "i", [j](){printf("test8b: %d\n", j);});
s.add_method("/test8", "i", [j](){printf("/test8b: %d\n", j);});

j*=2;
s.add_method("test9", "i", [j](const char *path, const char *types, lo_arg **argv, int argc)
{printf("test9.1: %d, %s, %s, %d\n", j, path, types, argv[0]->i); return 1;});
s.add_method("/test9", "i", [j](const char *path, const char *types, lo_arg **argv, int argc)
{printf("/test9.1: %d, %s, %s, %d\n", j, path, types, argv[0]->i); return 1;});
j*=2;
s.add_method("test10", "i", [j](const char *types, lo_arg **argv, int argc)
{printf("test10.1: %d, %s, %d\n", j, types, argv[0]->i); return 1;});
s.add_method("/test10", "i", [j](const char *types, lo_arg **argv, int argc)
{printf("/test10.1: %d, %s, %d\n", j, types, argv[0]->i); return 1;});
j*=2;
s.add_method("test11", "is", [j](const char *types, lo_arg **argv, int argc, lo_message msg)
{printf("test11.1: %d, %s, %d, %s -- ", j, types, argv[0]->i, &argv[1]->s); lo_message_pp(msg); return 1;});
s.add_method("/test11", "is", [j](const char *types, lo_arg **argv, int argc, lo_message msg)
{printf("/test11.1: %d, %s, %d, %s -- ", j, types, argv[0]->i, &argv[1]->s); lo_message_pp(msg); return 1;});

j*=2;
s.add_method("test9", "i", [j](const char *path, const char *types, lo_arg **argv, int argc)
{printf("test9.2: %d, %s, %s, %d\n", j, path, types, argv[0]->i);});
s.add_method("/test9", "i", [j](const char *path, const char *types, lo_arg **argv, int argc)
{printf("/test9.2: %d, %s, %s, %d\n", j, path, types, argv[0]->i);});
j*=2;
s.add_method("test10", "i", [j](const char *types, lo_arg **argv, int argc)
{printf("test10.2: %d, %s, %d\n", j, types, argv[0]->i);});
s.add_method("/test10", "i", [j](const char *types, lo_arg **argv, int argc)
{printf("/test10.2: %d, %s, %d\n", j, types, argv[0]->i);});
j*=2;
s.add_method("test11", "is", [j](const char *types, lo_arg **argv, int argc, lo_message msg)
{printf("test11.2: %d, %s, %d, %s -- ", j, types, argv[0]->i, &argv[1]->s); lo_message_pp(msg);});
s.add_method("/test11", "is", [j](const char *types, lo_arg **argv, int argc, lo_message msg)
{printf("/test11.2: %d, %s, %d, %s -- ", j, types, argv[0]->i, &argv[1]->s); lo_message_pp(msg);});

j*=2;
s.add_method("test12", "i", [j](const lo::Message m)
{printf("test12 (j=%d) source: %s\n", j, m.source().url().c_str());});
s.add_method("/test12", "i", [j](const lo::Message m)
{printf("/test12 (j=%d) source: %s\n", j, m.source().url().c_str());});

s.add_method(0, 0, [](const char *path, lo_message m){printf("generic: %s ", path); lo_message_pp(m);});

Expand Down Expand Up @@ -168,37 +168,38 @@ int main()
printf("iface: %s\n", a.iface().c_str());
#endif

a.send_from(st, "test1", "i", 20);
a.send("test2", "i", 40);
a.send("test3", "i", 60);
a.send("test4", "i", 80);
a.send("test5", "i", 100);
a.send("test6", "i", 120);
a.send("test7", "i", 140);
a.send("test8", "i", 160);
a.send("test9", "i", 180);
a.send("test10", std::string("i"), 200);
a.send_from(st, "/test1", "i", 20);
a.send("/test2", "i", 40);
a.send("/test3", "i", 60);
a.send("/test4", "i", 80);
a.send("/test5", "i", 100);
a.send("/test6", "i", 120);
a.send("/test7", "i", 140);
a.send("/test8", "i", 160);
a.send("/test9", "i", 180);
a.send("/test10", std::string("i"), 200);

lo::Message m;
m.add("i", 220);
m.add_string(std::string("blah"));
a.send("test11", m);
a.send("/test11", m);

m.add(lo::Blob(4,"asdf"));
m.add(lo::Blob(std::vector<char>(5, 'a')));
m.add(lo::Blob(std::array<char,5>{"asdf"}));
a.send("blobtest", m);
a.send("/blobtest", m);

a.send(
lo::Bundle({
{"test11", lo::Message("is",20,"first in bundle")},
{"test11", lo::Message("is",30,"second in bundle")}
})
);

lo::Bundle b({{"ok1", lo::Message("is",20,"first in bundle")},
lo::Bundle({"ok2", lo::Message("is",30,"second in bundle")})
}, LO_TT_IMMEDIATE);
{"/test11", lo::Message("is",20,"first in bundle")},
{"/test11", lo::Message("is",30,"second in bundle")}
})
);

lo::Bundle b({
{"/ok1", lo::Message("is",20,"first in bundle")},
lo::Bundle({"/ok2", lo::Message("is",30,"second in bundle")})
}, LO_TT_IMMEDIATE);
printf("Bundle:\n"); b.print();

lo::Bundle::Element e(b.get_element(0));
Expand All @@ -211,7 +212,7 @@ int main()
e.bundle.timestamp().sec,
e.bundle.timestamp().frac);

a.send("test12", "i", 240);
a.send("/test12", "i", 240);

char oscmsg[] = {'/','o','k',0,',','i',0,0,0,0,0,4};
lo::Message::maybe m2 = lo::Message::deserialise(oscmsg, sizeof(oscmsg));
Expand Down
2 changes: 2 additions & 0 deletions src/testlo.c
Original file line number Diff line number Diff line change
Expand Up @@ -1400,6 +1400,8 @@ void test_server_thread(lo_server_thread *pst, lo_address *pa)
-0.00000023001f, 1.0);
lo_send(a, "/a/b/c/d", "b", btest);

SLEEP_MS(1000);

/* Delete methods */
lo_server_thread_del_method(st, "/coerce", "dfhiSs");
TEST (lo_server_thread_del_lo_method(st, jit) == 0);
Expand Down
18 changes: 14 additions & 4 deletions src/tools/oscsendfile.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/*
* oscsend - Send OpenSound Control message.
* oscsendfile - Send OpenSound Control message.
*
* Copyright (C) 2016 Joseph Malloch <[email protected]>
*
* Adapted from oscsend:
* Copyright (C) 2008 Kentaro Fukuchi <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -45,8 +47,8 @@ void usage(void)
printf("oscsendfile version %s\n"
"Copyright (C) 2016 Joseph Malloch\n"
" adapted from oscsend.c (C) 2008 Kentaro Fukuchi\n\n"
"Usage: oscsend hostname port file <speed>\n"
"or oscsend url file <speed>\n"
"Usage: oscsendfile hostname port file <speed>\n"
"or oscsendfile url file <speed>\n"
"Send OpenSound Control messages from a file via UDP.\n\n"
"Description\n"
"hostname: specifies the remote host's name.\n"
Expand All @@ -55,7 +57,7 @@ void usage(void)
" e.g. UDP \"osc.udp://localhost:9000\"\n"
" Multicast \"osc.udp://224.0.1.9:9000\"\n"
" TCP \"osc.tcp://localhost:9000\"\n"
"speed : specifies a speed multiplier.\n",
"speed : specifies a speed multiplier (must be > 0).\n",
VERSION);
printf("Example\n"
"$ oscsendfile localhost 7777 myfile.txt 2.5\n");
Expand Down Expand Up @@ -219,15 +221,19 @@ lo_message create_message(char **argv)
}
case LO_TRUE:
lo_message_add_true(message);
++argi;
break;
case LO_FALSE:
lo_message_add_false(message);
++argi;
break;
case LO_NIL:
lo_message_add_nil(message);
++argi;
break;
case LO_INFINITUM:
lo_message_add_infinitum(message);
++argi;
break;
default:
fprintf(stderr, "Type '%c' is not supported or invalid.\n",
Expand Down Expand Up @@ -451,6 +457,10 @@ int main(int argc, char **argv)
if (argc > i+1) {
// optional speed argument
speed = atof(argv[i+1]);
if (speed <= 0.0) {
fprintf(stderr, "Negative speed multiplier is not supported.\n");
exit(1);
}
}
ret = send_file(target, speed);

Expand Down

0 comments on commit 0f0c8bd

Please sign in to comment.