diff options
author | David Robillard <d@drobilla.net> | 2017-12-17 00:03:59 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2017-12-17 00:03:59 +0100 |
commit | 86bf9cbd7af99c8964745d414494c26af11af0f4 (patch) | |
tree | 72ce9b2a55777f5de0ffa139812eaa761870af7d | |
parent | af51373cadb57d8b31ccb3c359e7c80d8f697487 (diff) | |
download | ingen-86bf9cbd7af99c8964745d414494c26af11af0f4.tar.gz ingen-86bf9cbd7af99c8964745d414494c26af11af0f4.tar.bz2 ingen-86bf9cbd7af99c8964745d414494c26af11af0f4.zip |
Simplify Tee
-rw-r--r-- | ingen/Tee.hpp | 24 | ||||
-rw-r--r-- | src/server/Engine.cpp | 17 |
2 files changed, 13 insertions, 28 deletions
diff --git a/ingen/Tee.hpp b/ingen/Tee.hpp index f02d8602..543dfa28 100644 --- a/ingen/Tee.hpp +++ b/ingen/Tee.hpp @@ -19,7 +19,7 @@ #include <mutex> #include <set> -#include <string> +#include <utility> #include "ingen/Interface.hpp" #include "ingen/types.hpp" @@ -32,25 +32,13 @@ class Tee : public Interface public: typedef std::set< SPtr<Interface> > Sinks; - Tee(const Sinks& sinks = {}) - : _sinks(sinks) - {} + explicit Tee(Sinks sinks) : _sinks(std::move(sinks)) {} - void add_sink(SPtr<Interface> sink) { - std::lock_guard<std::mutex> lock(_sinks_mutex); - _sinks.insert(sink); - } - - bool remove_sink(SPtr<Interface> sink) { - std::lock_guard<std::mutex> lock(_sinks_mutex); - return (_sinks.erase(sink) > 0); - } - - virtual SPtr<Interface> respondee() const { + SPtr<Interface> respondee() const override { return (*_sinks.begin())->respondee(); } - virtual void set_respondee(SPtr<Interface> respondee) { + void set_respondee(SPtr<Interface> respondee) override { (*_sinks.begin())->set_respondee(respondee); } @@ -61,9 +49,7 @@ public: } } - Raul::URI uri() const { return Raul::URI("ingen:/tee"); } - const Sinks& sinks() const { return _sinks; } - Sinks& sinks() { return _sinks; } + Raul::URI uri() const override { return Raul::URI("ingen:/tee"); } private: std::mutex _sinks_mutex; diff --git a/src/server/Engine.cpp b/src/server/Engine.cpp index 8567ae2a..2e32e706 100644 --- a/src/server/Engine.cpp +++ b/src/server/Engine.cpp @@ -121,15 +121,14 @@ Engine::Engine(Ingen::World* world) 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; + _interface = std::make_shared<Tee>( + Tee::Sinks{ + _event_writer, + std::make_shared<StreamWriter>(world->uri_map(), + world->uris(), + Raul::URI("ingen:/engine"), + stderr, + ColorContext::Color::MAGENTA)}); } _atom_interface = new AtomReader( |