From 7f24f7c5f62eb03e99b2ce812022f2fa3cdf05e6 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 12 Aug 2012 03:52:29 +0000 Subject: Fix notifications when running as LV2. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4665 a436a847-0d15-0410-975c-d299462d15a1 --- src/server/Context.hpp | 3 +++ src/server/PostProcessor.cpp | 8 +++++++- src/server/PostProcessor.hpp | 3 +++ src/server/ingen_lv2.cpp | 3 ++- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/server/Context.hpp b/src/server/Context.hpp index 62bcfba9..b5941dfc 100644 --- a/src/server/Context.hpp +++ b/src/server/Context.hpp @@ -64,6 +64,9 @@ public: /** Emit pending notifications in some other non-realtime thread. */ void emit_notifications(FrameTime end); + /** Return true iff any notifications are pending. */ + bool pending_notifications() const { return _event_sink.read_space(); } + inline ID id() const { return _id; } inline void locate(FrameTime s, SampleCount nframes) { diff --git a/src/server/PostProcessor.cpp b/src/server/PostProcessor.cpp index 92d49d43..74493b51 100644 --- a/src/server/PostProcessor.cpp +++ b/src/server/PostProcessor.cpp @@ -51,10 +51,16 @@ PostProcessor::append(ProcessContext& context, Event* first, Event* last) } } +bool +PostProcessor::pending() const +{ + return _head.get() || _engine.process_context().pending_notifications(); +} + void PostProcessor::process() { - const FrameTime end_time = _max_time.get() + 1; + const FrameTime end_time = _max_time.get(); // To avoid a race, we only process up to tail and never write to _tail Event* const tail = _tail.get(); diff --git a/src/server/PostProcessor.hpp b/src/server/PostProcessor.hpp index 31f49ad4..2bd6036f 100644 --- a/src/server/PostProcessor.hpp +++ b/src/server/PostProcessor.hpp @@ -54,6 +54,9 @@ public: /** Post-process and delete all pending events */ void process(); + /** Return true iff any events are pending */ + bool pending() const; + /** Set the latest event time that should be post-processed */ void set_end_time(FrameTime time) { _max_time = time; } diff --git a/src/server/ingen_lv2.cpp b/src/server/ingen_lv2.cpp index 43b8503d..2f845dd2 100644 --- a/src/server/ingen_lv2.cpp +++ b/src/server/ingen_lv2.cpp @@ -187,7 +187,8 @@ public: for (Ports::iterator i = _ports.begin(); i != _ports.end(); ++i) (*i)->pre_process(_engine.process_context()); - if (_engine.run(nframes) > 0) { + _engine.run(nframes); + if (_engine.post_processor()->pending()) { _main_sem.post(); } -- cgit v1.2.1