From 769fd5a2c60ef39f0af68664b35c99f90b8d715b Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 20 Aug 2011 20:59:48 +0000 Subject: Fix crash when sending port notifications (fix #741). Use a simpler system for port change notifications (abusing Event, which is virtual and thus can't be ringbuffered safely, was the cause of this crash). git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@3438 a436a847-0d15-0410-975c-d299462d15a1 --- src/server/Context.hpp | 11 +++-- src/server/ControlBindings.cpp | 14 +++--- src/server/Notification.cpp | 86 ++++++++++++++++++++++++++++++++++ src/server/Notification.hpp | 60 ++++++++++++++++++++++++ src/server/PortImpl.cpp | 23 +++++---- src/server/PortImpl.hpp | 7 ++- src/server/PostProcessor.cpp | 16 +++---- src/server/PostProcessor.hpp | 2 - src/server/events/SendBinding.cpp | 55 ---------------------- src/server/events/SendBinding.hpp | 86 ---------------------------------- src/server/events/SendPortActivity.cpp | 36 -------------- src/server/events/SendPortActivity.hpp | 69 --------------------------- src/server/events/SendPortValue.cpp | 42 ----------------- src/server/events/SendPortValue.hpp | 82 -------------------------------- src/server/internals/Controller.cpp | 11 +++-- src/server/wscript | 4 +- 16 files changed, 195 insertions(+), 409 deletions(-) create mode 100644 src/server/Notification.cpp create mode 100644 src/server/Notification.hpp delete mode 100644 src/server/events/SendBinding.cpp delete mode 100644 src/server/events/SendBinding.hpp delete mode 100644 src/server/events/SendPortActivity.cpp delete mode 100644 src/server/events/SendPortActivity.hpp delete mode 100644 src/server/events/SendPortValue.cpp delete mode 100644 src/server/events/SendPortValue.hpp diff --git a/src/server/Context.hpp b/src/server/Context.hpp index d2d1b11f..f30b11d5 100644 --- a/src/server/Context.hpp +++ b/src/server/Context.hpp @@ -18,6 +18,8 @@ #ifndef INGEN_ENGINE_CONTEXT_HPP #define INGEN_ENGINE_CONTEXT_HPP +#include "raul/RingBuffer.hpp" + #include "shared/World.hpp" #include "Engine.hpp" @@ -52,7 +54,7 @@ public: Context(Engine& engine, ID id) : _engine(engine) , _id(id) - , _event_sink(engine, engine.event_queue_size()) + , _event_sink(engine.event_queue_size()) , _start(0) , _end(0) , _nframes(0) @@ -85,14 +87,15 @@ public: inline SampleCount offset() const { return _offset; } inline bool realtime() const { return _realtime; } - inline const EventSink& event_sink() const { return _event_sink; } - inline EventSink& event_sink() { return _event_sink; } + inline const Raul::RingBuffer & event_sink() const { return _event_sink; } + inline Raul::RingBuffer& event_sink() { return _event_sink; } protected: Engine& _engine; ///< Engine we're running in ID _id; ///< Fast ID for this context - EventSink _event_sink; ///< Sink for events generated in a realtime context + Raul::RingBuffer _event_sink; ///< Port updates from process context + FrameTime _start; ///< Start frame of this cycle, timeline relative FrameTime _end; ///< End frame of this cycle, timeline relative SampleCount _nframes; ///< Length of this cycle in frames diff --git a/src/server/ControlBindings.cpp b/src/server/ControlBindings.cpp index 6c2cf09c..44a22f98 100644 --- a/src/server/ControlBindings.cpp +++ b/src/server/ControlBindings.cpp @@ -20,12 +20,12 @@ #include "raul/midi_events.h" #include "shared/LV2URIMap.hpp" #include "shared/World.hpp" -#include "events/SendPortValue.hpp" -#include "events/SendBinding.hpp" + #include "AudioBuffer.hpp" #include "ControlBindings.hpp" #include "Engine.hpp" #include "EventBuffer.hpp" +#include "Notification.hpp" #include "PortImpl.hpp" #include "ProcessContext.hpp" #include "ThreadManager.hpp" @@ -247,8 +247,9 @@ ControlBindings::set_port_value(ProcessContext& context, PortImpl* port, Type ty reinterpret_cast(port->buffer(v).get())->set_value( port_value.get_float(), context.start(), context.start()); - const Events::SendPortValue ev(context.engine(), context.start(), port, true, 0, port_value); - context.event_sink().write(sizeof(ev), &ev); + const Notification note(Notification::PORT_VALUE, + context.start(), port, port_value); + context.event_sink().write(sizeof(note), ¬e); } bool @@ -264,8 +265,9 @@ ControlBindings::bind(ProcessContext& context, Key key) _bindings->insert(make_pair(key, _learn_port)); - const Events::SendBinding ev(context.engine(), context.start(), _learn_port, key.type, key.num); - context.event_sink().write(sizeof(ev), &ev); + // FIXME + //const Events::SendBinding ev(context.engine(), context.start(), _learn_port, key.type, key.num); + //context.event_sink().write(sizeof(ev), &ev); _learn_port = NULL; return true; diff --git a/src/server/Notification.cpp b/src/server/Notification.cpp new file mode 100644 index 00000000..652662f2 --- /dev/null +++ b/src/server/Notification.cpp @@ -0,0 +1,86 @@ +/* This file is part of Ingen. + * Copyright 2011 David Robillard + * + * Ingen is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "shared/LV2URIMap.hpp" + +#include "ClientBroadcaster.hpp" +#include "Notification.hpp" +#include "PortImpl.hpp" + +namespace Ingen { +namespace Server { + +Notification::Notification(Type y, + FrameTime t, + PortImpl* p, + const Raul::Atom& v, + const ControlBindings::Type bt) + : type(y) + , binding_type(bt) + , time(t) + , port(p) + , value(v) +{} + +void +Notification::post_process(Engine& engine) +{ + switch (type) { + case PORT_VALUE: + engine.broadcaster()->set_property( + port->path(), + engine.world()->uris()->ingen_value, value); + break; + case PORT_ACTIVITY: + engine.broadcaster()->activity(port->path()); + break; + case PORT_BINDING: { + const Ingen::Shared::LV2URIMap& uris = *engine.world()->uris().get(); + Raul::Atom::DictValue dict; + switch (binding_type) { + case ControlBindings::MIDI_CC: + dict[uris.rdf_type] = uris.midi_Controller; + dict[uris.midi_controllerNumber] = value.get_int32(); + break; + case ControlBindings::MIDI_BENDER: + dict[uris.rdf_type] = uris.midi_Bender; + break; + case ControlBindings::MIDI_CHANNEL_PRESSURE: + dict[uris.rdf_type] = uris.midi_ChannelPressure; + break; + case ControlBindings::MIDI_NOTE: + dict[uris.rdf_type] = uris.midi_Note; + dict[uris.midi_noteNumber] = value.get_int32(); + break; + case ControlBindings::MIDI_RPN: // TODO + case ControlBindings::MIDI_NRPN: // TODO + case ControlBindings::NULL_CONTROL: + break; + } + port->set_property(uris.ingen_controlBinding, dict); // FIXME: thread unsafe + engine.broadcaster()->set_property(port->path(), + uris.ingen_controlBinding, + dict); + break; + } + case NIL: + break; + } +} + +} // namespace Server +} // namespace Ingen diff --git a/src/server/Notification.hpp b/src/server/Notification.hpp new file mode 100644 index 00000000..f6824318 --- /dev/null +++ b/src/server/Notification.hpp @@ -0,0 +1,60 @@ +/* This file is part of Ingen. + * Copyright 2007-2011 David Robillard + * + * Ingen is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef INGEN_ENGINE_NOTIFICATION_HPP +#define INGEN_ENGINE_NOTIFICATION_HPP + +#include "raul/Atom.hpp" + +#include "ControlBindings.hpp" +#include "types.hpp" + +namespace Ingen { +namespace Server { + +class Engine; +class PortImpl; + +struct Notification +{ + enum Type { + NIL, + PORT_VALUE, + PORT_ACTIVITY, + PORT_BINDING + }; + + Notification( + Type type = NIL, + FrameTime time = 0, + PortImpl* port = 0, + const Raul::Atom& value = Raul::Atom(), + const ControlBindings::Type btype = ControlBindings::NULL_CONTROL); + + void post_process(Engine& engine); + + Type type; + const ControlBindings::Type binding_type; + FrameTime time; + PortImpl* port; + const Raul::Atom value; +}; + +} // namespace Server +} // namespace Ingen + +#endif // INGEN_ENGINE_NOTIFICATION_HPP diff --git a/src/server/PortImpl.cpp b/src/server/PortImpl.cpp index a448916e..d7b7e569 100644 --- a/src/server/PortImpl.cpp +++ b/src/server/PortImpl.cpp @@ -15,19 +15,22 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "lv2/lv2plug.in/ns/ext/contexts/contexts.h" + #include "raul/Array.hpp" #include "raul/Maid.hpp" + #include "shared/LV2URIMap.hpp" -#include "lv2/lv2plug.in/ns/ext/contexts/contexts.h" + #include "ingen/PortType.hpp" -#include "events/SendPortValue.hpp" -#include "events/SendPortActivity.hpp" + #include "AudioBuffer.hpp" #include "BufferFactory.hpp" #include "Engine.hpp" #include "EventBuffer.hpp" #include "LV2Atom.hpp" #include "NodeImpl.hpp" +#include "Notification.hpp" #include "ObjectBuffer.hpp" #include "PortImpl.hpp" #include "ThreadManager.hpp" @@ -208,20 +211,24 @@ PortImpl::broadcast_value(Context& context, bool force) break; case PortType::EVENTS: if (((EventBuffer*)buffer(0).get())->event_count() > 0) { - const Events::SendPortActivity ev(context.engine(), context.start(), this); - context.event_sink().write(sizeof(ev), &ev); + const Notification note(Notification::PORT_ACTIVITY, + context.start(), this, Atom(true)); + context.event_sink().write(sizeof(note), ¬e); } break; case PortType::VALUE: case PortType::MESSAGE: - Ingen::Shared::LV2Atom::to_atom(_bufs.uris(), ((ObjectBuffer*)buffer(0).get())->atom(), val); + Ingen::Shared::LV2Atom::to_atom(_bufs.uris(), + ((ObjectBuffer*)buffer(0).get())->atom(), + val); break; } if (val.is_valid() && (force || val != _last_broadcasted_value)) { _last_broadcasted_value = val; - const Events::SendPortValue ev(context.engine(), context.start(), this, true, 0, val); - context.event_sink().write(sizeof(ev), &ev); + const Notification note(Notification::PORT_VALUE, + context.start(), this, val); + context.event_sink().write(sizeof(note), ¬e); } } diff --git a/src/server/PortImpl.hpp b/src/server/PortImpl.hpp index b3621f13..4bd52d88 100644 --- a/src/server/PortImpl.hpp +++ b/src/server/PortImpl.hpp @@ -21,14 +21,17 @@ #include #include #include + #include "raul/Array.hpp" #include "raul/Atom.hpp" + #include "ingen/Port.hpp" -#include "types.hpp" -#include "GraphObjectImpl.hpp" #include "ingen/PortType.hpp" + #include "Buffer.hpp" #include "Context.hpp" +#include "GraphObjectImpl.hpp" +#include "types.hpp" namespace Raul { class Maid; } diff --git a/src/server/PostProcessor.cpp b/src/server/PostProcessor.cpp index 3364322a..7c756812 100644 --- a/src/server/PostProcessor.cpp +++ b/src/server/PostProcessor.cpp @@ -21,10 +21,10 @@ #include "Driver.hpp" #include "Engine.hpp" +#include "Notification.hpp" #include "PostProcessor.hpp" #include "ProcessContext.hpp" #include "QueuedEvent.hpp" -#include "events/SendPortValue.hpp" using namespace std; using namespace Raul; @@ -35,14 +35,11 @@ namespace Server { PostProcessor::PostProcessor(Engine& engine) : _engine(engine) , _max_time(0) - , _event_buffer_size(sizeof(Events::SendPortValue)) // FIXME: make generic - , _event_buffer((uint8_t*)malloc(_event_buffer_size)) { } PostProcessor::~PostProcessor() { - free(_event_buffer); } void @@ -76,13 +73,14 @@ PostProcessor::process() /* Process audio thread generated events */ while (true) { Driver* driver = _engine.driver(); - if (driver && driver->context().event_sink().read(_event_buffer_size, _event_buffer)) { - if (((Event*)_event_buffer)->time() > end_time) { - warn << "Lost event with time " - << ((Event*)_event_buffer)->time() << " > " << end_time << endl; + Notification note; + if (driver && driver->context().event_sink().peek(sizeof(note), ¬e)) { + if (note.time > end_time) { break; } - ((Event*)_event_buffer)->post_process(); + + note.post_process(_engine); + driver->context().event_sink().skip(sizeof(note)); } else { break; } diff --git a/src/server/PostProcessor.hpp b/src/server/PostProcessor.hpp index 9cf8ea06..9b2ca037 100644 --- a/src/server/PostProcessor.hpp +++ b/src/server/PostProcessor.hpp @@ -62,8 +62,6 @@ private: Raul::AtomicPtr _head; Raul::AtomicPtr _tail; Raul::AtomicInt _max_time; - uint32_t _event_buffer_size; - uint8_t* _event_buffer; }; } // namespace Server diff --git a/src/server/events/SendBinding.cpp b/src/server/events/SendBinding.cpp deleted file mode 100644 index ebfa21dd..00000000 --- a/src/server/events/SendBinding.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* This file is part of Ingen. - * Copyright 2007-2011 David Robillard - * - * Ingen is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -#include "events/SendBinding.hpp" -#include "shared/LV2URIMap.hpp" -#include "Engine.hpp" -#include "PortImpl.hpp" -#include "ClientBroadcaster.hpp" - -using namespace std; - -namespace Ingen { -namespace Server { -namespace Events { - -void -SendBinding::post_process() -{ - const Ingen::Shared::LV2URIMap& uris = *_engine.world()->uris().get(); - Raul::Atom::DictValue dict; - if (_type == ControlBindings::MIDI_CC) { - dict[uris.rdf_type] = uris.midi_Controller; - dict[uris.midi_controllerNumber] = _num; - } else if (_type == ControlBindings::MIDI_BENDER) { - dict[uris.rdf_type] = uris.midi_Bender; - } else if (_type == ControlBindings::MIDI_CHANNEL_PRESSURE) { - dict[uris.rdf_type] = uris.midi_ChannelPressure; - } else if (_type == ControlBindings::MIDI_NOTE) { - dict[uris.rdf_type] = uris.midi_Note; - dict[uris.midi_noteNumber] = _num; - } - // TODO: other event types - _port->set_property(uris.ingen_controlBinding, dict); // FIXME: thread unsafe - _engine.broadcaster()->set_property(_port->path(), uris.ingen_controlBinding, dict); -} - -} // namespace Server -} // namespace Ingen -} // namespace Events - diff --git a/src/server/events/SendBinding.hpp b/src/server/events/SendBinding.hpp deleted file mode 100644 index f3727ece..00000000 --- a/src/server/events/SendBinding.hpp +++ /dev/null @@ -1,86 +0,0 @@ -/* This file is part of Ingen. - * Copyright 2007-2011 David Robillard - * - * Ingen is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef INGEN_EVENTS_SENDBINDING_HPP -#define INGEN_EVENTS_SENDBINDING_HPP - -#include "server/Event.hpp" -#include "server/ControlBindings.hpp" -#include "server/types.hpp" - -namespace Ingen { -namespace Server { - -class PortImpl; - -namespace Events { - -/** A special event used internally to send control bindings from the audio thread. - * - * See SendPortValue documentation for details. - * - * \ingroup engine - */ -class SendBinding : public Event -{ -public: - inline SendBinding( - Engine& engine, - SampleCount timestamp, - PortImpl* port, - ControlBindings::Type type, - int16_t num) - : Event(engine, SharedPtr(), timestamp) - , _port(port) - , _type(type) - , _num(num) - { - assert(_port); - switch (type) { - case ControlBindings::MIDI_CC: - assert(num >= 0 && num < 128); - break; - case ControlBindings::MIDI_RPN: - assert(num >= 0 && num < 16384); - break; - case ControlBindings::MIDI_NRPN: - assert(num >= 0 && num < 16384); - default: - break; - } - } - - inline SendBinding& operator=(const SendBinding& ev) { - _port = ev._port; - _type = ev._type; - _num = ev._num; - return *this; - } - - void post_process(); - -private: - PortImpl* _port; - ControlBindings::Type _type; - int16_t _num; -}; - -} // namespace Server -} // namespace Ingen -} // namespace Events - -#endif // INGEN_EVENTS_SENDBINDING_HPP diff --git a/src/server/events/SendPortActivity.cpp b/src/server/events/SendPortActivity.cpp deleted file mode 100644 index 8ff960e2..00000000 --- a/src/server/events/SendPortActivity.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* This file is part of Ingen. - * Copyright 2007-2011 David Robillard - * - * Ingen is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "events/SendPortActivity.hpp" -#include "Engine.hpp" -#include "PortImpl.hpp" -#include "ClientBroadcaster.hpp" - -namespace Ingen { -namespace Server { -namespace Events { - -void -SendPortActivity::post_process() -{ - _engine.broadcaster()->activity(_port->path()); -} - -} // namespace Server -} // namespace Ingen -} // namespace Events - diff --git a/src/server/events/SendPortActivity.hpp b/src/server/events/SendPortActivity.hpp deleted file mode 100644 index dd74a68a..00000000 --- a/src/server/events/SendPortActivity.hpp +++ /dev/null @@ -1,69 +0,0 @@ -/* This file is part of Ingen. - * Copyright 2007-2011 David Robillard - * - * Ingen is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef INGEN_EVENTS_SENDPORTACTIVITY_HPP -#define INGEN_EVENTS_SENDPORTACTIVITY_HPP - -#include "Event.hpp" -#include "types.hpp" - -namespace Ingen { -namespace Server { - -class PortImpl; - -namespace Events { - -/** A special event used internally to send port activity notification (e.g. - * MIDI event activity) from the audio thread. - * - * This is created in the audio thread (directly in a ringbuffer, not new'd) - * for processing in the post processing thread (unlike normal events which - * are created in the pre-processor thread then run through the audio - * thread). This event's job is done entirely in post_process. - * - * This only really makes sense for message ports. - * - * \ingroup engine - */ -class SendPortActivity : public Event -{ -public: - inline SendPortActivity(Engine& engine, - SampleCount timestamp, - PortImpl* port) - : Event(engine, SharedPtr(), timestamp) - , _port(port) - { - } - - inline SendPortActivity& operator=(const SendPortActivity& ev) { - _port = ev._port; - return *this; - } - - void post_process(); - -private: - PortImpl* _port; -}; - -} // namespace Server -} // namespace Ingen -} // namespace Events - -#endif // INGEN_EVENTS_SENDPORTACTIVITY_HPP diff --git a/src/server/events/SendPortValue.cpp b/src/server/events/SendPortValue.cpp deleted file mode 100644 index 1364b692..00000000 --- a/src/server/events/SendPortValue.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* This file is part of Ingen. - * Copyright 2007-2011 David Robillard - * - * Ingen is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -#include "events/SendPortValue.hpp" -#include "shared/LV2URIMap.hpp" -#include "Engine.hpp" -#include "PortImpl.hpp" -#include "ClientBroadcaster.hpp" - -using namespace std; - -namespace Ingen { -namespace Server { -namespace Events { - -void -SendPortValue::post_process() -{ - _engine.broadcaster()->set_property( - _port->path(), - _engine.world()->uris()->ingen_value, _value); -} - -} // namespace Server -} // namespace Ingen -} // namespace Events - diff --git a/src/server/events/SendPortValue.hpp b/src/server/events/SendPortValue.hpp deleted file mode 100644 index 4465ef00..00000000 --- a/src/server/events/SendPortValue.hpp +++ /dev/null @@ -1,82 +0,0 @@ -/* This file is part of Ingen. - * Copyright 2007-2011 David Robillard - * - * Ingen is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef INGEN_EVENTS_SENDPORTVALUE_HPP -#define INGEN_EVENTS_SENDPORTVALUE_HPP - -#include "raul/Atom.hpp" -#include "server/Event.hpp" -#include "server/types.hpp" - -namespace Ingen { -namespace Server { - -class PortImpl; - -namespace Events { - -/** A special event used internally to send port values from the audio thread. - * - * This is created in the audio thread (using in-place new on a preallocated - * buffer) for processing in the post processing thread (unlike normal events - * which are created in the pre-processor thread then run through the audio - * thread). This event's job is done entirely in post_process. - * - * This only works for control ports right now. - * - * \ingroup engine - */ -class SendPortValue : public Event -{ -public: - inline SendPortValue( - Engine& engine, - SampleCount timestamp, - PortImpl* port, - bool omni, - uint32_t voice_num, - const Raul::Atom& value) - : Event(engine, SharedPtr(), timestamp) - , _port(port) - , _omni(omni) - , _voice_num(voice_num) - , _value(value) - { - } - - inline SendPortValue& operator=(const SendPortValue& ev) { - _port = ev._port; - _omni = ev._omni; - _voice_num = ev._voice_num; - _value = ev._value; - return *this; - } - - void post_process(); - -private: - PortImpl* _port; - bool _omni; - uint32_t _voice_num; - Raul::Atom _value; -}; - -} // namespace Server -} // namespace Ingen -} // namespace Events - -#endif // INGEN_EVENTS_SENDPORTVALUE_HPP diff --git a/src/server/internals/Controller.cpp b/src/server/internals/Controller.cpp index 3d477de6..bdf8e607 100644 --- a/src/server/internals/Controller.cpp +++ b/src/server/internals/Controller.cpp @@ -19,14 +19,15 @@ #include "raul/midi_events.h" #include "shared/LV2URIMap.hpp" #include "internals/Controller.hpp" -#include "PostProcessor.hpp" -#include "events/SendPortValue.hpp" + +#include "AudioBuffer.hpp" +#include "EventBuffer.hpp" #include "InputPort.hpp" -#include "OutputPort.hpp" #include "InternalPlugin.hpp" -#include "AudioBuffer.hpp" +#include "Notification.hpp" +#include "OutputPort.hpp" +#include "PostProcessor.hpp" #include "ProcessContext.hpp" -#include "EventBuffer.hpp" #include "util.hpp" using namespace std; diff --git a/src/server/wscript b/src/server/wscript index 79a3e6e7..287debaf 100644 --- a/src/server/wscript +++ b/src/server/wscript @@ -24,6 +24,7 @@ def build(bld): MessageContext.cpp NodeFactory.cpp NodeImpl.cpp + Notification.cpp ObjectBuffer.cpp ObjectSender.cpp OutputPort.cpp @@ -46,9 +47,6 @@ def build(bld): events/Move.cpp events/RegisterClient.cpp events/RequestMetadata.cpp - events/SendBinding.cpp - events/SendPortActivity.cpp - events/SendPortValue.cpp events/SetMetadata.cpp events/SetPortValue.cpp events/UnregisterClient.cpp -- cgit v1.2.1