summaryrefslogtreecommitdiffstats
path: root/src/server/Context.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-07-17 22:36:55 +0000
committerDavid Robillard <d@drobilla.net>2012-07-17 22:36:55 +0000
commit5dcac50655a6635352e4542888e091bef515f865 (patch)
tree915b19f606b4221768287f9ca5903d5f35d19317 /src/server/Context.cpp
parentc94231abbc601652e73423ec6e43a1e241024a17 (diff)
downloadingen-5dcac50655a6635352e4542888e091bef515f865.tar.gz
ingen-5dcac50655a6635352e4542888e091bef515f865.tar.bz2
ingen-5dcac50655a6635352e4542888e091bef515f865.zip
Wrap notification stuff behind simple API and hide details in Context.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4545 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/server/Context.cpp')
-rw-r--r--src/server/Context.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/server/Context.cpp b/src/server/Context.cpp
new file mode 100644
index 00000000..9979415b
--- /dev/null
+++ b/src/server/Context.cpp
@@ -0,0 +1,46 @@
+/*
+ This file is part of Ingen.
+ Copyright 2007-2012 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
+ Software Foundation, either version 3 of the License, or any later version.
+
+ Ingen is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Affero General Public License for details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with Ingen. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "Context.hpp"
+
+namespace Ingen {
+namespace Server {
+
+void
+Context::notify(Notification::Type type,
+ FrameTime time,
+ PortImpl* port,
+ const Raul::Atom& value,
+ const ControlBindings::Type btype)
+{
+ const Notification n = Notification::make(type, time, port, value, btype);
+ _event_sink.write(sizeof(n), &n);
+}
+
+void
+Context::emit_notifications()
+{
+ 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.read(sizeof(note), &note) == sizeof(note)) {
+ Notification::post_process(note, _engine);
+ }
+ }
+}
+
+} // namespace Server
+} // namespace Ingen