Commit 517298d1 authored by Hanspeter Portner's avatar Hanspeter Portner

Merge commit '904309f8'

parents 9bc4f298 904309f8
Pipeline #22079748 failed with stages
in 5 minutes and 33 seconds
This diff is collapsed.
......@@ -32,6 +32,10 @@
extern "C" {
#endif
#ifndef __unused
# define __unused __attribute__((unused))
#endif
#undef LV2_ATOM_TUPLE_FOREACH // there is a bug in LV2 1.10.0
#define LV2_ATOM_TUPLE_FOREACH(tuple, iter) \
for (LV2_Atom* (iter) = lv2_atom_tuple_begin(tuple); \
......@@ -203,7 +207,8 @@ lv2_osc_argument_type(LV2_OSC_URID *osc_urid, const LV2_Atom *atom)
}
static inline const LV2_Atom *
lv2_osc_int32_get(LV2_OSC_URID *osc_urid, const LV2_Atom *atom, int32_t *i)
lv2_osc_int32_get(LV2_OSC_URID *osc_urid __unused, const LV2_Atom *atom,
int32_t *i)
{
assert(i);
*i = ((const LV2_Atom_Int *)atom)->body;
......@@ -212,7 +217,8 @@ lv2_osc_int32_get(LV2_OSC_URID *osc_urid, const LV2_Atom *atom, int32_t *i)
}
static inline const LV2_Atom *
lv2_osc_float_get(LV2_OSC_URID *osc_urid, const LV2_Atom *atom, float *f)
lv2_osc_float_get(LV2_OSC_URID *osc_urid __unused, const LV2_Atom *atom,
float *f)
{
assert(f);
*f = ((const LV2_Atom_Float *)atom)->body;
......@@ -221,7 +227,8 @@ lv2_osc_float_get(LV2_OSC_URID *osc_urid, const LV2_Atom *atom, float *f)
}
static inline const LV2_Atom *
lv2_osc_string_get(LV2_OSC_URID *osc_urid, const LV2_Atom *atom, const char **s)
lv2_osc_string_get(LV2_OSC_URID *osc_urid __unused, const LV2_Atom *atom,
const char **s)
{
assert(s);
*s = LV2_ATOM_BODY_CONST(atom);
......@@ -230,8 +237,8 @@ lv2_osc_string_get(LV2_OSC_URID *osc_urid, const LV2_Atom *atom, const char **s)
}
static inline const LV2_Atom *
lv2_osc_blob_get(LV2_OSC_URID *osc_urid, const LV2_Atom *atom, uint32_t *size,
const uint8_t **b)
lv2_osc_blob_get(LV2_OSC_URID *osc_urid __unused, const LV2_Atom *atom,
uint32_t *size, const uint8_t **b)
{
assert(size && b);
*size = atom->size;
......@@ -241,7 +248,8 @@ lv2_osc_blob_get(LV2_OSC_URID *osc_urid, const LV2_Atom *atom, uint32_t *size,
}
static inline const LV2_Atom *
lv2_osc_int64_get(LV2_OSC_URID *osc_urid, const LV2_Atom *atom, int64_t *h)
lv2_osc_int64_get(LV2_OSC_URID *osc_urid __unused, const LV2_Atom *atom,
int64_t *h)
{
assert(h);
*h = ((const LV2_Atom_Long *)atom)->body;
......@@ -250,7 +258,8 @@ lv2_osc_int64_get(LV2_OSC_URID *osc_urid, const LV2_Atom *atom, int64_t *h)
}
static inline const LV2_Atom *
lv2_osc_double_get(LV2_OSC_URID *osc_urid, const LV2_Atom *atom, double *d)
lv2_osc_double_get(LV2_OSC_URID *osc_urid __unused, const LV2_Atom *atom,
double *d)
{
assert(d);
*d = ((const LV2_Atom_Double *)atom)->body;
......@@ -289,31 +298,32 @@ lv2_osc_timetag_get(LV2_OSC_URID *osc_urid, const LV2_Atom *atom,
}
static inline const LV2_Atom *
lv2_osc_true_get(LV2_OSC_URID *osc_urid, const LV2_Atom *atom)
lv2_osc_true_get(LV2_OSC_URID *osc_urid __unused, const LV2_Atom *atom)
{
return lv2_atom_tuple_next(atom);
}
static inline const LV2_Atom *
lv2_osc_false_get(LV2_OSC_URID *osc_urid, const LV2_Atom *atom)
lv2_osc_false_get(LV2_OSC_URID *osc_urid __unused, const LV2_Atom *atom)
{
return lv2_atom_tuple_next(atom);
}
static inline const LV2_Atom *
lv2_osc_nil_get(LV2_OSC_URID *osc_urid, const LV2_Atom *atom)
lv2_osc_nil_get(LV2_OSC_URID *osc_urid __unused, const LV2_Atom *atom)
{
return lv2_atom_tuple_next(atom);
}
static inline const LV2_Atom *
lv2_osc_impulse_get(LV2_OSC_URID *osc_urid, const LV2_Atom *atom)
lv2_osc_impulse_get(LV2_OSC_URID *osc_urid __unused, const LV2_Atom *atom)
{
return lv2_atom_tuple_next(atom);
}
static inline const LV2_Atom *
lv2_osc_symbol_get(LV2_OSC_URID *osc_urid, const LV2_Atom *atom, LV2_URID *S)
lv2_osc_symbol_get(LV2_OSC_URID *osc_urid __unused, const LV2_Atom *atom,
LV2_URID *S)
{
assert(S);
*S = ((const LV2_Atom_URID *)atom)->body;
......@@ -322,8 +332,8 @@ lv2_osc_symbol_get(LV2_OSC_URID *osc_urid, const LV2_Atom *atom, LV2_URID *S)
}
static inline const LV2_Atom *
lv2_osc_midi_get(LV2_OSC_URID *osc_urid, const LV2_Atom *atom, uint32_t *size,
const uint8_t **m)
lv2_osc_midi_get(LV2_OSC_URID *osc_urid __unused, const LV2_Atom *atom,
uint32_t *size, const uint8_t **m)
{
assert(size && m);
*size = atom->size;
......@@ -333,7 +343,7 @@ lv2_osc_midi_get(LV2_OSC_URID *osc_urid, const LV2_Atom *atom, uint32_t *size,
}
static inline const LV2_Atom *
lv2_osc_char_get(LV2_OSC_URID *osc_urid, const LV2_Atom *atom, char *c)
lv2_osc_char_get(LV2_OSC_URID *osc_urid __unused, const LV2_Atom *atom, char *c)
{
assert(c);
const char *str = LV2_ATOM_CONTENTS_CONST(LV2_Atom_Literal, atom);
......@@ -343,7 +353,7 @@ lv2_osc_char_get(LV2_OSC_URID *osc_urid, const LV2_Atom *atom, char *c)
}
static inline const LV2_Atom *
lv2_osc_rgba_get(LV2_OSC_URID *osc_urid, const LV2_Atom *atom,
lv2_osc_rgba_get(LV2_OSC_URID *osc_urid __unused, const LV2_Atom *atom,
uint8_t *r, uint8_t *g, uint8_t *b, uint8_t *a)
{
assert(r && g && b && a);
......
CC ?= gcc
#C_FLAGS ?= -I../ -Wall -Wextra -Wpedantic $(shell pkg-config --cflags lv2) \
# -fprofile-arcs -ftest-coverage
C_FLAGS ?= -I../ $(shell pkg-config --cflags lv2) \
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
./$@
gcov $<
check: osc_test
./$<
gcov $<.c
clean:
rm -f osc_test *.gcov *.gc* vgcore.*
......@@ -2,6 +2,7 @@
#include <string.h>
#include <stdio.h>
#include <pthread.h>
#include <time.h>
#include <osc.lv2/osc.h>
#include <osc.lv2/reader.h>
......@@ -9,7 +10,7 @@
#include <osc.lv2/forge.h>
#include <osc.lv2/stream.h>
#define BUF_SIZE 8192
#define BUF_SIZE 0x100000
#define MAX_URIDS 512
typedef void (*test_t)(LV2_OSC_Writer *writer);
......@@ -588,12 +589,21 @@ static const LV2_OSC_Driver driv = {
.read_adv = _read_adv
};
#define COUNT 1024
#define COUNT 128
typedef struct _pair_t pair_t;
struct _pair_t {
const char *server;
const char *client;
bool lossy;
};
static void *
_thread_1(void *data)
{
const char *uri = data;
const pair_t *pair = data;
const char *uri = pair->server;
LV2_OSC_Stream stream;
stash_t stash [2];
......@@ -605,9 +615,11 @@ _thread_1(void *data)
assert(lv2_osc_stream_init(&stream, uri, &driv, stash) == 0);
time_t t0 = time(NULL);
unsigned count = 0;
while(true)
{
const time_t t1 = time(NULL);
const LV2_OSC_Enum ev = lv2_osc_stream_run(&stream);
if(ev & LV2_OSC_RECV)
......@@ -648,31 +660,44 @@ _thread_1(void *data)
_stash_read_adv(&stash[0]);
}
t0 = t1;
}
if(count >= COUNT)
{
break;
}
else if(pair->lossy && (difftime(t1, t0) >= 1.0) )
{
fprintf(stderr, "%s: timeout: %i\n", __func__, count);
break;
}
}
LV2_OSC_Enum ev;
do
{
ev = lv2_osc_stream_run(&stream);
} while( (ev & LV2_OSC_SEND) || (stream.fd > 0) );
} while( (ev & LV2_OSC_SEND) || stream.connected );
sleep(1);
assert(pair->lossy || (count == COUNT) );
assert(lv2_osc_stream_deinit(&stream) == 0);
if(stash[0].rsvd)
{
free(stash[0].rsvd);
stash[0].rsvd = NULL;
while(stash[0].size)
{
_stash_read_adv(&stash[0]);
}
free(stash[0].items);
assert(stash[1].rsvd == 0);
free(stash[1].rsvd);
while(stash[1].size)
{
_stash_read_adv(&stash[1]);
}
free(stash[1].items);
return NULL;
}
......@@ -680,7 +705,8 @@ _thread_1(void *data)
static void *
_thread_2(void *data)
{
const char *uri = data;
const pair_t *pair = data;
const char *uri = pair->client;
LV2_OSC_Stream stream;
stash_t stash [2];
......@@ -746,8 +772,10 @@ _thread_2(void *data)
}
}
while(count <= (COUNT - 1))
time_t t0 = time(NULL);
while(true)
{
const time_t t1 = time(NULL);
const LV2_OSC_Enum ev = lv2_osc_stream_run(&stream);
if(ev & LV2_OSC_RECV)
......@@ -775,78 +803,97 @@ _thread_2(void *data)
_stash_read_adv(&stash[0]);
}
}
t0 = t1;
}
assert(count == COUNT);
if(count >= COUNT)
{
break;
}
else if(pair->lossy && (difftime(t1, t0) >= 1.0) )
{
fprintf(stderr, "%s: timeout: %i\n", __func__, count);
break;
}
}
sleep(1);
assert(pair->lossy || (count == COUNT) );
assert(lv2_osc_stream_deinit(&stream) == 0);
if(stash[0].rsvd)
{
free(stash[0].rsvd);
stash[0].rsvd = NULL;
while(stash[0].size)
{
_stash_read_adv(&stash[0]);
}
free(stash[0].items);
assert(stash[1].rsvd == NULL);
free(stash[1].rsvd);
while(stash[1].size)
{
_stash_read_adv(&stash[1]);
}
free(stash[1].items);
return NULL;
}
typedef struct _pair_t pair_t;
struct _pair_t {
const char *server;
const char *client;
};
static const pair_t pairs [] = {
{
.server = "osc.udp://:2222",
.client = "osc.udp://localhost:2222"
.client = "osc.udp://localhost:2222",
.lossy = true
},
{
.server = "osc.udp://[]:3333",
.client = "osc.udp://[::1]:3333"
.client = "osc.udp://[::1]:3333",
.lossy = true
},
{
.server = "osc.udp://:3344",
.client = "osc.udp://255.255.255.255:3344"
.client = "osc.udp://255.255.255.255:3344",
.lossy = true
},
{
.server = "osc.tcp://:4444",
.client = "osc.tcp://localhost:4444"
.client = "osc.tcp://localhost:4444",
.lossy = false
},
{
.server = "osc.tcp://[]:5555",
.client = "osc.tcp://[::1]:5555"
.client = "osc.tcp://[::1]:5555",
.lossy = false
},
{
.server = "osc.slip.tcp://:6666",
.client = "osc.slip.tcp://localhost:6666"
.client = "osc.slip.tcp://localhost:6666",
.lossy = false
},
{
.server = "osc.slip.tcp://[]:7777",
.client = "osc.slip.tcp://[::1]:7777"
.client = "osc.slip.tcp://[::1]:7777",
.lossy = false
},
{
.server = "osc.prefix.tcp://:8888",
.client = "osc.prefix.tcp://localhost:8888"
.client = "osc.prefix.tcp://localhost:8888",
.lossy = false
},
{
.server = "osc.prefix.tcp://[%lo]:9999",
.client = "osc.prefix.tcp://[::1%lo]:9999"
.client = "osc.prefix.tcp://[::1%lo]:9999",
.lossy = false
},
{
.server = NULL,
.client = NULL
.client = NULL,
.lossy = false
}
};
......@@ -864,13 +911,11 @@ main(int argc, char **argv)
pthread_t thread_1;
pthread_t thread_2;
const char *uri_1 = pair->server;
const char *uri_2 = pair->client;
fprintf(stdout, "running stream test: <%s> <%s>\n", uri_1, uri_2);
fprintf(stdout, "running stream test: <%s> <%s> %i\n",
pair->server, pair->client, pair->lossy);
assert(pthread_create(&thread_1, NULL, _thread_1, (void *)uri_1) == 0);
assert(pthread_create(&thread_2, NULL, _thread_2, (void *)uri_2) == 0);
assert(pthread_create(&thread_1, NULL, _thread_1, (void *)pair) == 0);
assert(pthread_create(&thread_2, NULL, _thread_2, (void *)pair) == 0);
assert(pthread_join(thread_1, NULL) == 0);
assert(pthread_join(thread_2, NULL) == 0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment