diff options
author | David Robillard <d@drobilla.net> | 2010-01-07 01:34:42 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2010-01-07 01:34:42 +0000 |
commit | 10a5b76a65fb7ca7bf8c1f5869aaf763854e05a3 (patch) | |
tree | f93824399e791f218545109304500fe71686f0a3 /src/engine | |
parent | a6045e5dc58f2dd2ab9e3d3d19fd3eaf6d84216f (diff) | |
download | ingen-10a5b76a65fb7ca7bf8c1f5869aaf763854e05a3.tar.gz ingen-10a5b76a65fb7ca7bf8c1f5869aaf763854e05a3.tar.bz2 ingen-10a5b76a65fb7ca7bf8c1f5869aaf763854e05a3.zip |
Merge QueuedEventSource and EventSource.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2352 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/engine')
-rw-r--r-- | src/engine/Engine.cpp | 2 | ||||
-rw-r--r-- | src/engine/EventSource.cpp (renamed from src/engine/QueuedEventSource.cpp) | 17 | ||||
-rw-r--r-- | src/engine/EventSource.hpp | 46 | ||||
-rw-r--r-- | src/engine/HTTPEngineReceiver.cpp | 6 | ||||
-rw-r--r-- | src/engine/OSCEngineReceiver.cpp | 6 | ||||
-rw-r--r-- | src/engine/QueuedEngineInterface.cpp | 6 | ||||
-rw-r--r-- | src/engine/QueuedEngineInterface.hpp | 4 | ||||
-rw-r--r-- | src/engine/QueuedEvent.hpp | 6 | ||||
-rw-r--r-- | src/engine/QueuedEventSource.hpp | 78 | ||||
-rw-r--r-- | src/engine/events/CreatePort.cpp | 4 | ||||
-rw-r--r-- | src/engine/events/CreatePort.hpp | 2 | ||||
-rw-r--r-- | src/engine/events/Delete.cpp | 4 | ||||
-rw-r--r-- | src/engine/events/Delete.hpp | 2 | ||||
-rw-r--r-- | src/engine/events/LoadPlugins.cpp | 4 | ||||
-rw-r--r-- | src/engine/events/LoadPlugins.hpp | 2 | ||||
-rw-r--r-- | src/engine/events/SetMetadata.cpp | 4 | ||||
-rw-r--r-- | src/engine/events/SetMetadata.hpp | 2 | ||||
-rw-r--r-- | src/engine/wscript | 6 |
18 files changed, 69 insertions, 132 deletions
diff --git a/src/engine/Engine.cpp b/src/engine/Engine.cpp index bee2cec7..292a4e70 100644 --- a/src/engine/Engine.cpp +++ b/src/engine/Engine.cpp @@ -43,7 +43,7 @@ #include "ProcessContext.hpp" #include "ProcessSlave.hpp" #include "QueuedEngineInterface.hpp" -#include "QueuedEventSource.hpp" +#include "EventSource.hpp" #include "ThreadManager.hpp" #include "tuning.hpp" diff --git a/src/engine/QueuedEventSource.cpp b/src/engine/EventSource.cpp index 9fcd5711..0b8cb9dd 100644 --- a/src/engine/QueuedEventSource.cpp +++ b/src/engine/EventSource.cpp @@ -16,7 +16,7 @@ */ #include <sys/mman.h> -#include "QueuedEventSource.hpp" +#include "EventSource.hpp" #include "QueuedEvent.hpp" #include "PostProcessor.hpp" #include "ThreadManager.hpp" @@ -27,16 +27,16 @@ using namespace std; namespace Ingen { -QueuedEventSource::QueuedEventSource(size_t queue_size) +EventSource::EventSource(size_t queue_size) : _blocking_semaphore(0) { Thread::set_context(THREAD_PRE_PROCESS); assert(context() == THREAD_PRE_PROCESS); - set_name("QueuedEventSource"); + set_name("EventSource"); } -QueuedEventSource::~QueuedEventSource() +EventSource::~EventSource() { Thread::stop(); } @@ -45,7 +45,7 @@ QueuedEventSource::~QueuedEventSource() /** Push an unprepared event onto the queue. */ void -QueuedEventSource::push_queued(QueuedEvent* const ev) +EventSource::push_queued(QueuedEvent* const ev) { assert(!ev->is_prepared()); Raul::List<Event*>::Node* node = new Raul::List<Event*>::Node(ev); @@ -62,7 +62,7 @@ QueuedEventSource::push_queued(QueuedEvent* const ev) * Executed events will be pushed to @a dest. */ void -QueuedEventSource::process(PostProcessor& dest, ProcessContext& context) +EventSource::process(PostProcessor& dest, ProcessContext& context) { assert(ThreadManager::current_thread_id() == THREAD_PROCESS); @@ -96,12 +96,9 @@ QueuedEventSource::process(PostProcessor& dest, ProcessContext& context) } -// Private // - - /** Pre-process a single event */ void -QueuedEventSource::_whipped() +EventSource::_whipped() { Raul::List<Event*>::Node* pb = _prepared_back.get(); if (!pb) diff --git a/src/engine/EventSource.hpp b/src/engine/EventSource.hpp index 0db5c879..58d26ea8 100644 --- a/src/engine/EventSource.hpp +++ b/src/engine/EventSource.hpp @@ -15,8 +15,12 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef EVENTSOURCE_H -#define EVENTSOURCE_H +#ifndef INGEN_EVENT_SOURCE_HPP +#define INGEN_EVENT_SOURCE_HPP + +#include "raul/Semaphore.hpp" +#include "raul/Slave.hpp" +#include "raul/List.hpp" namespace Ingen { @@ -31,26 +35,40 @@ class ProcessContext; * The Driver gets events from an EventSource in the process callback * (realtime audio thread) and executes them, then they are sent to the * PostProcessor and finalised (post-processing thread). - * - * There are two distinct classes of events - "queued" and "stamped". Queued - * events are events that require non-realtime pre-processing before being - * executed in the process thread. Stamped events are timestamped realtime - * events that require no pre-processing and can be executed immediately - * (with sample accuracy). */ -class EventSource +class EventSource : protected Raul::Slave { public: - virtual ~EventSource() {} + EventSource(size_t queue_size); + ~EventSource(); + + void activate_source() { Slave::start(); } + void deactivate_source() { Slave::stop(); } + + void process(PostProcessor& dest, ProcessContext& context); + + /** Signal that a blocking event is finished. + * + * This MUST be called by blocking events in their post_process() method + * to resume pre-processing of events. + */ + inline void unblock() { _blocking_semaphore.post(); } + +protected: + void push_queued(QueuedEvent* const ev); + + inline bool unprepared_events() { return (_prepared_back.get() != NULL); } - virtual void activate_source() = 0; - virtual void deactivate_source() = 0; + virtual void _whipped(); ///< Prepare 1 event - virtual void process(PostProcessor& dest, ProcessContext& context) = 0; +private: + Raul::List<Event*> _events; + Raul::AtomicPtr<Raul::List<Event*>::Node> _prepared_back; + Raul::Semaphore _blocking_semaphore; }; } // namespace Ingen -#endif // EVENTSOURCE_H +#endif // INGEN_EVENT_SOURCE_HPP diff --git a/src/engine/HTTPEngineReceiver.cpp b/src/engine/HTTPEngineReceiver.cpp index 8cc39ddb..d28e1a24 100644 --- a/src/engine/HTTPEngineReceiver.cpp +++ b/src/engine/HTTPEngineReceiver.cpp @@ -31,7 +31,7 @@ #include "EngineStore.hpp" #include "HTTPClientSender.hpp" #include "HTTPEngineReceiver.hpp" -#include "QueuedEventSource.hpp" +#include "EventSource.hpp" #include "ThreadManager.hpp" using namespace std; @@ -78,7 +78,7 @@ HTTPEngineReceiver::~HTTPEngineReceiver() void HTTPEngineReceiver::activate_source() { - QueuedEventSource::activate_source(); + EventSource::activate_source(); _receive_thread->set_name("HTTP Receiver"); _receive_thread->start(); } @@ -88,7 +88,7 @@ void HTTPEngineReceiver::deactivate_source() { _receive_thread->stop(); - QueuedEventSource::deactivate_source(); + EventSource::deactivate_source(); } diff --git a/src/engine/OSCEngineReceiver.cpp b/src/engine/OSCEngineReceiver.cpp index d4b6e43e..e0b176bc 100644 --- a/src/engine/OSCEngineReceiver.cpp +++ b/src/engine/OSCEngineReceiver.cpp @@ -29,7 +29,7 @@ #include "Engine.hpp" #include "OSCClientSender.hpp" #include "OSCEngineReceiver.hpp" -#include "QueuedEventSource.hpp" +#include "EventSource.hpp" #include "ThreadManager.hpp" #define LOG(s) s << "[OSCEngineReceiver] " @@ -138,7 +138,7 @@ OSCEngineReceiver::~OSCEngineReceiver() void OSCEngineReceiver::activate_source() { - QueuedEventSource::activate_source(); + EventSource::activate_source(); _receive_thread->set_name("OSC Receiver"); _receive_thread->start(); _receive_thread->set_scheduling(SCHED_FIFO, 5); // Jack default appears to be 10 @@ -149,7 +149,7 @@ void OSCEngineReceiver::deactivate_source() { _receive_thread->stop(); - QueuedEventSource::deactivate_source(); + EventSource::deactivate_source(); } diff --git a/src/engine/QueuedEngineInterface.cpp b/src/engine/QueuedEngineInterface.cpp index ded0b5cf..8f5fdade 100644 --- a/src/engine/QueuedEngineInterface.cpp +++ b/src/engine/QueuedEngineInterface.cpp @@ -18,7 +18,7 @@ #include "raul/log.hpp" #include "QueuedEngineInterface.hpp" #include "tuning.hpp" -#include "QueuedEventSource.hpp" +#include "EventSource.hpp" #include "events.hpp" #include "Engine.hpp" #include "Driver.hpp" @@ -33,7 +33,7 @@ namespace Ingen { using namespace Shared; QueuedEngineInterface::QueuedEngineInterface(Engine& engine, size_t queue_size) - : QueuedEventSource(queue_size) + : EventSource(queue_size) , _responder(new Responder(NULL, 0)) , _engine(engine) , _in_bundle(false) @@ -113,7 +113,7 @@ QueuedEngineInterface::activate() in_activate = true; _engine.activate(); } - QueuedEventSource::activate_source(); + EventSource::activate_source(); push_queued(new Events::Ping(_engine, _responder, now())); in_activate = false; } diff --git a/src/engine/QueuedEngineInterface.hpp b/src/engine/QueuedEngineInterface.hpp index ef470e3e..04314c35 100644 --- a/src/engine/QueuedEngineInterface.hpp +++ b/src/engine/QueuedEngineInterface.hpp @@ -25,7 +25,7 @@ #include "interface/ClientInterface.hpp" #include "interface/EngineInterface.hpp" #include "interface/Resource.hpp" -#include "QueuedEventSource.hpp" +#include "EventSource.hpp" #include "Responder.hpp" #include "tuning.hpp" #include "types.hpp" @@ -45,7 +45,7 @@ class Engine; * If you do not register a responder, you have no way of knowing if your calls * are successful. */ -class QueuedEngineInterface : public QueuedEventSource, public Shared::EngineInterface +class QueuedEngineInterface : public EventSource, public Shared::EngineInterface { public: QueuedEngineInterface(Engine& engine, size_t queue_size); diff --git a/src/engine/QueuedEvent.hpp b/src/engine/QueuedEvent.hpp index 64a82304..f19c7b95 100644 --- a/src/engine/QueuedEvent.hpp +++ b/src/engine/QueuedEvent.hpp @@ -22,7 +22,7 @@ namespace Ingen { -class QueuedEventSource; +class EventSource; /** An Event with a not-time-critical preprocessing stage. @@ -57,7 +57,7 @@ protected: SharedPtr<Responder> responder, FrameTime time, bool blocking = false, - QueuedEventSource* source = NULL) + EventSource* source = NULL) : Event(engine, responder, time) , _source(source) , _pre_processed(false) @@ -75,7 +75,7 @@ protected: , _blocking(false) {} - QueuedEventSource* _source; + EventSource* _source; bool _pre_processed; bool _blocking; }; diff --git a/src/engine/QueuedEventSource.hpp b/src/engine/QueuedEventSource.hpp deleted file mode 100644 index 12b2300c..00000000 --- a/src/engine/QueuedEventSource.hpp +++ /dev/null @@ -1,78 +0,0 @@ -/* This file is part of Ingen. - * Copyright (C) 2008-2009 Dave Robillard <http://drobilla.net> - * - * 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_QUEUED_EVENT_SOURCE_HPP -#define INGEN_QUEUED_EVENT_SOURCE_HPP - -#include <cstdlib> -#include <pthread.h> -#include "raul/Semaphore.hpp" -#include "raul/Slave.hpp" -#include "raul/List.hpp" -#include "EventSource.hpp" - -namespace Ingen { - -class Event; -class QueuedEvent; -class PostProcessor; - - -/** Queue of events that need processing before reaching the audio thread. - * - * Implemented as a deque (ringbuffer) in a circular array. Pushing and - * popping are threadsafe, as long as a single thread pushes and a single - * thread pops (ie this data structure is threadsafe, but the push and pop - * methods themselves are not). Creating an instance of this class spawns - * a pre-processing thread to prepare queued events. - * - * This class is it's own slave. :) - */ -class QueuedEventSource : public EventSource, protected Raul::Slave -{ -public: - QueuedEventSource(size_t queue_size); - ~QueuedEventSource(); - - void activate_source() { Slave::start(); } - void deactivate_source() { Slave::stop(); } - - void process(PostProcessor& dest, ProcessContext& context); - - /** Signal that the blocking event is finished. - * When this is called preparing will resume. This MUST be called by - * blocking events in their post_process() method. */ - inline void unblock() { _blocking_semaphore.post(); } - -protected: - void push_queued(QueuedEvent* const ev); - - inline bool unprepared_events() { return (_prepared_back.get() != NULL); } - - virtual void _whipped(); ///< Prepare 1 event - -private: - Raul::List<Event*> _events; - Raul::AtomicPtr<Raul::List<Event*>::Node> _prepared_back; - Raul::Semaphore _blocking_semaphore; -}; - - -} // namespace Ingen - -#endif // INGEN_QUEUED_EVENT_SOURCE_HPP - diff --git a/src/engine/events/CreatePort.cpp b/src/engine/events/CreatePort.cpp index 299e60e9..7845994a 100644 --- a/src/engine/events/CreatePort.cpp +++ b/src/engine/events/CreatePort.cpp @@ -26,7 +26,7 @@ #include "PluginImpl.hpp" #include "Engine.hpp" #include "PatchImpl.hpp" -#include "QueuedEventSource.hpp" +#include "EventSource.hpp" #include "EngineStore.hpp" #include "ClientBroadcaster.hpp" #include "PortImpl.hpp" @@ -49,7 +49,7 @@ CreatePort::CreatePort( const Raul::Path& path, const Raul::URI& type, bool is_output, - QueuedEventSource* source, + EventSource* source, const Resource::Properties& properties) : QueuedEvent(engine, responder, timestamp, true, source) , _error(NO_ERROR) diff --git a/src/engine/events/CreatePort.hpp b/src/engine/events/CreatePort.hpp index af58fcfe..c7ddb56a 100644 --- a/src/engine/events/CreatePort.hpp +++ b/src/engine/events/CreatePort.hpp @@ -47,7 +47,7 @@ public: const Raul::Path& path, const Raul::URI& type, bool is_output, - QueuedEventSource* source, + EventSource* source, const Shared::Resource::Properties& properties); void pre_process(); diff --git a/src/engine/events/Delete.cpp b/src/engine/events/Delete.cpp index 62ddedf1..91e18dd0 100644 --- a/src/engine/events/Delete.cpp +++ b/src/engine/events/Delete.cpp @@ -27,7 +27,7 @@ #include "DisconnectAll.hpp" #include "ClientBroadcaster.hpp" #include "EngineStore.hpp" -#include "QueuedEventSource.hpp" +#include "EventSource.hpp" #include "PortImpl.hpp" using namespace std; @@ -38,7 +38,7 @@ namespace Events { using namespace Shared; -Delete::Delete(Engine& engine, SharedPtr<Responder> responder, FrameTime time, QueuedEventSource* source, const Raul::Path& path) +Delete::Delete(Engine& engine, SharedPtr<Responder> responder, FrameTime time, EventSource* source, const Raul::Path& path) : QueuedEvent(engine, responder, time, true, source) , _path(path) , _store_iterator(engine.engine_store()->end()) diff --git a/src/engine/events/Delete.hpp b/src/engine/events/Delete.hpp index a72dcc12..ac46030f 100644 --- a/src/engine/events/Delete.hpp +++ b/src/engine/events/Delete.hpp @@ -61,7 +61,7 @@ public: Engine& engine, SharedPtr<Responder> responder, FrameTime timestamp, - QueuedEventSource* source, + EventSource* source, const Raul::Path& path); ~Delete(); diff --git a/src/engine/events/LoadPlugins.cpp b/src/engine/events/LoadPlugins.cpp index e8ae8ce2..65043757 100644 --- a/src/engine/events/LoadPlugins.cpp +++ b/src/engine/events/LoadPlugins.cpp @@ -20,13 +20,13 @@ #include "Engine.hpp" #include "NodeFactory.hpp" #include "ClientBroadcaster.hpp" -#include "QueuedEventSource.hpp" +#include "EventSource.hpp" namespace Ingen { namespace Events { -LoadPlugins::LoadPlugins(Engine& engine, SharedPtr<Responder> responder, SampleCount timestamp, QueuedEventSource* source) +LoadPlugins::LoadPlugins(Engine& engine, SharedPtr<Responder> responder, SampleCount timestamp, EventSource* source) : QueuedEvent(engine, responder, timestamp, true, source) { } diff --git a/src/engine/events/LoadPlugins.hpp b/src/engine/events/LoadPlugins.hpp index 8dce2a27..3549fdfd 100644 --- a/src/engine/events/LoadPlugins.hpp +++ b/src/engine/events/LoadPlugins.hpp @@ -34,7 +34,7 @@ public: LoadPlugins(Engine& engine, SharedPtr<Responder> responder, SampleCount timestamp, - QueuedEventSource* source); + EventSource* source); void pre_process(); void post_process(); diff --git a/src/engine/events/SetMetadata.cpp b/src/engine/events/SetMetadata.cpp index 53e79977..6c8c25f3 100644 --- a/src/engine/events/SetMetadata.cpp +++ b/src/engine/events/SetMetadata.cpp @@ -29,7 +29,7 @@ #include "PatchImpl.hpp" #include "PluginImpl.hpp" #include "PortImpl.hpp" -#include "QueuedEventSource.hpp" +#include "EventSource.hpp" #include "Responder.hpp" #include "SetMetadata.hpp" #include "SetPortValue.hpp" @@ -48,7 +48,7 @@ SetMetadata::SetMetadata( Engine& engine, SharedPtr<Responder> responder, SampleCount timestamp, - QueuedEventSource* source, + EventSource* source, bool replace, bool meta, const URI& subject, diff --git a/src/engine/events/SetMetadata.hpp b/src/engine/events/SetMetadata.hpp index dc67d162..1417e02c 100644 --- a/src/engine/events/SetMetadata.hpp +++ b/src/engine/events/SetMetadata.hpp @@ -69,7 +69,7 @@ public: Engine& engine, SharedPtr<Responder> responder, SampleCount timestamp, - QueuedEventSource* source, + EventSource* source, bool replace, bool meta, const Raul::URI& subject, diff --git a/src/engine/wscript b/src/engine/wscript index 6e146d3c..2b98df26 100644 --- a/src/engine/wscript +++ b/src/engine/wscript @@ -16,6 +16,7 @@ def build(bld): Event.cpp EventBuffer.cpp EventSink.cpp + EventSource.cpp GraphObjectImpl.cpp InputPort.cpp InternalPlugin.cpp @@ -32,7 +33,6 @@ def build(bld): ProcessSlave.cpp QueuedEngineInterface.cpp QueuedEvent.cpp - QueuedEventSource.cpp events/AllNotesOff.cpp events/Connect.cpp events/CreateNode.cpp @@ -79,7 +79,7 @@ def build(bld): if bld.env['HAVE_SOUP'] == 1: obj = bld.new_task_gen('cxx', 'shlib') obj.source = ''' - QueuedEventSource.cpp + EventSource.cpp QueuedEngineInterface.cpp HTTPClientSender.cpp HTTPEngineReceiver.cpp @@ -94,7 +94,7 @@ def build(bld): if bld.env['HAVE_LIBLO'] == 1: obj = bld.new_task_gen('cxx', 'shlib') obj.source = ''' - QueuedEventSource.cpp + EventSource.cpp QueuedEngineInterface.cpp OSCClientSender.cpp OSCEngineReceiver.cpp |