diff options
Diffstat (limited to 'src/server')
-rw-r--r-- | src/server/ClientBroadcaster.cpp | 10 | ||||
-rw-r--r-- | src/server/ClientBroadcaster.hpp | 6 | ||||
-rw-r--r-- | src/server/Engine.cpp | 2 | ||||
-rw-r--r-- | src/server/Engine.hpp | 3 | ||||
-rw-r--r-- | src/server/EventWriter.cpp | 27 | ||||
-rw-r--r-- | src/server/EventWriter.hpp | 14 | ||||
-rw-r--r-- | src/server/ingen_lv2.cpp | 6 |
7 files changed, 35 insertions, 33 deletions
diff --git a/src/server/ClientBroadcaster.cpp b/src/server/ClientBroadcaster.cpp index 46e6fb2f..42aad778 100644 --- a/src/server/ClientBroadcaster.cpp +++ b/src/server/ClientBroadcaster.cpp @@ -36,7 +36,7 @@ namespace Server { /** Register a client to receive messages over the notification band. */ void -ClientBroadcaster::register_client(const URI& uri, Interface* client) +ClientBroadcaster::register_client(const URI& uri, SharedPtr<Interface> client) { Glib::Mutex::Lock lock(_clients_mutex); LOG(info) << "Registered client: " << uri << endl; @@ -65,7 +65,7 @@ ClientBroadcaster::unregister_client(const URI& uri) /** Looks up the client with the given source @a uri (which is used as the * unique identifier for registered clients). */ -Interface* +SharedPtr<Interface> ClientBroadcaster::client(const URI& uri) { Glib::Mutex::Lock lock(_clients_mutex); @@ -73,7 +73,7 @@ ClientBroadcaster::client(const URI& uri) if (i != _clients.end()) { return (*i).second; } else { - return NULL; + return SharedPtr<Interface>(); } } @@ -82,7 +82,7 @@ ClientBroadcaster::send_plugins(const NodeFactory::Plugins& plugins) { Glib::Mutex::Lock lock(_clients_mutex); for (Clients::const_iterator c = _clients.begin(); c != _clients.end(); ++c) { - send_plugins_to((*c).second, plugins); + send_plugins_to((*c).second.get(), plugins); } } @@ -109,7 +109,7 @@ ClientBroadcaster::send_object(const GraphObjectImpl* o, bool recursive) { Glib::Mutex::Lock lock(_clients_mutex); for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i) { - ObjectSender::send_object((*i).second, o, recursive); + ObjectSender::send_object((*i).second.get(), o, recursive); } } diff --git a/src/server/ClientBroadcaster.hpp b/src/server/ClientBroadcaster.hpp index c095b960..5eea1093 100644 --- a/src/server/ClientBroadcaster.hpp +++ b/src/server/ClientBroadcaster.hpp @@ -49,10 +49,10 @@ class ConnectionImpl; class ClientBroadcaster : public Interface { public: - void register_client(const Raul::URI& uri, Interface* client); + void register_client(const Raul::URI& uri, SharedPtr<Interface> client); bool unregister_client(const Raul::URI& uri); - Interface* client(const Raul::URI& uri); + SharedPtr<Interface> client(const Raul::URI& uri); void send_plugins(const NodeFactory::Plugins& plugin_list); void send_plugins_to(Interface*, const NodeFactory::Plugins& plugin_list); @@ -118,7 +118,7 @@ public: void error(const std::string& msg) { BROADCAST(error, msg); } private: - typedef std::map<Raul::URI, Interface*> Clients; + typedef std::map< Raul::URI, SharedPtr<Interface> > Clients; Glib::Mutex _clients_mutex; Clients _clients; diff --git a/src/server/Engine.cpp b/src/server/Engine.cpp index f2f088f5..f3b5e476 100644 --- a/src/server/Engine.cpp +++ b/src/server/Engine.cpp @@ -278,7 +278,7 @@ Engine::process_events(ProcessContext& context) } void -Engine::register_client(const Raul::URI& uri, Interface* client) +Engine::register_client(const Raul::URI& uri, SharedPtr<Interface> client) { _broadcaster->register_client(uri, client); } diff --git a/src/server/Engine.hpp b/src/server/Engine.hpp index 5111f52c..9600e8a2 100644 --- a/src/server/Engine.hpp +++ b/src/server/Engine.hpp @@ -69,7 +69,8 @@ public: virtual void run(uint32_t sample_count); virtual void quit(); virtual bool main_iteration(); - virtual void register_client(const Raul::URI& uri, Interface* client); + virtual void register_client(const Raul::URI& uri, + SharedPtr<Interface> client); virtual bool unregister_client(const Raul::URI& uri); void set_driver(SharedPtr<Driver> driver); diff --git a/src/server/EventWriter.cpp b/src/server/EventWriter.cpp index 19a738b0..4ec0756b 100644 --- a/src/server/EventWriter.cpp +++ b/src/server/EventWriter.cpp @@ -36,7 +36,6 @@ namespace Server { EventWriter::EventWriter(Engine& engine) : _engine(engine) - , _respondee(NULL) , _request_id(-1) { } @@ -59,10 +58,6 @@ EventWriter::now() const void EventWriter::set_response_id(int32_t id) { - if (!_respondee) { // Kludge - _respondee = _engine.broadcaster()->client( - "http://drobilla.net/ns/ingen#internal"); - } _request_id = id; } @@ -72,7 +67,7 @@ EventWriter::put(const URI& uri, const Resource::Graph ctx) { _engine.enqueue_event( - new Events::SetMetadata(_engine, _respondee, _request_id, now(), + new Events::SetMetadata(_engine, _respondee.get(), _request_id, now(), true, ctx, uri, properties)); } @@ -82,7 +77,7 @@ EventWriter::delta(const URI& uri, const Resource::Properties& add) { _engine.enqueue_event( - new Events::SetMetadata(_engine, _respondee, _request_id, now(), + new Events::SetMetadata(_engine, _respondee.get(), _request_id, now(), false, Resource::DEFAULT, uri, add, remove)); } @@ -91,7 +86,7 @@ EventWriter::move(const Path& old_path, const Path& new_path) { _engine.enqueue_event( - new Events::Move(_engine, _respondee, _request_id, now(), + new Events::Move(_engine, _respondee.get(), _request_id, now(), old_path, new_path)); } @@ -105,7 +100,7 @@ EventWriter::del(const URI& uri) _engine.quit(); } else { _engine.enqueue_event( - new Events::Delete(_engine, _respondee, _request_id, now(), uri)); + new Events::Delete(_engine, _respondee.get(), _request_id, now(), uri)); } } @@ -114,7 +109,7 @@ EventWriter::connect(const Path& tail_path, const Path& head_path) { _engine.enqueue_event( - new Events::Connect(_engine, _respondee, _request_id, now(), + new Events::Connect(_engine, _respondee.get(), _request_id, now(), tail_path, head_path)); } @@ -130,7 +125,7 @@ EventWriter::disconnect(const Path& src, } _engine.enqueue_event( - new Events::Disconnect(_engine, _respondee, _request_id, now(), + new Events::Disconnect(_engine, _respondee.get(), _request_id, now(), src, dst)); } @@ -139,7 +134,7 @@ EventWriter::disconnect_all(const Path& patch_path, const Path& path) { _engine.enqueue_event( - new Events::DisconnectAll(_engine, _respondee, _request_id, now(), + new Events::DisconnectAll(_engine, _respondee.get(), _request_id, now(), patch_path, path)); } @@ -153,10 +148,10 @@ EventWriter::set_property(const URI& uri, if (value.get_bool()) { _engine.activate(); _engine.enqueue_event( - new Events::Ping(_engine, _respondee, _request_id, now())); + new Events::Ping(_engine, _respondee.get(), _request_id, now())); } else { _engine.enqueue_event( - new Events::Deactivate(_engine, _respondee, _request_id, now())); + new Events::Deactivate(_engine, _respondee.get(), _request_id, now())); } } else { Resource::Properties remove; @@ -164,7 +159,7 @@ EventWriter::set_property(const URI& uri, Resource::Properties add; add.insert(make_pair(predicate, value)); _engine.enqueue_event( - new Events::SetMetadata(_engine, _respondee, _request_id, now(), + new Events::SetMetadata(_engine, _respondee.get(), _request_id, now(), false, Resource::DEFAULT, uri, add, remove)); } } @@ -173,7 +168,7 @@ void EventWriter::get(const URI& uri) { _engine.enqueue_event( - new Events::Get(_engine, _respondee, _request_id, now(), uri)); + new Events::Get(_engine, _respondee.get(), _request_id, now(), uri)); } } // namespace Server diff --git a/src/server/EventWriter.hpp b/src/server/EventWriter.hpp index 9e334f98..2a080be4 100644 --- a/src/server/EventWriter.hpp +++ b/src/server/EventWriter.hpp @@ -42,7 +42,13 @@ public: Raul::URI uri() const { return "http://drobilla.net/ns/ingen#internal"; } - void set_respondee(Interface* iface) { _respondee = iface; } + virtual SharedPtr<Interface> respondee() const { + return _respondee; + } + + virtual void set_respondee(SharedPtr<Interface> respondee) { + _respondee = respondee; + } virtual void set_response_id(int32_t id); @@ -83,9 +89,9 @@ public: virtual void error(const std::string& msg) {} ///< N/A protected: - Engine& _engine; - Interface* _respondee; - int32_t _request_id; + Engine& _engine; + SharedPtr<Interface> _respondee; + int32_t _request_id; private: SampleCount now() const; diff --git a/src/server/ingen_lv2.cpp b/src/server/ingen_lv2.cpp index 733f7a52..5e21f679 100644 --- a/src/server/ingen_lv2.cpp +++ b/src/server/ingen_lv2.cpp @@ -438,9 +438,9 @@ ingen_instantiate(const LV2_Descriptor* descriptor, LV2Driver* driver = new LV2Driver(*engine.get(), 4096, rate); engine->set_driver(SharedPtr<Ingen::Server::Driver>(driver)); - interface->set_respondee(&driver->writer()); - engine->register_client("http://drobilla.net/ns/ingen#internal", - &driver->writer()); + SharedPtr<Interface> client(&driver->writer(), NullDeleter<Interface>); + interface->set_respondee(client); + engine->register_client("http://drobilla.net/ns/ingen#internal", client); engine->activate(); Server::ThreadManager::single_threaded = true; |