From 5dcac50655a6635352e4542888e091bef515f865 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 17 Jul 2012 22:36:55 +0000 Subject: 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 --- src/server/Context.cpp | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/server/Context.cpp (limited to 'src/server/Context.cpp') 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 + + 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 . +*/ + +#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), ¬e) == sizeof(note)) { + Notification::post_process(note, _engine); + } + } +} + +} // namespace Server +} // namespace Ingen -- cgit v1.2.1