summaryrefslogtreecommitdiffstats
path: root/src/server/Context.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2014-08-31 01:24:57 +0000
committerDavid Robillard <d@drobilla.net>2014-08-31 01:24:57 +0000
commita2792bd09212eed55bba1aa30dc09043a6955486 (patch)
treed4262f760d4522bc6f1c99778987aada332b9e7e /src/server/Context.cpp
parente3ecb2b439bd03d27b5e11efe430c24f0ebe6283 (diff)
downloadingen-a2792bd09212eed55bba1aa30dc09043a6955486.tar.gz
ingen-a2792bd09212eed55bba1aa30dc09043a6955486.tar.bz2
ingen-a2792bd09212eed55bba1aa30dc09043a6955486.zip
Use float sequences for sample-accurate control ports.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@5462 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/server/Context.cpp')
-rw-r--r--src/server/Context.cpp38
1 files changed, 30 insertions, 8 deletions
diff --git a/src/server/Context.cpp b/src/server/Context.cpp
index 67a247e1..ecf078e1 100644
--- a/src/server/Context.cpp
+++ b/src/server/Context.cpp
@@ -47,13 +47,35 @@ struct Notification
Context::Context(Engine& engine, ID id)
: _engine(engine)
, _id(id)
- , _event_sink(engine.event_queue_size() * sizeof(Notification))
+ , _event_sink(
+ new Raul::RingBuffer(engine.event_queue_size() * sizeof(Notification)))
, _start(0)
, _end(0)
+ , _offset(0)
, _nframes(0)
, _realtime(true)
+ , _copy(false)
{}
+Context::Context(const Context& copy)
+ : _engine(copy._engine)
+ , _id(copy._id)
+ , _event_sink(copy._event_sink)
+ , _start(copy._start)
+ , _end(copy._end)
+ , _offset(copy._offset)
+ , _nframes(copy._nframes)
+ , _realtime(copy._realtime)
+ , _copy(true)
+{}
+
+Context::~Context()
+{
+ if (!_copy) {
+ delete _event_sink;
+ }
+}
+
bool
Context::must_notify(const PortImpl* port) const
{
@@ -69,12 +91,12 @@ Context::notify(LV2_URID key,
const void* body)
{
const Notification n(port, time, key, size, type);
- if (_event_sink.write_space() < sizeof(n) + size) {
+ if (_event_sink->write_space() < sizeof(n) + size) {
return false;
}
- if (_event_sink.write(sizeof(n), &n) != sizeof(n)) {
+ if (_event_sink->write(sizeof(n), &n) != sizeof(n)) {
_engine.log().error("Error writing header to notification ring\n");
- } else if (_event_sink.write(size, body) != size) {
+ } else if (_event_sink->write(size, body) != size) {
_engine.log().error("Error writing body to notification ring\n");
} else {
return true;
@@ -86,17 +108,17 @@ void
Context::emit_notifications(FrameTime end)
{
const URIs& uris = _engine.buffer_factory()->uris();
- const uint32_t read_space = _event_sink.read_space();
+ const uint32_t read_space = _event_sink->read_space();
Notification note;
for (uint32_t i = 0; i < read_space; i += sizeof(note)) {
- if (_event_sink.peek(sizeof(note), &note) != sizeof(note) ||
+ if (_event_sink->peek(sizeof(note), &note) != sizeof(note) ||
note.time >= end) {
return;
}
- if (_event_sink.read(sizeof(note), &note) == sizeof(note)) {
+ if (_event_sink->read(sizeof(note), &note) == sizeof(note)) {
Atom value = _engine.world()->forge().alloc(
note.size, note.type, NULL);
- if (_event_sink.read(note.size, value.get_body()) == note.size) {
+ if (_event_sink->read(note.size, value.get_body()) == note.size) {
i += note.size;
const char* key = _engine.world()->uri_map().unmap_uri(note.key);
if (key) {