aboutsummaryrefslogtreecommitdiff
path: root/osc.lv2/osc.lv2
diff options
context:
space:
mode:
authorHanspeter Portner <dev@open-music-kontrollers.ch>2018-05-19 20:02:59 +0200
committerHanspeter Portner <dev@open-music-kontrollers.ch>2018-05-19 20:02:59 +0200
commit0f2e9ebf4b7cead78f6f05b03a893f6edf99a5f9 (patch)
tree23215b437925896f8169099f7d1c62027fe917b6 /osc.lv2/osc.lv2
parent944c2255c7e3d20887d6e138c36ca454963a34a9 (diff)
parentb93a7c9484f8f424e45aff38b8bfc892b5a201c4 (diff)
downloadsynthpod-0f2e9ebf4b7cead78f6f05b03a893f6edf99a5f9.tar.xz
Merge commit 'b93a7c9484f8f424e45aff38b8bfc892b5a201c4'
Diffstat (limited to 'osc.lv2/osc.lv2')
-rw-r--r--osc.lv2/osc.lv2/stream.h12
-rw-r--r--osc.lv2/osc.lv2/writer.h22
2 files changed, 21 insertions, 13 deletions
diff --git a/osc.lv2/osc.lv2/stream.h b/osc.lv2/osc.lv2/stream.h
index 0efa0676..85c1187f 100644
--- a/osc.lv2/osc.lv2/stream.h
+++ b/osc.lv2/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/osc.lv2/writer.h b/osc.lv2/osc.lv2/writer.h
index dda3514b..037d44cd 100644
--- a/osc.lv2/osc.lv2/writer.h
+++ b/osc.lv2/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)