diff options
author | David Robillard <d@drobilla.net> | 2016-09-18 04:42:31 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2016-09-18 04:42:31 -0400 |
commit | ce6dc3d549bc58515d5d55db1d0a009a92887f3c (patch) | |
tree | 2cde2929903e30ec6272a79bd0877dd435aa83c2 /src/server | |
parent | 758543f6dbb56755d3239c0ed68f1083384f0e96 (diff) | |
download | ingen-ce6dc3d549bc58515d5d55db1d0a009a92887f3c.tar.gz ingen-ce6dc3d549bc58515d5d55db1d0a009a92887f3c.tar.bz2 ingen-ce6dc3d549bc58515d5d55db1d0a009a92887f3c.zip |
Add fancy communication logging
Diffstat (limited to 'src/server')
-rw-r--r-- | src/server/Engine.cpp | 21 | ||||
-rw-r--r-- | src/server/Engine.hpp | 40 | ||||
-rw-r--r-- | src/server/SocketServer.hpp | 25 | ||||
-rw-r--r-- | src/server/events/Delta.cpp | 22 | ||||
-rw-r--r-- | src/server/events/Undo.cpp | 4 | ||||
-rw-r--r-- | src/server/ingen_lv2.cpp | 4 |
6 files changed, 62 insertions, 54 deletions
diff --git a/src/server/Engine.cpp b/src/server/Engine.cpp index 8fa4d2f5..7baea132 100644 --- a/src/server/Engine.cpp +++ b/src/server/Engine.cpp @@ -28,6 +28,8 @@ #include "ingen/Configuration.hpp" #include "ingen/Log.hpp" #include "ingen/Store.hpp" +#include "ingen/StreamWriter.hpp" +#include "ingen/Tee.hpp" #include "ingen/URIs.hpp" #include "ingen/World.hpp" #include "ingen/types.hpp" @@ -69,7 +71,8 @@ Engine::Engine(Ingen::World* world) , _buffer_factory(new BufferFactory(*this, world->uris())) , _control_bindings(NULL) , _event_writer(new EventWriter(*this)) - , _atom_interface(new AtomReader(world->uri_map(), world->uris(), world->log(), *_event_writer)) + , _interface(_event_writer) + , _atom_interface(nullptr) , _maid(new Raul::Maid()) , _options(new LV2Options(world->uris())) , _undo_stack(new UndoStack(_world->uris(), _world->uri_map())) @@ -106,6 +109,21 @@ Engine::Engine(Ingen::World* world) _world->lv2_features().add_feature( SPtr<LV2Features::Feature>( new LV2Features::EmptyFeature(LV2_STATE__loadDefaultState))); + + if (world->conf().option("dump").get<int32_t>()) { + SPtr<Tee> tee(new Tee()); + SPtr<StreamWriter> dumper(new StreamWriter(world->uri_map(), + world->uris(), + Raul::URI("ingen:/engine"), + stderr, + ColorContext::Color::MAGENTA)); + tee->add_sink(_event_writer); + tee->add_sink(dumper); + _interface = tee; + } + + _atom_interface = new AtomReader( + world->uri_map(), world->uris(), world->log(), *_interface.get()); } Engine::~Engine() @@ -144,7 +162,6 @@ Engine::~Engine() delete _block_factory; delete _control_bindings; delete _broadcaster; - delete _event_writer; delete _worker; delete _maid; diff --git a/src/server/Engine.hpp b/src/server/Engine.hpp index 82cbcdfb..32f284e0 100644 --- a/src/server/Engine.hpp +++ b/src/server/Engine.hpp @@ -28,6 +28,7 @@ #include "Event.hpp" #include "RunContext.hpp" +#include "EventWriter.hpp" namespace Raul { class Maid; } @@ -44,7 +45,6 @@ class Broadcaster; class BufferFactory; class ControlBindings; class Driver; -class EventWriter; class GraphImpl; class LV2Options; class PostProcessor; @@ -98,7 +98,8 @@ public: Ingen::World* world() const { return _world; } - EventWriter* interface() const { return _event_writer; } + Interface* interface() const { return _interface.get(); } + EventWriter* event_writer() const { return _event_writer.get(); } AtomReader* atom_interface() const { return _atom_interface; } BlockFactory* block_factory() const { return _block_factory; } Broadcaster* broadcaster() const { return _broadcaster; } @@ -123,23 +124,24 @@ public: private: Ingen::World* _world; - BlockFactory* _block_factory; - Broadcaster* _broadcaster; - BufferFactory* _buffer_factory; - ControlBindings* _control_bindings; - SPtr<Driver> _driver; - EventWriter* _event_writer; - AtomReader* _atom_interface; - Raul::Maid* _maid; - SPtr<LV2Options> _options; - UndoStack* _undo_stack; - UndoStack* _redo_stack; - PreProcessor* _pre_processor; - PostProcessor* _post_processor; - GraphImpl* _root_graph; - Worker* _worker; - Worker* _sync_worker; - SocketListener* _listener; + BlockFactory* _block_factory; + Broadcaster* _broadcaster; + BufferFactory* _buffer_factory; + ControlBindings* _control_bindings; + SPtr<Driver> _driver; + SPtr<EventWriter> _event_writer; + SPtr<Interface> _interface; + AtomReader* _atom_interface; + Raul::Maid* _maid; + SPtr<LV2Options> _options; + UndoStack* _undo_stack; + UndoStack* _redo_stack; + PreProcessor* _pre_processor; + PostProcessor* _post_processor; + GraphImpl* _root_graph; + Worker* _worker; + Worker* _sync_worker; + SocketListener* _listener; RunContext _run_context; diff --git a/src/server/SocketServer.hpp b/src/server/SocketServer.hpp index fc9fdeae..6420020e 100644 --- a/src/server/SocketServer.hpp +++ b/src/server/SocketServer.hpp @@ -17,10 +17,11 @@ #ifndef INGEN_SERVER_SOCKET_SERVER_HPP #define INGEN_SERVER_SOCKET_SERVER_HPP -#include "raul/Socket.hpp" - #include "ingen/SocketReader.hpp" #include "ingen/SocketWriter.hpp" +#include "ingen/StreamWriter.hpp" +#include "ingen/Tee.hpp" +#include "raul/Socket.hpp" #include "EventWriter.hpp" @@ -28,21 +29,29 @@ namespace Ingen { namespace Server { /** The server side of an Ingen socket connection. */ -class SocketServer : public EventWriter, public SocketReader +class SocketServer { public: SocketServer(World& world, Server::Engine& engine, SPtr<Raul::Socket> sock) - : EventWriter(engine) - , SocketReader(world, *this, sock) - , _engine(engine) + : _engine(engine) + , _sink(world.conf().option("dump").get<int32_t>() + ? SPtr<Interface>( + new Tee({SPtr<Interface>(new EventWriter(engine)), + SPtr<Interface>(new StreamWriter(world.uri_map(), + world.uris(), + Raul::URI("ingen:/engine"), + stderr, + ColorContext::Color::CYAN))})) + : SPtr<Interface>(new EventWriter(engine))) + , _reader(new SocketReader(world, *_sink.get(), sock)) , _writer(new SocketWriter(world.uri_map(), world.uris(), sock->uri(), sock)) { - set_respondee(_writer); + _sink->set_respondee(_writer); engine.register_client(_writer); } @@ -60,6 +69,8 @@ protected: private: Server::Engine& _engine; + SPtr<Interface> _sink; + SPtr<SocketReader> _reader; SPtr<SocketWriter> _writer; }; diff --git a/src/server/events/Delta.cpp b/src/server/events/Delta.cpp index d54ec53f..49ea27ff 100644 --- a/src/server/events/Delta.cpp +++ b/src/server/events/Delta.cpp @@ -38,9 +38,6 @@ #include "SetPortValue.hpp" #include "events/Get.hpp" -// #define DUMP 1 -// #include "ingen/URIMap.hpp" - namespace Ingen { namespace Server { namespace Events { @@ -74,25 +71,6 @@ Delta::Delta(Engine& engine, p.second.set_context(context); } } - -#ifdef DUMP - std::cerr << "Delta " << subject << " : " << (int)context << " {" << std::endl; - typedef Resource::Properties::const_iterator iterator; - for (iterator i = properties.begin(); i != properties.end(); ++i) { - std::cerr << " + " << i->first - << " " << engine.world()->forge().str(i->second) - << "^^<" << engine.world()->uri_map().unmap_uri(i->second.type()) << ">" - << std::endl; - } - typedef Resource::Properties::const_iterator iterator; - for (iterator i = remove.begin(); i != remove.end(); ++i) { - std::cerr << " - " << i->first - << " " << engine.world()->forge().str(i->second) - << "^^<" << engine.world()->uri_map().unmap_uri(i->second.type()) << ">" - << std::endl; - } - std::cerr << "}" << std::endl; -#endif } Delta::~Delta() diff --git a/src/server/events/Undo.cpp b/src/server/events/Undo.cpp index 06289aa1..15c18ca2 100644 --- a/src/server/events/Undo.cpp +++ b/src/server/events/Undo.cpp @@ -44,7 +44,7 @@ Undo::pre_process() } _entry = stack->pop(); - _engine.interface()->set_event_mode(mode); + _engine.event_writer()->set_event_mode(mode); if (_entry.events.size() > 1) { _engine.interface()->bundle_begin(); } @@ -56,7 +56,7 @@ Undo::pre_process() if (_entry.events.size() > 1) { _engine.interface()->bundle_end(); } - _engine.interface()->set_event_mode(mode); + _engine.event_writer()->set_event_mode(mode); return Event::pre_process_done(Status::SUCCESS); } diff --git a/src/server/ingen_lv2.cpp b/src/server/ingen_lv2.cpp index 53d302b1..0c32731c 100644 --- a/src/server/ingen_lv2.cpp +++ b/src/server/ingen_lv2.cpp @@ -544,8 +544,8 @@ ingen_instantiate(const LV2_Descriptor* descriptor, plugin->engine = engine; plugin->world->set_engine(engine); - SPtr<EventWriter> interface = SPtr<EventWriter>(engine->interface(), - NullDeleter<EventWriter>); + SPtr<Interface> interface = SPtr<Interface>(engine->interface(), + NullDeleter<Interface>); plugin->world->set_interface(interface); |