summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/AtomWriter.cpp29
-rw-r--r--src/Parser.cpp12
-rw-r--r--src/SocketReader.cpp13
-rw-r--r--src/server/ControlBindings.cpp8
-rw-r--r--src/server/JackDriver.cpp6
-rw-r--r--src/server/events/Copy.cpp1
6 files changed, 23 insertions, 46 deletions
diff --git a/src/AtomWriter.cpp b/src/AtomWriter.cpp
index f477adcc..4f342edf 100644
--- a/src/AtomWriter.cpp
+++ b/src/AtomWriter.cpp
@@ -1,6 +1,6 @@
/*
This file is part of Ingen.
- Copyright 2007-2016 David Robillard <http://drobilla.net/>
+ Copyright 2007-2017 David Robillard <http://drobilla.net/>
Ingen is free software: you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License as published by the Free
@@ -60,47 +60,26 @@
namespace Ingen {
-static LV2_Atom_Forge_Ref
-forge_sink(LV2_Atom_Forge_Sink_Handle handle,
- const void* buf,
- uint32_t size)
-{
- SerdChunk* chunk = (SerdChunk*)handle;
- const LV2_Atom_Forge_Ref ref = chunk->len + 1;
- serd_chunk_sink(buf, size, chunk);
- return ref;
-}
-
-static LV2_Atom*
-forge_deref(LV2_Atom_Forge_Sink_Handle handle, LV2_Atom_Forge_Ref ref)
-{
- SerdChunk* chunk = (SerdChunk*)handle;
- return (LV2_Atom*)(chunk->buf + ref - 1);
-}
-
AtomWriter::AtomWriter(URIMap& map, URIs& uris, AtomSink& sink)
: _map(map)
, _uris(uris)
, _sink(sink)
, _id(0)
{
- _out.buf = NULL;
- _out.len = 0;
lv2_atom_forge_init(&_forge, &map.urid_map_feature()->urid_map);
- lv2_atom_forge_set_sink(&_forge, forge_sink, forge_deref, &_out);
+ _out.set_forge_sink(&_forge);
}
AtomWriter::~AtomWriter()
{
- free((void*)_out.buf);
}
void
AtomWriter::finish_msg()
{
assert(!_forge.stack);
- _sink.write((const LV2_Atom*)_out.buf);
- _out.len = 0;
+ _sink.write(_out.atom());
+ _out.clear();
}
/** @page protocol
diff --git a/src/Parser.cpp b/src/Parser.cpp
index 765f9bd4..0e3a031e 100644
--- a/src/Parser.cpp
+++ b/src/Parser.cpp
@@ -1,6 +1,6 @@
/*
This file is part of Ingen.
- Copyright 2007-2016 David Robillard <http://drobilla.net/>
+ Copyright 2007-2017 David Robillard <http://drobilla.net/>
Ingen is free software: you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License as published by the Free
@@ -24,6 +24,7 @@
#include <glibmm/miscutils.h>
#include "ingen/Atom.hpp"
+#include "ingen/AtomForgeSink.hpp"
#include "ingen/Interface.hpp"
#include "ingen/Log.hpp"
#include "ingen/Parser.hpp"
@@ -127,22 +128,22 @@ get_properties(Ingen::World* world,
const Sord::Node& subject,
Resource::Graph ctx)
{
- SerdChunk out = { NULL, 0 };
LV2_URID_Map* map = &world->uri_map().urid_map_feature()->urid_map;
Sratom* sratom = sratom_new(map);
LV2_Atom_Forge forge;
lv2_atom_forge_init(&forge, map);
- lv2_atom_forge_set_sink(&forge, sratom_forge_sink, sratom_forge_deref, &out);
+
+ AtomForgeSink out(&forge);
const Sord::Node nil;
Resource::Properties props;
for (Sord::Iter i = model.find(subject, nil, nil); !i.end(); ++i) {
if (!skip_property(world->uris(), i.get_predicate())) {
- out.len = 0;
+ out.clear();
sratom_read(sratom, &forge, world->rdf_world()->c_obj(),
model.c_obj(), i.get_object().c_obj());
- const LV2_Atom* atom = (const LV2_Atom*)out.buf;
+ const LV2_Atom* atom = out.atom();
Atom atomm;
atomm = world->forge().alloc(
atom->size, atom->type, LV2_ATOM_BODY_CONST(atom));
@@ -151,7 +152,6 @@ get_properties(Ingen::World* world,
}
}
- free((uint8_t*)out.buf);
sratom_free(sratom);
return props;
}
diff --git a/src/SocketReader.cpp b/src/SocketReader.cpp
index 32552c24..381a5305 100644
--- a/src/SocketReader.cpp
+++ b/src/SocketReader.cpp
@@ -1,6 +1,6 @@
/*
This file is part of Ingen.
- Copyright 2007-2015 David Robillard <http://drobilla.net/>
+ Copyright 2007-2017 David Robillard <http://drobilla.net/>
Ingen is free software: you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License as published by the Free
@@ -17,6 +17,7 @@
#include <errno.h>
#include <poll.h>
+#include "ingen/AtomForgeSink.hpp"
#include "ingen/AtomReader.hpp"
#include "ingen/Interface.hpp"
#include "ingen/Log.hpp"
@@ -101,11 +102,10 @@ SocketReader::run()
// Set up sratom and a forge to build LV2 atoms from model
Sratom* sratom = sratom_new(map);
- SerdChunk chunk = { NULL, 0 };
LV2_Atom_Forge forge;
lv2_atom_forge_init(&forge, map);
- lv2_atom_forge_set_sink(
- &forge, sratom_forge_sink, sratom_forge_deref, &chunk);
+
+ AtomForgeSink buffer(&forge);
SordNode* base_uri = NULL;
SordModel* model = NULL;
@@ -173,10 +173,10 @@ SocketReader::run()
sratom_read(sratom, &forge, world->c_obj(), model, _msg_node);
// Call _iface methods based on atom content
- ar.write((const LV2_Atom*)chunk.buf);
+ ar.write(buffer.atom());
// Reset everything for the next iteration
- chunk.len = 0;
+ buffer.clear();
sord_node_free(world->c_obj(), _msg_node);
_msg_node = NULL;
}
@@ -191,7 +191,6 @@ SocketReader::run()
sratom_free(sratom);
serd_reader_free(reader);
sord_free(model);
- free((uint8_t*)chunk.buf);
_socket.reset();
}
diff --git a/src/server/ControlBindings.cpp b/src/server/ControlBindings.cpp
index 9e3d2fae..6ae4f856 100644
--- a/src/server/ControlBindings.cpp
+++ b/src/server/ControlBindings.cpp
@@ -1,6 +1,6 @@
/*
This file is part of Ingen.
- Copyright 2007-2016 David Robillard <http://drobilla.net/>
+ Copyright 2007-2017 David Robillard <http://drobilla.net/>
Ingen is free software: you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License as published by the Free
@@ -349,11 +349,11 @@ ControlBindings::finish_learn(RunContext& context, Key key)
binding->key = key;
_bindings->insert(*binding);
- uint8_t buf[128];
+ LV2_Atom buf[16];
memset(buf, 0, sizeof(buf));
- lv2_atom_forge_set_buffer(&_forge, buf, sizeof(buf));
+ lv2_atom_forge_set_buffer(&_forge, (uint8_t*)buf, sizeof(buf));
forge_binding(uris, &_forge, key.type, key.num);
- const LV2_Atom* atom = (const LV2_Atom*)buf;
+ const LV2_Atom* atom = buf;
context.notify(uris.midi_binding,
context.start(),
binding->port,
diff --git a/src/server/JackDriver.cpp b/src/server/JackDriver.cpp
index c03bf42c..77eb62b3 100644
--- a/src/server/JackDriver.cpp
+++ b/src/server/JackDriver.cpp
@@ -1,6 +1,6 @@
/*
This file is part of Ingen.
- Copyright 2007-2016 David Robillard <http://drobilla.net/>
+ Copyright 2007-2017 David Robillard <http://drobilla.net/>
Ingen is free software: you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License as published by the Free
@@ -422,9 +422,9 @@ JackDriver::append_time_events(RunContext& context,
_old_bpm = pos->beats_per_minute;
// Build an LV2 position object to append to the buffer
- uint8_t pos_buf[256];
+ LV2_Atom pos_buf[16];
LV2_Atom_Forge_Frame frame;
- lv2_atom_forge_set_buffer(&_forge, pos_buf, sizeof(pos_buf));
+ lv2_atom_forge_set_buffer(&_forge, (uint8_t*)pos_buf, sizeof(pos_buf));
lv2_atom_forge_object(&_forge, &frame, 0, uris.time_Position);
lv2_atom_forge_key(&_forge, uris.time_frame);
lv2_atom_forge_long(&_forge, pos->frame);
diff --git a/src/server/events/Copy.cpp b/src/server/events/Copy.cpp
index 58c9a89c..668a6fca 100644
--- a/src/server/events/Copy.cpp
+++ b/src/server/events/Copy.cpp
@@ -18,7 +18,6 @@
#include "ingen/Serialiser.hpp"
#include "ingen/Store.hpp"
#include "raul/Path.hpp"
-#include "serd/serd.h"
#include "BlockImpl.hpp"
#include "Broadcaster.hpp"