aboutsummaryrefslogtreecommitdiff
path: root/osc.lv2
diff options
context:
space:
mode:
authorHanspeter Portner <dev@open-music-kontrollers.ch>2018-05-19 20:04:17 +0200
committerHanspeter Portner <dev@open-music-kontrollers.ch>2018-05-19 20:04:17 +0200
commitb1da7a31b24ee63d135fdd010717d40dd9653fff (patch)
tree15c8a3b36e4068c5a483370fca0f8b9d04d1312d /osc.lv2
parentc333cb1ab3d2a0c7eaab61743900fba887d4ece4 (diff)
downloadmoony.lv2-b1da7a31b24ee63d135fdd010717d40dd9653fff.tar.xz
Squashed 'osc.lv2/' changes from dbc66f5d..0ed6f994
0ed6f994 fix missed pieces in last commit. 6a1f3b3d fix potentially uninitialized frame structures. e48c4d0c fix name clashes in tests on mingw32. 937189e4 do not run stream tests on mingw32. d0748f0f fix unit test on 32-bit systems. c5b2557d initial migration to meson. git-subtree-dir: osc.lv2 git-subtree-split: 0ed6f994c2b7d1a89ad95b0b0f1c9b6c01a463af
Diffstat (limited to 'osc.lv2')
-rw-r--r--osc.lv2/stream.h12
-rw-r--r--osc.lv2/writer.h22
2 files changed, 21 insertions, 13 deletions
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)