summaryrefslogtreecommitdiffstats
path: root/src/engine/MessageContext.hpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2009-11-22 03:06:25 +0000
committerDavid Robillard <d@drobilla.net>2009-11-22 03:06:25 +0000
commite479da3c26d41e977cf55b8e2355db45991be09f (patch)
treef6887a9b19eaee951dafd17fea8021556bff1169 /src/engine/MessageContext.hpp
parent58807f5840592959c31b415f7e2d64967594b5ee (diff)
downloadingen-e479da3c26d41e977cf55b8e2355db45991be09f.tar.gz
ingen-e479da3c26d41e977cf55b8e2355db45991be09f.tar.bz2
ingen-e479da3c26d41e977cf55b8e2355db45991be09f.zip
Partial support for message/value ports and the message context.
This use case now works: - Add an event input and the "print" plugin from imum.lv2 to ingen - Connect the event input to the input of "print" - Hook Ingen up to JACK and play some MIDI events (or get events to the print plugin from anywhere else) - The "print" plugin will print the received events to the console in the message context (i.e. the audio thread is realtime safe) git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2281 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/engine/MessageContext.hpp')
-rw-r--r--src/engine/MessageContext.hpp38
1 files changed, 36 insertions, 2 deletions
diff --git a/src/engine/MessageContext.hpp b/src/engine/MessageContext.hpp
index 9d17d920..c871ad1c 100644
--- a/src/engine/MessageContext.hpp
+++ b/src/engine/MessageContext.hpp
@@ -18,7 +18,14 @@
#ifndef MESSAGECONTEXT_H
#define MESSAGECONTEXT_H
+#include <glibmm/thread.h>
+#include "raul/Thread.hpp"
+#include "raul/Semaphore.hpp"
+#include "raul/AtomicPtr.hpp"
+#include "object.lv2/object.h"
#include "Context.hpp"
+#include "ThreadManager.hpp"
+#include "tuning.hpp"
namespace Ingen {
@@ -33,14 +40,41 @@ class NodeImpl;
*
* \ingroup engine
*/
-class MessageContext : public Context
+class MessageContext : public Context, public Raul::Thread
{
public:
MessageContext(Engine& engine)
: Context(engine, MESSAGE)
- {}
+ , Raul::Thread("message-context")
+ , _sem(0)
+ , _requests(message_context_queue_size)
+ {
+ Thread::set_context(THREAD_MESSAGE);
+ }
+ /** Request a run starting at node.
+ *
+ * Safe to call from either process thread or pre-process thread.
+ */
void run(NodeImpl* node);
+
+ inline void signal() { _sem.post(); }
+ inline bool has_requests() const {
+ return _requests.read_space() >= sizeof(NodeImpl*) || _request.get();
+ }
+
+protected:
+ /** Thread run method (wait for and execute requests from process thread */
+ void _run();
+
+ /** Actually execute and propagate from node */
+ void run_node(NodeImpl* node);
+
+ Raul::Semaphore _sem;
+ Raul::RingBuffer<NodeImpl*> _requests;
+ Glib::Mutex _mutex;
+ Glib::Cond _cond;
+ Raul::AtomicPtr<NodeImpl> _request;
};