Commit c74bb83c authored by Hanspeter Portner's avatar Hanspeter Portner

Squashed 'osc.lv2/' changes from 1eaabb49..e9316bc2

e9316bc2 get rid of sscanf.
bff22acc fix lv2_osc_symbol_get.
c6f8fb69 fix LV2_ATOM_TUPLE_FOREACH.
0f69bfeb mingw: define htonll/ntohll.
ea2a418f add portable endian.h.
5df966f8 add missing header.
16035fe1 use atom:literal for osc:Nil/Impulse/Char/RGBA.
b3346080 implement argument iterator helpers.
346f8c34 remove test plugin, move headers, fix funcnames.
f7b07b9e extend unit test with forge/deforge.
f9006de6 implement forge.h, add util.h.
0a421cba add reader/writer/forge headers.
6c406c5a reduction to the minimum.
b8d91e2f prototype test plugin infra.
e3b36824 use double for frames in schedule interface.

git-subtree-dir: osc.lv2
git-subtree-split: e9316bc2
parent 1eaabb49
cmake_minimum_required(VERSION 2.8)
project(osc.lv2)
include_directories(${PROJECT_SOURCE_DIR})
set(CMAKE_C_FLAGS "-std=gnu11 -Wextra -Wno-unused-parameter -ffast-math -fvisibility=hidden ${CMAKE_C_FLAGS}")
set(CMAKE_C_FLAGS "-Wshadow -Wimplicit-function-declaration -Wredundant-decls -Wmissing-prototypes -Wstrict-prototypes ${CMAKE_C_FLAGS}")
include(CTest)
if(${BUILD_TESTING})
add_executable(osc_test
osc_test.c)
add_test(NAME API-Test COMMAND osc_test)
endif()
# Copyright (c) 2015 Hanspeter Portner (dev@open-music-kontrollers.ch)
# Copyright (c) 2015-2016 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
......
This diff is collapsed.
# Copyright (c) 2015 Hanspeter Portner (dev@open-music-kontrollers.ch)
# Copyright (c) 2015-2016 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
......
// "License": Public Domain
// I, Mathias Panzenböck, place this file hereby into the public domain. Use it at your own risk for whatever you like.
// In case there are jurisdictions that don't support putting things in the public domain you can also consider it to
// be "dual licensed" under the BSD, MIT and Apache licenses, if you want to. This code is trivial anyway. Consider it
// an example on how to get the endian conversion functions on different platforms.
#ifndef PORTABLE_ENDIAN_H__
#define PORTABLE_ENDIAN_H__
#if (defined(_WIN16) || defined(_WIN32) || defined(_WIN64)) && !defined(__WINDOWS__)
# define __WINDOWS__
#endif
#if defined(__linux__) || defined(__CYGWIN__)
# include <endian.h>
#elif defined(__APPLE__)
# include <libkern/OSByteOrder.h>
# define htobe16(x) OSSwapHostToBigInt16(x)
# define htole16(x) OSSwapHostToLittleInt16(x)
# define be16toh(x) OSSwapBigToHostInt16(x)
# define le16toh(x) OSSwapLittleToHostInt16(x)
# define htobe32(x) OSSwapHostToBigInt32(x)
# define htole32(x) OSSwapHostToLittleInt32(x)
# define be32toh(x) OSSwapBigToHostInt32(x)
# define le32toh(x) OSSwapLittleToHostInt32(x)
# define htobe64(x) OSSwapHostToBigInt64(x)
# define htole64(x) OSSwapHostToLittleInt64(x)
# define be64toh(x) OSSwapBigToHostInt64(x)
# define le64toh(x) OSSwapLittleToHostInt64(x)
# define __BYTE_ORDER BYTE_ORDER
# define __BIG_ENDIAN BIG_ENDIAN
# define __LITTLE_ENDIAN LITTLE_ENDIAN
# define __PDP_ENDIAN PDP_ENDIAN
#elif defined(__OpenBSD__)
# include <sys/endian.h>
#elif defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)
# include <sys/endian.h>
# define be16toh(x) betoh16(x)
# define le16toh(x) letoh16(x)
# define be32toh(x) betoh32(x)
# define le32toh(x) letoh32(x)
# define be64toh(x) betoh64(x)
# define le64toh(x) letoh64(x)
#elif defined(__WINDOWS__)
# include <winsock2.h>
# include <sys/param.h>
# if BYTE_ORDER == LITTLE_ENDIAN
# define htobe16(x) htons(x)
# define htole16(x) (x)
# define be16toh(x) ntohs(x)
# define le16toh(x) (x)
# define htobe32(x) htonl(x)
# define htole32(x) (x)
# define be32toh(x) ntohl(x)
# define le32toh(x) (x)
# ifndef htonll
static inline uint64_t htonll(uint64_t n)
{
return (((uint64_t)htonl(n)) << 32) + htonl(n >> 32);
}
# endif
# ifndef ntohll
# define ntohll htonll
# endif
# define htobe64(x) htonll(x)
# define htole64(x) (x)
# define be64toh(x) ntohll(x)
# define le64toh(x) (x)
# elif BYTE_ORDER == BIG_ENDIAN
/* that would be xbox 360 */
# define htobe16(x) (x)
# define htole16(x) __builtin_bswap16(x)
# define be16toh(x) (x)
# define le16toh(x) __builtin_bswap16(x)
# define htobe32(x) (x)
# define htole32(x) __builtin_bswap32(x)
# define be32toh(x) (x)
# define le32toh(x) __builtin_bswap32(x)
# define htobe64(x) (x)
# define htole64(x) __builtin_bswap64(x)
# define be64toh(x) (x)
# define le64toh(x) __builtin_bswap64(x)
# else
# error byte order not supported
# endif
# define __BYTE_ORDER BYTE_ORDER
# define __BIG_ENDIAN BIG_ENDIAN
# define __LITTLE_ENDIAN LITTLE_ENDIAN
# define __PDP_ENDIAN PDP_ENDIAN
#else
# error platform not supported
#endif
#endif
This diff is collapsed.
/*
* Copyright (c) 2015-2016 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.
*/
#ifndef LV2_OSC_H
#define LV2_OSC_H
#include <stdint.h>
#include <lv2/lv2plug.in/ns/ext/urid/urid.h>
#include <lv2/lv2plug.in/ns/ext/atom/atom.h>
#include <lv2/lv2plug.in/ns/ext/midi/midi.h>
#define LV2_OSC_URI "http://open-music-kontrollers.ch/lv2/osc"
#define LV2_OSC_PREFIX LV2_OSC_URI "#"
#define LV2_OSC__Event LV2_OSC_PREFIX "Event" // atom message type
#define LV2_OSC__schedule LV2_OSC_PREFIX "schedule" // feature
#define LV2_OSC__Packet LV2_OSC_PREFIX "Packet" // atom object type
#define LV2_OSC__Bundle LV2_OSC_PREFIX "Bundle" // atom object type
#define LV2_OSC__bundleTimetag LV2_OSC_PREFIX "bundleTimetag" // atom object property
#define LV2_OSC__bundleItems LV2_OSC_PREFIX "bundleItems"
#define LV2_OSC__Message LV2_OSC_PREFIX "Message" // atom object type
#define LV2_OSC__messagePath LV2_OSC_PREFIX "messagePath" // atom object property
#define LV2_OSC__messageArguments LV2_OSC_PREFIX "messageArguments" // atom object property
#define LV2_OSC__Timetag LV2_OSC_PREFIX "Timetag" // atom object type
#define LV2_OSC__timetagIntegral LV2_OSC_PREFIX "timetagIntegral" // atom object property
#define LV2_OSC__timetagFraction LV2_OSC_PREFIX "timetagFraction" // atom object property
#define LV2_OSC__Nil LV2_OSC_PREFIX "Nil" // atom literal type
#define LV2_OSC__Impulse LV2_OSC_PREFIX "Impulse" // atom literal type
#define LV2_OSC__Char LV2_OSC_PREFIX "Char" // atom literal type
#define LV2_OSC__RGBA LV2_OSC_PREFIX "RGBA" // atom literal type
#define LV2_OSC_PADDED_SIZE(size) ( ( (size_t)(size) + 3 ) & ( ~3 ) )
#define LV2_OSC_IMMEDIATE 1ULL
#ifdef __cplusplus
extern "C" {
#endif
typedef void *LV2_OSC_Schedule_Handle;
typedef double (*LV2_OSC_Schedule_OSC2Frames)(
LV2_OSC_Schedule_Handle handle,
uint64_t timetag);
typedef uint64_t (*LV2_OSC_Schedule_Frames2OSC)(
LV2_OSC_Schedule_Handle handle,
double frames);
typedef struct _LV2_OSC_Schedule {
LV2_OSC_Schedule_Handle handle;
LV2_OSC_Schedule_OSC2Frames osc2frames;
LV2_OSC_Schedule_Frames2OSC frames2osc;
} LV2_OSC_Schedule;
typedef enum LV2_OSC_Type {
LV2_OSC_INT32 = 'i',
LV2_OSC_FLOAT = 'f',
LV2_OSC_STRING = 's',
LV2_OSC_BLOB = 'b',
LV2_OSC_TRUE = 'T',
LV2_OSC_FALSE = 'F',
LV2_OSC_NIL = 'N',
LV2_OSC_IMPULSE = 'I',
LV2_OSC_INT64 = 'h',
LV2_OSC_DOUBLE = 'd',
LV2_OSC_TIMETAG = 't',
LV2_OSC_SYMBOL = 'S',
LV2_OSC_CHAR = 'c',
LV2_OSC_MIDI = 'm',
LV2_OSC_RGBA = 'r'
} LV2_OSC_Type;
union swap32_t {
uint32_t u;
int32_t i;
float f;
};
union swap64_t {
uint64_t u;
int64_t h;
uint64_t t;
double d;
};
typedef struct _LV2_OSC_Timetag {
uint32_t integral;
uint32_t fraction;
} LV2_OSC_Timetag;
typedef struct _LV2_OSC_URID {
LV2_URID OSC_Packet;
LV2_URID OSC_Bundle;
LV2_URID OSC_bundleTimetag;
LV2_URID OSC_bundleItems;
LV2_URID OSC_Message;
LV2_URID OSC_messagePath;
LV2_URID OSC_messageArguments;
LV2_URID OSC_Timetag;
LV2_URID OSC_timetagIntegral;
LV2_URID OSC_timetagFraction;
LV2_URID OSC_Nil;
LV2_URID OSC_Impulse;
LV2_URID OSC_Char;
LV2_URID OSC_RGBA;
LV2_URID MIDI_MidiEvent;
LV2_URID ATOM_Int;
LV2_URID ATOM_Long;
LV2_URID ATOM_String;
LV2_URID ATOM_Literal;
LV2_URID ATOM_Float;
LV2_URID ATOM_Double;
LV2_URID ATOM_URID;
LV2_URID ATOM_Bool;
LV2_URID ATOM_Tuple;
LV2_URID ATOM_Object;
LV2_URID ATOM_Chunk;
} LV2_OSC_URID;
static inline void
lv2_osc_urid_init(LV2_OSC_URID *osc_urid, LV2_URID_Map *map)
{
osc_urid->OSC_Packet = map->map(map->handle, LV2_OSC__Packet);
osc_urid->OSC_Bundle = map->map(map->handle, LV2_OSC__Bundle);
osc_urid->OSC_bundleTimetag = map->map(map->handle, LV2_OSC__bundleTimetag);
osc_urid->OSC_bundleItems = map->map(map->handle, LV2_OSC__bundleItems);
osc_urid->OSC_Message = map->map(map->handle, LV2_OSC__Message);
osc_urid->OSC_messagePath = map->map(map->handle, LV2_OSC__messagePath);
osc_urid->OSC_messageArguments = map->map(map->handle, LV2_OSC__messageArguments);
osc_urid->OSC_Timetag = map->map(map->handle, LV2_OSC__Timetag);
osc_urid->OSC_timetagIntegral = map->map(map->handle, LV2_OSC__timetagIntegral);
osc_urid->OSC_timetagFraction = map->map(map->handle, LV2_OSC__timetagFraction);
osc_urid->OSC_Nil = map->map(map->handle, LV2_OSC__Nil);
osc_urid->OSC_Impulse = map->map(map->handle, LV2_OSC__Impulse);
osc_urid->OSC_Char = map->map(map->handle, LV2_OSC__Char);
osc_urid->OSC_RGBA = map->map(map->handle, LV2_OSC__RGBA);
osc_urid->MIDI_MidiEvent = map->map(map->handle, LV2_MIDI__MidiEvent);
osc_urid->ATOM_Int = map->map(map->handle, LV2_ATOM__Int);
osc_urid->ATOM_Long = map->map(map->handle, LV2_ATOM__Long);
osc_urid->ATOM_String = map->map(map->handle, LV2_ATOM__String);
osc_urid->ATOM_Literal = map->map(map->handle, LV2_ATOM__Literal);
osc_urid->ATOM_Float = map->map(map->handle, LV2_ATOM__Float);
osc_urid->ATOM_Double = map->map(map->handle, LV2_ATOM__Double);
osc_urid->ATOM_URID = map->map(map->handle, LV2_ATOM__URID);
osc_urid->ATOM_Bool = map->map(map->handle, LV2_ATOM__Bool);
osc_urid->ATOM_Tuple = map->map(map->handle, LV2_ATOM__Tuple);
osc_urid->ATOM_Object = map->map(map->handle, LV2_ATOM__Object);
osc_urid->ATOM_Chunk = map->map(map->handle, LV2_ATOM__Chunk);
}
#ifdef __cplusplus
} // extern "C"
#endif
#endif // LV2_OSC_H
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
# Copyright (c) 2015 Hanspeter Portner (dev@open-music-kontrollers.ch)
# Copyright (c) 2015-2016 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
......@@ -13,14 +13,12 @@
# along the source as a COPYING file. If not, obtain it from
# http://www.perlfoundation.org/artistic_license_2_0.
@prefix atom: <http://lv2plug.in/ns/ext/atom#> .
@prefix lv2: <http://lv2plug.in/ns/lv2core#> .
@prefix midi: <http://lv2plug.in/ns/midi#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix osc: <http://open-music-kontrollers.ch/lv2/osc#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix lv2: <http://lv2plug.in/ns/lv2core#> .
@prefix atom: <http://lv2plug.in/ns/ext/atom#> .
@prefix osc: <http://open-music-kontrollers.ch/lv2/osc#> .
<http://open-music-kontrollers.ch/lv2/osc>
a owl:Ontology ;
......@@ -37,65 +35,8 @@ osc:schedule
a lv2:Feature .
osc:Event
a rdfs:Class ;
rdfs:subClassOf atom:Object ;
a rdfs:Class ,
rdfs:Datatype ;
rdfs:subClassOf atom:Atom ;
owl:onDatatype xsd:hexBinary ;
rdfs:label "OSC Event (Bundle or Message)" .
osc:Bundle
a rdfs:Class ;
rdfs:subClassOf osc:Event ;
rdfs:label "OSC Bundle" .
osc:Message
a rdfs:Class ;
rdfs:subClassOf osc:Event ;
rdfs:label "OSC Message" .
osc:bundleTimestamp
a rdf:Property ,
owl:ObjectProperty ,
owl:FunctionalProperty ;
rdfs:domain osc:Bundle ;
rdfs:range atom:Long ;
rdfs:label "OSC Bundle Timestamp" .
osc:bundleItems
a rdf:Property ,
owl:ObjectProperty ,
owl:FunctionalProperty ;
rdfs:domain osc:Bundle ;
rdfs:range atom:Tuple ;
rdfs:label "OSC Bundle Items" ;
lv2:documentation """
<p>Tuple of OSC Bundle Items (e.g. nested osc:Bundle's and/or
osc:Message's).</p>
""" .
osc:messagePath
a rdf:Property ,
owl:ObjectProperty ,
owl:FunctionalProperty ;
rdfs:domain osc:Message ;
rdfs:range atom:String ;
rdfs:label "OSC Message Path" .
osc:messageFormat
a rdf:Property ,
owl:ObjectProperty ,
owl:FunctionalProperty ;
rdfs:domain osc:Message ;
rdfs:range atom:String ;
rdfs:label "OSC Message Format" .
osc:messageArguments
a rdf:Property ,
owl:ObjectProperty ,
owl:FunctionalProperty ;
rdfs:domain osc:Message ;
rdfs:range atom:Tuple ;
rdfs:label "OSC Message Arguments" ;
lv2:documentation """
<p>Tuple of OSC Message Arguments (e.g. Atom:Int, Atom:Long, Atom:Float,
Atom:Double, Atom:String, Atom:Chunk, Atom:Bool, Atom:Blank,
MIDI:MidiEvent).</p>
""" .
#include <assert.h>
#include <string.h>
#include <stdio.h>
#include <osc.lv2/osc.h>
#include <osc.lv2/reader.h>
#include <osc.lv2/writer.h>
#include <osc.lv2/forge.h>
#define BUF_SIZE 8192
#define MAX_URIDS 512
typedef void (*test_t)(LV2_OSC_Writer *writer);
typedef struct _urid_t urid_t;
typedef struct _handle_t handle_t;
struct _urid_t {
LV2_URID urid;
char *uri;
};
struct _handle_t {
urid_t urids [MAX_URIDS];
LV2_URID urid;
};
static handle_t __handle;
static uint8_t buf0 [BUF_SIZE];
static uint8_t buf1 [BUF_SIZE];
static uint8_t buf2 [BUF_SIZE];
static const LV2_Atom_Object *obj2= (const LV2_Atom_Object *)buf2;
const uint8_t raw_0 [] = {
'/', 0x0, 0x0, 0x0,
',', 0x0, 0x0, 0x0
};
const uint8_t raw_1 [] = {
'/', 'p', 'i', 'n',
'g', 0x0, 0x0, 0x0,
',', 'i', 'f', 's',
0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0xc,
0x40, 0x59, 0x99, 0x9a,
'w', 'o', 'r', 'l',
'd', 0x0, 0x0, 0x0
};
const uint8_t raw_2 [] = {
'/', 'p', 'i', 'n',
'g', 0x0, 0x0, 0x0,
',', 'h', 'd', 'S',
0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0xc,
0x40, 0x0b, 0x33, 0x33,
0x33, 0x33, 0x33, 0x33,
'h', 't', 't', 'p',
':', '/', '/', 'e',
'x', 'a', 'm', 'p',
'l', 'e', '.', 'c',
'o', 'm', 0x0, 0x0
};
const uint8_t raw_3 [] = {
'/', 'p', 'i', 'n',
'g', 0x0, 0x0, 0x0,
',', 'T', 'F', 'N',
'I', 0x0, 0x0, 0x0
};
const uint8_t raw_4 [] = {
'/', 'm', 'i', 'd',
'i', 0x0, 0x0, 0x0,
',', 'm', 0x0, 0x0,
0x0, 0x90, 24, 0x7f
};
const uint8_t raw_5 [] = {
'/', 'b', 'l', 'o',
'b', 0x0, 0x0, 0x0,
',', 'b', 0x0, 0x0,
0x0, 0x0, 0x0, 0x6,
0x1, 0x2, 0x3, 0x4,
0x5, 0x6, 0x0, 0x0
};
const uint8_t raw_6 [] = {
'#', 'b', 'u', 'n',
'd', 'l', 'e', 0x0,
0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x1,
0x0, 0x0, 0x0, 0x8,
'/', 0x0, 0x0, 0x0,
',', 0x0, 0x0, 0x0
};
const uint8_t raw_7 [] = {
'#', 'b', 'u', 'n',
'd', 'l', 'e', 0x0,
0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x1,
0x0, 0x0, 0x0, 0x1c,
'#', 'b', 'u', 'n',
'd', 'l', 'e', 0x0,
0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x1,
0x0, 0x0, 0x0, 0x8,
'/', 0x0, 0x0, 0x0,
',', 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x8,
'/', 0x0, 0x0, 0x0,
',', 0x0, 0x0, 0x0
};
static LV2_URID
_map(LV2_URID_Map_Handle instance, const char *uri)
{
handle_t *handle = instance;
urid_t *itm;
for(itm=handle->urids; itm->urid; itm++)
{
if(!strcmp(itm->uri, uri))
return itm->urid;
}
assert(handle->urid + 1 < MAX_URIDS);
// create new
itm->urid = ++handle->urid;
itm->uri = strdup(uri);
return itm->urid;
}
static const char *
_unmap(LV2_URID_Unmap_Handle instance, LV2_URID urid)
{
handle_t *handle = instance;
urid_t *itm;
for(itm=handle->urids; itm->urid; itm++)
{
if(itm->urid == urid)
return itm->uri;
}
// not found
return NULL;
}
static LV2_URID_Map map = {
.handle = &__handle,
.map = _map
};
static LV2_URID_Unmap unmap = {
.handle = &__handle,
.unmap = _unmap
};
static void
_dump(const uint8_t *src, const uint8_t *dst, size_t size)
{
for(size_t i = 0; i < size; i++)
printf("%zu %02x %02x\n", i, src[i], dst[i]);
printf("\n");
}
static void
_clone(LV2_OSC_Reader *reader, LV2_OSC_Writer *writer, size_t size)
{
if(lv2_osc_reader_is_bundle(reader))
{
LV2_OSC_Item *itm = OSC_READER_BUNDLE_BEGIN(reader, size);
assert(itm);
LV2_OSC_Writer_Frame frame_bndl;
assert(lv2_osc_writer_push_bundle(writer, &frame_bndl, itm->timetag));
OSC_READER_BUNDLE_ITERATE(reader, itm)
{
LV2_OSC_Reader reader2;
lv2_osc_reader_initialize(&reader2, itm->body, itm->size);
LV2_OSC_Writer_Frame frame_itm;
assert(lv2_osc_writer_push_item(writer, &frame_itm));
_clone(&reader2, writer, itm->size);
assert(lv2_osc_writer_pop_item(writer, &frame_itm));
}
assert(lv2_osc_writer_pop_bundle(writer, &frame_bndl));
}
else if(lv2_osc_reader_is_message(reader))
{
LV2_OSC_Arg *arg = OSC_READER_MESSAGE_BEGIN(reader, size);
assert(arg);
assert(lv2_osc_writer_add_path(writer, arg->path));
assert(lv2_osc_writer_add_format(writer, arg->type));
OSC_READER_MESSAGE_ITERATE(reader, arg)
{
switch((LV2_OSC_Type)*arg->type)
{
case LV2_OSC_INT32:
assert(lv2_osc_writer_add_int32(writer, arg->i));
break;
case LV2_OSC_FLOAT:
assert(lv2_osc_writer_add_float(writer, arg->f));
break;
case LV2_OSC_STRING:
assert(lv2_osc_writer_add_string(writer, arg->s));
break;
case LV2_OSC_BLOB:
assert(lv2_osc_writer_add_blob(writer, arg->size, arg->b));
break;
case LV2_OSC_INT64:
assert(lv2_osc_writer_add_int64(writer, arg->h));
break;
case LV2_OSC_DOUBLE:
assert(lv2_osc_writer_add_double(writer, arg->d));
break;
case LV2_OSC_TIMETAG:
assert(lv2_osc_writer_add_timetag(writer, arg->t));
break;
case LV2_OSC_TRUE:
case LV2_OSC_FALSE:
case LV2_OSC_NIL:
case LV2_OSC_IMPULSE:
break;
case LV2_OSC_MIDI:
assert(lv2_osc_writer_add_midi(writer, arg->size, arg->m));
break;
case LV2_OSC_SYMBOL:
assert(lv2_osc_writer_add_symbol(writer, arg->S));
break;
case LV2_OSC_CHAR:
assert(lv2_osc_writer_add_char(writer, arg->c));
break;
case LV2_OSC_RGBA:
assert(lv2_osc_writer_add_rgba(writer, arg->R, arg->G, arg->B, arg->A));
break;
}
}
}
}
static void
_test_a(LV2_OSC_Writer *writer, const uint8_t *raw, size_t size)
{
LV2_OSC_URID osc_urid;
lv2_osc_urid_init(&osc_urid, &map);
// check writer against raw bytes
size_t len;
assert(lv2_osc_writer_finalize(writer, &len) == buf0);
assert(len == size);
assert(memcmp(raw, buf0, size) == 0);
// check reader & writer
LV2_OSC_Reader reader;
lv2_osc_reader_initialize(&reader, buf0, size);
lv2_osc_writer_initialize(writer, buf1, BUF_SIZE);
_clone(&reader, writer, size);
// check cloned against raw bytes
assert(lv2_osc_writer_finalize(writer, &len) == buf1);
assert(len == size);
assert(memcmp(raw, buf1, size) == 0);
// check forge
LV2_Atom_Forge forge;
lv2_atom_forge_init(&forge, &map);
lv2_atom_forge_set_buffer(&forge, buf2, BUF_SIZE);
assert(lv2_osc_forge_packet(&forge, &osc_urid, &map, buf0, size));
// check deforge
lv2_osc_writer_initialize(writer, buf1, BUF_SIZE);
assert(lv2_osc_writer_packet(writer, &osc_urid, &unmap, obj2->atom.size, &obj2->body));
// check deforged against ra