diff options
-rw-r--r-- | src/server/EventQueue.cpp | 2 | ||||
-rw-r--r-- | src/server/EventQueue.hpp | 4 | ||||
-rw-r--r-- | src/server/EventSink.hpp | 37 | ||||
-rw-r--r-- | src/server/EventSource.hpp | 47 | ||||
-rw-r--r-- | src/server/ServerInterfaceImpl.cpp | 22 | ||||
-rw-r--r-- | src/socket/SocketListener.cpp | 2 |
6 files changed, 100 insertions, 14 deletions
diff --git a/src/server/EventQueue.cpp b/src/server/EventQueue.cpp index ffafe17a..8cb979ca 100644 --- a/src/server/EventQueue.cpp +++ b/src/server/EventQueue.cpp @@ -39,7 +39,7 @@ EventQueue::~EventQueue() /** Push an unprepared event onto the queue. */ void -EventQueue::push_queued(Event* const ev) +EventQueue::event(Event* const ev) { assert(!ev->is_prepared()); assert(!ev->next()); diff --git a/src/server/EventQueue.hpp b/src/server/EventQueue.hpp index e1adbd6b..a3567574 100644 --- a/src/server/EventQueue.hpp +++ b/src/server/EventQueue.hpp @@ -20,6 +20,7 @@ #include "raul/AtomicPtr.hpp" #include "raul/Slave.hpp" +#include "EventSink.hpp" #include "EventSource.hpp" namespace Ingen { @@ -32,6 +33,7 @@ class ProcessContext; /** An EventSource which prepares events in its own thread. */ class EventQueue : public EventSource + , public EventSink , public Raul::Slave { public: @@ -44,7 +46,7 @@ public: inline bool empty() const { return !_head.get(); } protected: - void push_queued(Event* const ev); + void event(Event* ev); virtual void _whipped(); ///< Prepare 1 event diff --git a/src/server/EventSink.hpp b/src/server/EventSink.hpp new file mode 100644 index 00000000..e24fa5e9 --- /dev/null +++ b/src/server/EventSink.hpp @@ -0,0 +1,37 @@ +/* + 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/>. +*/ + +#ifndef INGEN_ENGINE_EVENTSINK_HPP +#define INGEN_ENGINE_EVENTSINK_HPP + +namespace Ingen { +namespace Server { + +class Event; + +class EventSink +{ +public: + virtual ~EventSink() {} + + virtual void event(Event* ev) = 0; +}; + +} // namespace Server +} // namespace Ingen + +#endif // INGEN_ENGINE_EVENTSINK_HPP + diff --git a/src/server/EventSource.hpp b/src/server/EventSource.hpp new file mode 100644 index 00000000..4425586d --- /dev/null +++ b/src/server/EventSource.hpp @@ -0,0 +1,47 @@ +/* + 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/>. +*/ + +#ifndef INGEN_ENGINE_EVENTSOURCE_HPP +#define INGEN_ENGINE_EVENTSOURCE_HPP + +namespace Ingen { +namespace Server { + +class Event; +class PostProcessor; +class ProcessContext; + +/** Source for events to run in the audio thread. + * + * The Driver gets events from an EventQueue in the process callback and + * executes them, then they are sent to the PostProcessor and finalised + * (post-processing thread). + */ +class EventSource +{ +public: + virtual ~EventSource() {} + + virtual void process(PostProcessor& dest, + ProcessContext& context, + bool limit = true) = 0; +}; + +} // namespace Server +} // namespace Ingen + +#endif // INGEN_ENGINE_EVENTSOURCE_HPP + diff --git a/src/server/ServerInterfaceImpl.cpp b/src/server/ServerInterfaceImpl.cpp index 492139ed..d3f151e7 100644 --- a/src/server/ServerInterfaceImpl.cpp +++ b/src/server/ServerInterfaceImpl.cpp @@ -94,7 +94,7 @@ ServerInterfaceImpl::put(const URI& uri, const Resource::Properties& properties, const Resource::Graph ctx) { - push_queued(new Events::SetMetadata(_engine, _request_client, _request_id, now(), true, ctx, uri, properties)); + event(new Events::SetMetadata(_engine, _request_client, _request_id, now(), true, ctx, uri, properties)); } void @@ -102,14 +102,14 @@ ServerInterfaceImpl::delta(const URI& uri, const Resource::Properties& remove, const Resource::Properties& add) { - push_queued(new Events::SetMetadata(_engine, _request_client, _request_id, now(), false, Resource::DEFAULT, uri, add, remove)); + event(new Events::SetMetadata(_engine, _request_client, _request_id, now(), false, Resource::DEFAULT, uri, add, remove)); } void ServerInterfaceImpl::move(const Path& old_path, const Path& new_path) { - push_queued(new Events::Move(_engine, _request_client, _request_id, now(), old_path, new_path)); + event(new Events::Move(_engine, _request_client, _request_id, now(), old_path, new_path)); } void @@ -121,7 +121,7 @@ ServerInterfaceImpl::del(const URI& uri) } _engine.quit(); } else { - push_queued(new Events::Delete(_engine, _request_client, _request_id, now(), uri)); + event(new Events::Delete(_engine, _request_client, _request_id, now(), uri)); } } @@ -129,7 +129,7 @@ void ServerInterfaceImpl::connect(const Path& tail_path, const Path& head_path) { - push_queued(new Events::Connect(_engine, _request_client, _request_id, now(), tail_path, head_path)); + event(new Events::Connect(_engine, _request_client, _request_id, now(), tail_path, head_path)); } @@ -143,7 +143,7 @@ ServerInterfaceImpl::disconnect(const Path& src, return; } - push_queued(new Events::Disconnect(_engine, _request_client, _request_id, now(), + event(new Events::Disconnect(_engine, _request_client, _request_id, now(), Path(src.str()), Path(dst.str()))); } @@ -151,7 +151,7 @@ void ServerInterfaceImpl::disconnect_all(const Path& patch_path, const Path& path) { - push_queued(new Events::DisconnectAll(_engine, _request_client, _request_id, now(), patch_path, path)); + event(new Events::DisconnectAll(_engine, _request_client, _request_id, now(), patch_path, path)); } void @@ -163,16 +163,16 @@ ServerInterfaceImpl::set_property(const URI& uri, && value.type() == _engine.world()->forge().Bool) { if (value.get_bool()) { _engine.activate(); - push_queued(new Events::Ping(_engine, _request_client, _request_id, now())); + event(new Events::Ping(_engine, _request_client, _request_id, now())); } else { - push_queued(new Events::Deactivate(_engine, _request_client, _request_id, now())); + event(new Events::Deactivate(_engine, _request_client, _request_id, now())); } } else { Resource::Properties remove; remove.insert(make_pair(predicate, _engine.world()->uris()->wildcard)); Resource::Properties add; add.insert(make_pair(predicate, value)); - push_queued(new Events::SetMetadata( + event(new Events::SetMetadata( _engine, _request_client, _request_id, now(), false, Resource::DEFAULT, uri, add, remove)); } @@ -183,7 +183,7 @@ ServerInterfaceImpl::set_property(const URI& uri, void ServerInterfaceImpl::get(const URI& uri) { - push_queued(new Events::Get(_engine, _request_client, _request_id, now(), uri)); + event(new Events::Get(_engine, _request_client, _request_id, now(), uri)); } } // namespace Server diff --git a/src/socket/SocketListener.cpp b/src/socket/SocketListener.cpp index ba427433..edd5421b 100644 --- a/src/socket/SocketListener.cpp +++ b/src/socket/SocketListener.cpp @@ -62,7 +62,7 @@ SocketListener::SocketListener(Ingen::Shared::World& world, LOG(Raul::error) << "Failed to listen on socket" << std::endl; } - LOG(Raul::info) << "Opened socket at " << _sock_path << std::endl; + LOG(Raul::info) << "Listening on socket at " << _sock_path << std::endl; start(); } |