aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Hanspeter Portner <dev@open-music-kontrollers.ch>2018-05-19 20:03:25 +0200
committerGravatar Hanspeter Portner <dev@open-music-kontrollers.ch>2018-05-19 20:03:25 +0200
commit91857efae50d74da5c9c874856a65d44963f5086 (patch)
tree15c8a3b36e4068c5a483370fca0f8b9d04d1312d
parentde935451ca61e9de24c23ab801d691de93bb4b7a (diff)
downloadchim.lv2-91857efae50d74da5c9c874856a65d44963f5086.zip
chim.lv2-91857efae50d74da5c9c874856a65d44963f5086.tar.gz
chim.lv2-91857efae50d74da5c9c874856a65d44963f5086.tar.bz2
chim.lv2-91857efae50d74da5c9c874856a65d44963f5086.tar.xz
Squashed 'osc.lv2/' changes from dbc66f5..0ed6f99
0ed6f99 fix missed pieces in last commit. 6a1f3b3 fix potentially uninitialized frame structures. e48c4d0 fix name clashes in tests on mingw32. 937189e do not run stream tests on mingw32. d0748f0 fix unit test on 32-bit systems. c5b2557 initial migration to meson. git-subtree-dir: osc.lv2 git-subtree-split: 0ed6f994c2b7d1a89ad95b0b0f1c9b6c01a463af
-rw-r--r--.gitlab-ci.yml62
-rw-r--r--README.md30
-rw-r--r--VERSION1
-rw-r--r--meson.build34
-rw-r--r--osc.lv2/stream.h12
-rw-r--r--osc.lv2/writer.h22
-rw-r--r--test/Makefile15
-rw-r--r--test/osc_test.c46
8 files changed, 175 insertions, 47 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644
index 0000000..ebc4676
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,62 @@
+stages:
+ - test
+
+.variables_template: &variables_definition
+ variables:
+ BASE_NAME: "osc.lv2"
+ PKG_CONFIG_PATH: "/opt/lv2/lib/pkgconfig:/opt/${CI_BUILD_NAME}/lib/pkgconfig:/usr/lib/${CI_BUILD_NAME}/pkgconfig"
+
+.common_template: &common_definition
+ <<: *variables_definition
+ stage: test
+
+.build_template: &build_definition
+ <<: *common_definition
+ script:
+ - meson --cross-file "${CI_BUILD_NAME}" build
+ - ninja -C build
+
+.test_template: &test_definition
+ <<: *common_definition
+ script:
+ - meson --cross-file "${CI_BUILD_NAME}" build
+ - ninja -C build
+ - cd build
+ - meson test --verbose --wrap "${CI_BUILD_NAME}.wrap"
+
+.universal_linux_template: &universal_linux_definition
+ image: ventosus/universal-linux-gnu
+ <<: *test_definition
+
+.arm_linux_template: &arm_linux_definition
+ image: ventosus/arm-linux-gnueabihf
+ <<: *test_definition
+
+.universal_w64_template: &universal_w64_definition
+ image: ventosus/universal-w64-mingw32
+ before_script:
+ - ln -s /usr/lib/gcc/i686-w64-mingw32/6.3-win32/libgcc_s_sjlj-1.dll /opt/i686-w64-mingw32/lib/libgcc_s_sjlj-1.dll
+ <<: *test_definition
+
+.universal_apple_template: &universal_apple_definition
+ image: ventosus/universal-apple-darwin
+ <<: *build_definition
+
+# building in docker
+x86_64-linux-gnu:
+ <<: *universal_linux_definition
+
+i686-linux-gnu:
+ <<: *universal_linux_definition
+
+arm-linux-gnueabihf:
+ <<: *arm_linux_definition
+
+x86_64-w64-mingw32:
+ <<: *universal_w64_definition
+
+i686-w64-mingw32:
+ <<: *universal_w64_definition
+
+universal-apple-darwin:
+ <<: *universal_apple_definition
diff --git a/README.md b/README.md
index b48021f..1a30571 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,33 @@
# osc.lv2
## Open Sound Control Extension for the LV2 Plugin Specification
+
+### Build Status
+
+[![build status](https://gitlab.com/OpenMusicKontrollers/osc.lv2/badges/master/build.svg)](https://gitlab.com/OpenMusicKontrollers/osc.lv2/commits/master)
+
+### Build / test
+
+ git clone https://git.open-music-kontrollers.ch/lv2/osc.lv2
+ cd osc.lv2
+ meson build
+ cd build
+ ninja -j4
+ ninja test
+
+### License
+
+Copyright (c) 2017 Hanspeter Portner (dev@open-music-kontrollers.ch)
+
+This is free software: you can redistribute it and/or modify
+it under the terms of the Artistic License 2.0 as published by
+The Perl Foundation.
+
+This source is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+Artistic License 2.0 for more details.
+
+You should have received a copy of the Artistic License 2.0
+along the source as a COPYING file. If not, obtain it from
+<http://www.perlfoundation.org/artistic_license_2_0>.
diff --git a/VERSION b/VERSION
new file mode 100644
index 0000000..c0c68ba
--- /dev/null
+++ b/VERSION
@@ -0,0 +1 @@
+0.1.85
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..ba60db1
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,34 @@
+project('osc.lv2', 'c', default_options : [
+ 'buildtype=release',
+ 'warning_level=3',
+ 'werror=true',
+ 'b_lto=true',
+ 'c_std=c11'])
+
+version = run_command('cat', 'VERSION').stdout().strip()
+
+add_project_arguments('-D_GNU_SOURCE', language : 'c')
+
+conf_data = configuration_data()
+cc = meson.get_compiler('c')
+
+lv2_dep = dependency('lv2')
+thread_dep = dependency('threads')
+deps = [lv2_dep, thread_dep]
+
+c_args = []
+
+if host_machine.system() == 'windows'
+ deps += cc.find_library('ws2_32')
+ c_args += '-Wno-error=format'
+ c_args += '-Wno-error=format-extra-args'
+endif
+
+osc_test = executable('osc_test',
+ join_paths('test', 'osc_test.c'),
+ c_args : c_args,
+ dependencies : deps,
+ install : false)
+
+test('Test', osc_test,
+ timeout : 240)
diff --git a/osc.lv2/stream.h b/osc.lv2/stream.h
index 0efa067..85c1187 100644
--- a/osc.lv2/stream.h
+++ b/osc.lv2/stream.h
@@ -20,12 +20,14 @@
#include <stdbool.h>
#include <string.h>
-#include <arpa/inet.h>
+#if !defined(_WIN32)
+# include <arpa/inet.h>
+# include <sys/socket.h>
+# include <net/if.h>
+# include <netinet/tcp.h>
+# include <netdb.h>
+#endif
#include <sys/types.h>
-#include <sys/socket.h>
-#include <net/if.h>
-#include <netinet/tcp.h>
-#include <netdb.h>
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
diff --git a/osc.lv2/writer.h b/osc.lv2/writer.h
index dda3514..037d44c 100644
--- a/osc.lv2/writer.h
+++ b/osc.lv2/writer.h
@@ -125,11 +125,14 @@ lv2_osc_writer_add_float(LV2_OSC_Writer *writer, float f)
static inline bool
lv2_osc_writer_add_string(LV2_OSC_Writer *writer, const char *s)
{
- const size_t padded = LV2_OSC_PADDED_SIZE(strlen(s) + 1);
+ const size_t rawlen = strlen(s) + 1;
+ const size_t padded = LV2_OSC_PADDED_SIZE(rawlen);
if(lv2_osc_writer_overflow(writer, padded))
return false;
- strncpy((char *)writer->ptr, s, padded);
+ const uint32_t blank = 0;
+ memcpy(writer->ptr + padded - sizeof(uint32_t), &blank, sizeof(uint32_t));
+ memcpy(writer->ptr, s, rawlen);
writer->ptr += padded;
return true;
@@ -171,7 +174,7 @@ lv2_osc_writer_add_blob_inline(LV2_OSC_Writer *writer, int32_t len, uint8_t **bo
return false;
*body = writer->ptr;
- memset(&writer->ptr[len], 0x0, len_padded - len);
+ //memset(&writer->ptr[len], 0x0, len_padded - len);
writer->ptr += len_padded;
return true;
@@ -196,7 +199,7 @@ lv2_osc_writer_add_midi_inline(LV2_OSC_Writer *writer, int32_t len, uint8_t **m)
return false;
*m = writer->ptr;
- memset(&writer->ptr[len], 0x0, 4 - len);
+ //memset(&writer->ptr[len], 0x0, 4 - len);
writer->ptr += 4;
return true;
@@ -301,12 +304,15 @@ lv2_osc_writer_add_path(LV2_OSC_Writer *writer, const char *path)
static inline bool
lv2_osc_writer_add_format(LV2_OSC_Writer *writer, const char *fmt)
{
- const size_t padded = LV2_OSC_PADDED_SIZE(strlen(fmt) + 2);
+ const size_t rawlen = strlen(fmt) + 1;
+ const size_t padded = LV2_OSC_PADDED_SIZE(rawlen + 1);
if(lv2_osc_writer_overflow(writer, padded))
return false;
+ const uint32_t blank = 0;
+ memcpy(writer->ptr + padded - sizeof(uint32_t), &blank, sizeof(uint32_t));
*writer->ptr++ = ',';
- strncpy((char *)writer->ptr, fmt, padded - 1);
+ memcpy(writer->ptr, fmt, rawlen);
writer->ptr += padded - 1;
return true;
@@ -437,7 +443,7 @@ lv2_osc_writer_packet(LV2_OSC_Writer *writer, LV2_OSC_URID *osc_urid,
return false;
LV2_OSC_Timetag tt;
- LV2_OSC_Writer_Frame bndl;
+ LV2_OSC_Writer_Frame bndl = { .ref = 0 };
lv2_osc_timetag_get(osc_urid, &timetag->atom, &tt);
if(!lv2_osc_writer_push_bundle(writer, &bndl, lv2_osc_timetag_parse(&tt)))
@@ -446,7 +452,7 @@ lv2_osc_writer_packet(LV2_OSC_Writer *writer, LV2_OSC_URID *osc_urid,
LV2_ATOM_TUPLE_FOREACH(items, atom)
{
const LV2_Atom_Object *obj= (const LV2_Atom_Object *)atom;
- LV2_OSC_Writer_Frame itm;
+ LV2_OSC_Writer_Frame itm = { .ref = 0 };
if( !lv2_osc_writer_push_item(writer, &itm)
|| !lv2_osc_writer_packet(writer, osc_urid, unmap, obj->atom.size, &obj->body)
diff --git a/test/Makefile b/test/Makefile
deleted file mode 100644
index 9e6530e..0000000
--- a/test/Makefile
+++ /dev/null
@@ -1,15 +0,0 @@
-CC ?= gcc
-C_FLAGS ?= -I../ -Wall -Wextra -Wpedantic $(shell pkg-config --cflags lv2) \
- -fprofile-arcs -ftest-coverage
-
-all: osc_test
-
-osc_test: osc_test.c ../osc.lv2/*.h
- $(CC) -std=gnu11 -g -o $@ $< $(C_FLAGS) -lpthread
-
-check: osc_test
- ./$<
- gcov $<.c
-
-clean:
- rm -f osc_test *.gcov *.gc* vgcore.*
diff --git a/test/osc_test.c b/test/osc_test.c
index e853a14..e9566d5 100644
--- a/test/osc_test.c
+++ b/test/osc_test.c
@@ -8,26 +8,28 @@
#include <osc.lv2/reader.h>
#include <osc.lv2/writer.h>
#include <osc.lv2/forge.h>
-#include <osc.lv2/stream.h>
+#if !defined(_WIN32)
+# include <osc.lv2/stream.h>
+#endif
#define BUF_SIZE 0x100000
#define MAX_URIDS 512
typedef void (*test_t)(LV2_OSC_Writer *writer);
typedef struct _urid_t urid_t;
-typedef struct _handle_t handle_t;
+typedef struct _app_t app_t;
struct _urid_t {
LV2_URID urid;
char *uri;
};
-struct _handle_t {
+struct _app_t {
urid_t urids [MAX_URIDS];
LV2_URID urid;
};
-static handle_t __handle;
+static app_t __app;
static uint8_t buf0 [BUF_SIZE];
static uint8_t buf1 [BUF_SIZE];
static uint8_t buf2 [BUF_SIZE];
@@ -134,19 +136,19 @@ const uint8_t raw_8 [] = {
static LV2_URID
_map(LV2_URID_Map_Handle instance, const char *uri)
{
- handle_t *handle = instance;
+ app_t *app = instance;
urid_t *itm;
- for(itm=handle->urids; itm->urid; itm++)
+ for(itm=app->urids; itm->urid; itm++)
{
if(!strcmp(itm->uri, uri))
return itm->urid;
}
- assert(handle->urid + 1 < MAX_URIDS);
+ assert(app->urid + 1 < MAX_URIDS);
// create new
- itm->urid = ++handle->urid;
+ itm->urid = ++app->urid;
itm->uri = strdup(uri);
return itm->urid;
@@ -155,10 +157,10 @@ _map(LV2_URID_Map_Handle instance, const char *uri)
static const char *
_unmap(LV2_URID_Unmap_Handle instance, LV2_URID urid)
{
- handle_t *handle = instance;
+ app_t *app = instance;
urid_t *itm;
- for(itm=handle->urids; itm->urid; itm++)
+ for(itm=app->urids; itm->urid; itm++)
{
if(itm->urid == urid)
return itm->uri;
@@ -169,12 +171,12 @@ _unmap(LV2_URID_Unmap_Handle instance, LV2_URID urid)
}
static LV2_URID_Map map = {
- .handle = &__handle,
+ .handle = &__app,
.map = _map
};
static LV2_URID_Unmap unmap = {
- .handle = &__handle,
+ .handle = &__app,
.unmap = _unmap
};
@@ -197,7 +199,7 @@ _clone(LV2_OSC_Reader *reader, LV2_OSC_Writer *writer, size_t size)
LV2_OSC_Item *itm = OSC_READER_BUNDLE_BEGIN(reader, size);
assert(itm);
- LV2_OSC_Writer_Frame frame_bndl;
+ LV2_OSC_Writer_Frame frame_bndl = { .ref = 0 };
assert(lv2_osc_writer_push_bundle(writer, &frame_bndl, itm->timetag));
OSC_READER_BUNDLE_ITERATE(reader, itm)
@@ -205,7 +207,7 @@ _clone(LV2_OSC_Reader *reader, LV2_OSC_Writer *writer, size_t size)
LV2_OSC_Reader reader2;
lv2_osc_reader_initialize(&reader2, itm->body, itm->size);
- LV2_OSC_Writer_Frame frame_itm;
+ LV2_OSC_Writer_Frame frame_itm = { .ref = 0 };
assert(lv2_osc_writer_push_item(writer, &frame_itm));
_clone(&reader2, writer, itm->size);
assert(lv2_osc_writer_pop_item(writer, &frame_itm));
@@ -341,7 +343,7 @@ static void
test_2_a(LV2_OSC_Writer *writer)
{
assert(lv2_osc_writer_message_vararg(writer, "/ping", "hdS",
- 12, 3.4, "http://example.com"));
+ (int64_t)12, (double)3.4, "http://example.com"));
_test_a(writer, raw_2, sizeof(raw_2));
}
@@ -373,7 +375,8 @@ test_5_a(LV2_OSC_Writer *writer)
static void
test_6_a(LV2_OSC_Writer *writer)
{
- LV2_OSC_Writer_Frame frame_bndl, frame_itm;
+ LV2_OSC_Writer_Frame frame_bndl = { .ref = 0 };
+ LV2_OSC_Writer_Frame frame_itm = { .ref = 0 };
assert(lv2_osc_writer_push_bundle(writer, &frame_bndl, LV2_OSC_IMMEDIATE));
{
@@ -391,7 +394,8 @@ test_6_a(LV2_OSC_Writer *writer)
static void
test_7_a(LV2_OSC_Writer *writer)
{
- LV2_OSC_Writer_Frame frame_bndl[2], frame_itm[2];
+ LV2_OSC_Writer_Frame frame_bndl[2] = { { .ref = 0 }, { .ref = 0 } };
+ LV2_OSC_Writer_Frame frame_itm[2] = { { .ref = 0 }, { .ref = 0 } };;
assert(lv2_osc_writer_push_bundle(writer, &frame_bndl[0], LV2_OSC_IMMEDIATE));
{
@@ -466,6 +470,7 @@ _run_tests()
return 0;
}
+#if !defined(_WIN32)
typedef struct _item_t item_t;
typedef struct _stash_t stash_t;
@@ -896,6 +901,7 @@ static const pair_t pairs [] = {
.lossy = false
}
};
+#endif
int
main(int argc, char **argv)
@@ -906,6 +912,7 @@ main(int argc, char **argv)
fprintf(stdout, "running main tests:\n");
assert(_run_tests() == 0);
+#if !defined(_WIN32)
for(const pair_t *pair = pairs; pair->server; pair++)
{
pthread_t thread_1;
@@ -920,10 +927,11 @@ main(int argc, char **argv)
assert(pthread_join(thread_1, NULL) == 0);
assert(pthread_join(thread_2, NULL) == 0);
}
+#endif
- for(unsigned i=0; i<__handle.urid; i++)
+ for(unsigned i=0; i<__app.urid; i++)
{
- urid_t *itm = &__handle.urids[i];
+ urid_t *itm = &__app.urids[i];
free(itm->uri);
}