summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Serialiser.cpp6
-rw-r--r--src/World.cpp82
-rw-r--r--src/server/BlockFactory.cpp15
-rw-r--r--src/server/BlockFactory.hpp4
-rw-r--r--src/server/Broadcaster.cpp2
-rw-r--r--src/server/Engine.cpp30
-rw-r--r--src/server/Engine.hpp10
-rw-r--r--src/server/RunContext.cpp2
-rw-r--r--src/server/RunContext.hpp3
-rw-r--r--src/server/Worker.cpp3
-rw-r--r--src/server/Worker.hpp19
-rw-r--r--src/server/events/CreateGraph.cpp26
-rw-r--r--src/server/events/CreateGraph.hpp17
-rw-r--r--src/server/events/Delete.cpp7
-rw-r--r--src/server/events/Delete.hpp2
-rw-r--r--src/server/events/Delta.cpp36
-rw-r--r--src/server/events/Delta.hpp4
-rw-r--r--src/server/events/Disconnect.cpp14
-rw-r--r--src/server/events/Disconnect.hpp4
-rw-r--r--src/server/ingen_lv2.cpp9
20 files changed, 129 insertions, 166 deletions
diff --git a/src/Serialiser.cpp b/src/Serialiser.cpp
index 36d4a87f..6a0991be 100644
--- a/src/Serialiser.cpp
+++ b/src/Serialiser.cpp
@@ -101,13 +101,11 @@ struct Serialiser::Impl {
};
Serialiser::Serialiser(World& world)
- : me(new Impl(world))
+ : me{make_unique<Impl>(world)}
{}
Serialiser::~Serialiser()
-{
- delete me;
-}
+{}
void
Serialiser::Impl::write_manifest(const FilePath& bundle_path,
diff --git a/src/World.cpp b/src/World.cpp
index fd13d643..233a7d36 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -105,20 +105,20 @@ public:
, argv(nullptr)
, lv2_features(nullptr)
, rdf_world(new Sord::World())
- , lilv_world(lilv_world_new())
- , uri_map(new URIMap(log, map, unmap))
- , forge(new Forge(*uri_map))
- , uris(new URIs(*forge, uri_map, lilv_world))
- , conf(*forge)
- , log(lv2_log, *uris)
+ , lilv_world(lilv_world_new(), lilv_world_free)
+ , uri_map(log, map, unmap)
+ , forge(uri_map)
+ , uris(forge, &uri_map, lilv_world.get())
+ , conf(forge)
+ , log(lv2_log, uris)
{
lv2_features = new LV2Features();
- lv2_features->add_feature(uri_map->urid_map_feature());
- lv2_features->add_feature(uri_map->urid_unmap_feature());
+ lv2_features->add_feature(uri_map.urid_map_feature());
+ lv2_features->add_feature(uri_map.urid_unmap_feature());
lv2_features->add_feature(SPtr<InstanceAccess>(new InstanceAccess()));
lv2_features->add_feature(SPtr<DataAccess>(new DataAccess()));
lv2_features->add_feature(SPtr<Log::Feature>(new Log::Feature()));
- lilv_world_load_all(lilv_world);
+ lilv_world_load_all(lilv_world.get());
// Set up RDF namespaces
rdf_world->add_prefix("atom", "http://lv2plug.in/ns/ext/atom#");
@@ -134,14 +134,14 @@ public:
// Load internal 'plugin' information into lilv world
LilvNode* rdf_type = lilv_new_uri(
- lilv_world, "http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
+ lilv_world.get(), "http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
LilvNode* ingen_Plugin = lilv_new_uri(
- lilv_world, INGEN__Plugin);
+ lilv_world.get(), INGEN__Plugin);
LilvNodes* internals = lilv_world_find_nodes(
- lilv_world, nullptr, rdf_type, ingen_Plugin);
+ lilv_world.get(), nullptr, rdf_type, ingen_Plugin);
LILV_FOREACH(nodes, i, internals) {
const LilvNode* internal = lilv_nodes_get(internals, i);
- lilv_world_load_resource(lilv_world, internal);
+ lilv_world_load_resource(lilv_world.get(), internal);
}
lilv_nodes_free(internals);
lilv_node_free(rdf_type);
@@ -171,18 +171,12 @@ public:
interface_factories.clear();
script_runners.clear();
- delete rdf_world;
delete lv2_features;
- delete uris;
- delete forge;
- delete uri_map;
-
- lilv_world_free(lilv_world);
// Module libraries go out of scope and close here
}
- typedef std::map<const std::string, Module*> Modules;
+ typedef std::map<std::string, Module*> Modules;
Modules modules;
typedef std::map<const std::string, World::InterfaceFactory> InterfaceFactories;
@@ -192,24 +186,26 @@ public:
typedef std::map<const std::string, ScriptRunner> ScriptRunners;
ScriptRunners script_runners;
- int* argc;
- char*** argv;
- LV2Features* lv2_features;
- Sord::World* rdf_world;
- LilvWorld* lilv_world;
- URIMap* uri_map;
- Forge* forge;
- URIs* uris;
- LV2_Log_Log* lv2_log;
- Configuration conf;
- Log log;
- SPtr<Interface> interface;
- SPtr<EngineBase> engine;
- SPtr<Serialiser> serialiser;
- SPtr<Parser> parser;
- SPtr<Store> store;
- std::mutex rdf_mutex;
- std::string jack_uuid;
+ using LilvWorldUPtr = std::unique_ptr<LilvWorld, decltype(&lilv_world_free)>;
+
+ int* argc;
+ char*** argv;
+ LV2Features* lv2_features;
+ UPtr<Sord::World> rdf_world;
+ LilvWorldUPtr lilv_world;
+ URIMap uri_map;
+ Forge forge;
+ URIs uris;
+ LV2_Log_Log* lv2_log;
+ Configuration conf;
+ Log log;
+ SPtr<Interface> interface;
+ SPtr<EngineBase> engine;
+ SPtr<Serialiser> serialiser;
+ SPtr<Parser> parser;
+ SPtr<Store> store;
+ std::mutex rdf_mutex;
+ std::string jack_uuid;
};
World::World(LV2_URID_Map* map, LV2_URID_Unmap* unmap, LV2_Log_Log* log)
@@ -259,13 +255,13 @@ Log& World::log() { return _impl->log; }
std::mutex& World::rdf_mutex() { return _impl->rdf_mutex; }
-Sord::World* World::rdf_world() { return _impl->rdf_world; }
-LilvWorld* World::lilv_world() { return _impl->lilv_world; }
+Sord::World* World::rdf_world() { return _impl->rdf_world.get(); }
+LilvWorld* World::lilv_world() { return _impl->lilv_world.get(); }
LV2Features& World::lv2_features() { return *_impl->lv2_features; }
-Forge& World::forge() { return *_impl->forge; }
-URIs& World::uris() { return *_impl->uris; }
-URIMap& World::uri_map() { return *_impl->uri_map; }
+Forge& World::forge() { return _impl->forge; }
+URIs& World::uris() { return _impl->uris; }
+URIMap& World::uri_map() { return _impl->uri_map; }
bool
World::load_module(const char* name)
diff --git a/src/server/BlockFactory.cpp b/src/server/BlockFactory.cpp
index 105d60cf..02be5159 100644
--- a/src/server/BlockFactory.cpp
+++ b/src/server/BlockFactory.cpp
@@ -46,11 +46,6 @@ BlockFactory::BlockFactory(ingen::World& world)
BlockFactory::~BlockFactory()
{
- for (auto& p : _plugins) {
- delete p.second;
- }
-
- _plugins.clear();
}
const BlockFactory::Plugins&
@@ -64,12 +59,12 @@ BlockFactory::plugins()
return _plugins;
}
-std::set<PluginImpl*>
+std::set<SPtr<PluginImpl>>
BlockFactory::refresh()
{
// Record current plugins, and those that are currently zombies
- const Plugins old_plugins(_plugins);
- std::set<PluginImpl*> zombies;
+ const Plugins old_plugins(_plugins);
+ std::set<SPtr<PluginImpl>> zombies;
for (const auto& p : _plugins) {
if (p.second->is_zombie()) {
zombies.insert(p.second);
@@ -80,7 +75,7 @@ BlockFactory::refresh()
load_lv2_plugins();
// Add any new plugins to response
- std::set<PluginImpl*> new_plugins;
+ std::set<SPtr<PluginImpl>> new_plugins;
for (const auto& p : _plugins) {
auto o = old_plugins.find(p.first);
if (o == old_plugins.end()) {
@@ -103,7 +98,7 @@ BlockFactory::plugin(const URI& uri)
{
load_plugin(uri);
const Plugins::const_iterator i = _plugins.find(uri);
- return ((i != _plugins.end()) ? i->second : nullptr);
+ return ((i != _plugins.end()) ? i->second.get() : nullptr);
}
void
diff --git a/src/server/BlockFactory.hpp b/src/server/BlockFactory.hpp
index 80f99563..cac9a1d1 100644
--- a/src/server/BlockFactory.hpp
+++ b/src/server/BlockFactory.hpp
@@ -43,11 +43,11 @@ public:
*
* @return The set of newly loaded plugins.
*/
- std::set<PluginImpl*> refresh();
+ std::set<SPtr<PluginImpl>> refresh();
void load_plugin(const URI& uri);
- typedef std::map<URI, PluginImpl*> Plugins;
+ using Plugins = std::map<URI, SPtr<PluginImpl>>;
const Plugins& plugins();
PluginImpl* plugin(const URI& uri);
diff --git a/src/server/Broadcaster.cpp b/src/server/Broadcaster.cpp
index f8b58beb..aac28d53 100644
--- a/src/server/Broadcaster.cpp
+++ b/src/server/Broadcaster.cpp
@@ -86,7 +86,7 @@ Broadcaster::send_plugins_to(Interface* client,
client->bundle_begin();
for (const auto& p : plugins) {
- const PluginImpl* const plugin = p.second;
+ const auto& plugin = p.second;
client->put(plugin->uri(), plugin->properties());
}
diff --git a/src/server/Engine.cpp b/src/server/Engine.cpp
index 5b132623..c463e7d6 100644
--- a/src/server/Engine.cpp
+++ b/src/server/Engine.cpp
@@ -96,9 +96,11 @@ Engine::Engine(ingen::World& world)
}
for (int i = 0; i < world.conf().option("threads").get<int32_t>(); ++i) {
- Raul::RingBuffer* ring = new Raul::RingBuffer(24 * event_queue_size());
- _notifications.push_back(ring);
- _run_contexts.push_back(new RunContext(*this, ring, i, i > 0));
+ _notifications.emplace_back(
+ make_unique<Raul::RingBuffer>(uint32_t(24 * event_queue_size())));
+ _run_contexts.emplace_back(
+ make_unique<RunContext>(
+ *this, _notifications.back().get(), unsigned(i), i > 0));
}
_world.lv2_features().add_feature(_worker->schedule_feature());
@@ -149,12 +151,8 @@ Engine::~Engine()
// Delete run contexts
_quit_flag = true;
_tasks_available.notify_all();
- for (RunContext* ctx : _run_contexts) {
+ for (const auto& ctx : _run_contexts) {
ctx->join();
- delete ctx;
- }
- for (Raul::RingBuffer* ring : _notifications) {
- delete ring;
}
const SPtr<Store> store = this->store();
@@ -181,7 +179,7 @@ Engine::listen()
void
Engine::advance(SampleCount nframes)
{
- for (RunContext* ctx : _run_contexts) {
+ for (const auto& ctx : _run_contexts) {
ctx->locate(ctx->start() + nframes, block_length());
}
}
@@ -189,7 +187,7 @@ Engine::advance(SampleCount nframes)
void
Engine::locate(FrameTime s, SampleCount nframes)
{
- for (RunContext* ctx : _run_contexts) {
+ for (const auto& ctx : _run_contexts) {
ctx->locate(s, nframes);
}
}
@@ -222,7 +220,7 @@ Engine::flush_events(const std::chrono::milliseconds& sleep_ms)
void
Engine::emit_notifications(FrameTime end)
{
- for (RunContext* ctx : _run_contexts) {
+ for (const auto& ctx : _run_contexts) {
ctx->emit_notifications(end);
}
}
@@ -230,7 +228,7 @@ Engine::emit_notifications(FrameTime end)
bool
Engine::pending_notifications()
{
- for (const RunContext* ctx : _run_contexts) {
+ for (const auto& ctx : _run_contexts) {
if (ctx->pending_notifications()) {
return true;
}
@@ -258,9 +256,9 @@ Task*
Engine::steal_task(unsigned start_thread)
{
for (unsigned i = 0; i < _run_contexts.size(); ++i) {
- const unsigned id = (start_thread + i) % _run_contexts.size();
- RunContext* const ctx = _run_contexts[id];
- Task* par = ctx->task();
+ const unsigned id = (start_thread + i) % _run_contexts.size();
+ const auto& ctx = _run_contexts[id];
+ Task* par = ctx->task();
if (par) {
Task* t = par->steal(*ctx);
if (t) {
@@ -338,7 +336,7 @@ void
Engine::set_driver(SPtr<Driver> driver)
{
_driver = driver;
- for (RunContext* ctx : _run_contexts) {
+ for (const auto& ctx : _run_contexts) {
ctx->set_priority(driver->real_time_priority());
ctx->set_rate(driver->sample_rate());
}
diff --git a/src/server/Engine.hpp b/src/server/Engine.hpp
index a86397ea..35030d47 100644
--- a/src/server/Engine.hpp
+++ b/src/server/Engine.hpp
@@ -197,11 +197,11 @@ private:
UPtr<AtomReader> _atom_interface;
GraphImpl* _root_graph;
- std::vector<Raul::RingBuffer*> _notifications;
- std::vector<RunContext*> _run_contexts;
- uint64_t _cycle_start_time;
- Load _run_load;
- Clock _clock;
+ std::vector<UPtr<Raul::RingBuffer>> _notifications;
+ std::vector<UPtr<RunContext>> _run_contexts;
+ uint64_t _cycle_start_time;
+ Load _run_load;
+ Clock _clock;
std::mt19937 _rand_engine;
std::uniform_real_distribution<float> _uniform_dist;
diff --git a/src/server/RunContext.cpp b/src/server/RunContext.cpp
index 64ea24f9..d7b96fba 100644
--- a/src/server/RunContext.cpp
+++ b/src/server/RunContext.cpp
@@ -177,7 +177,7 @@ RunContext::join()
if (_thread->joinable()) {
_thread->join();
}
- delete _thread;
+ _thread.reset();
}
}
diff --git a/src/server/RunContext.hpp b/src/server/RunContext.hpp
index 15e65806..3a317af3 100644
--- a/src/server/RunContext.hpp
+++ b/src/server/RunContext.hpp
@@ -23,6 +23,7 @@
#include "lv2/urid/urid.h"
#include "raul/RingBuffer.hpp"
+#include "ingen/types.hpp"
#include "types.hpp"
namespace ingen {
@@ -144,7 +145,7 @@ protected:
Engine& _engine; ///< Engine we're running in
Raul::RingBuffer* _event_sink; ///< Port updates from process context
Task* _task; ///< Currently executing task
- std::thread* _thread; ///< Thread (null for main run context)
+ UPtr<std::thread> _thread; ///< Thread (null for main run context)
unsigned _id; ///< Context ID
FrameTime _start; ///< Start frame of this cycle, timeline relative
diff --git a/src/server/Worker.cpp b/src/server/Worker.cpp
index 368455e2..65ce7727 100644
--- a/src/server/Worker.cpp
+++ b/src/server/Worker.cpp
@@ -118,7 +118,7 @@ Worker::Worker(Log& log, uint32_t buffer_size, bool synchronous)
, _synchronous(synchronous)
{
if (!synchronous) {
- _thread = new std::thread(&Worker::run, this);
+ _thread = make_unique<std::thread>(&Worker::run, this);
}
}
@@ -128,7 +128,6 @@ Worker::~Worker()
_sem.post();
if (_thread) {
_thread->join();
- delete _thread;
}
free(_buffer);
}
diff --git a/src/server/Worker.hpp b/src/server/Worker.hpp
index 1dd5f34f..cea6ee62 100644
--- a/src/server/Worker.hpp
+++ b/src/server/Worker.hpp
@@ -20,6 +20,7 @@
#include <thread>
#include "ingen/LV2Features.hpp"
+#include "ingen/types.hpp"
#include "lv2/worker/worker.h"
#include "raul/RingBuffer.hpp"
#include "raul/Semaphore.hpp"
@@ -57,15 +58,15 @@ public:
private:
SPtr<Schedule> _schedule;
- Log& _log;
- Raul::Semaphore _sem;
- Raul::RingBuffer _requests;
- Raul::RingBuffer _responses;
- uint8_t* const _buffer;
- const uint32_t _buffer_size;
- std::thread* _thread;
- bool _exit_flag;
- bool _synchronous;
+ Log& _log;
+ Raul::Semaphore _sem;
+ Raul::RingBuffer _requests;
+ Raul::RingBuffer _responses;
+ uint8_t* const _buffer;
+ const uint32_t _buffer_size;
+ UPtr<std::thread> _thread;
+ bool _exit_flag;
+ bool _synchronous;
void run();
};
diff --git a/src/server/events/CreateGraph.cpp b/src/server/events/CreateGraph.cpp
index bd7079d9..5bb66a46 100644
--- a/src/server/events/CreateGraph.cpp
+++ b/src/server/events/CreateGraph.cpp
@@ -44,13 +44,6 @@ CreateGraph::CreateGraph(Engine& engine,
, _parent(nullptr)
{}
-CreateGraph::~CreateGraph()
-{
- for (Event* ev : _child_events) {
- delete ev;
- }
-}
-
void
CreateGraph::build_child_events()
{
@@ -76,10 +69,9 @@ CreateGraph::build_child_events()
Resource::Graph::EXTERNAL);
_child_events.push_back(
- new events::CreatePort(
- _engine, _request_client, -1, _time,
- _path.child(Raul::Symbol("control")),
- in_properties));
+ make_unique<events::CreatePort>(_engine, _request_client, -1, _time,
+ _path.child(Raul::Symbol("control")),
+ in_properties));
// Add notify port (message respond)
Properties out_properties(control_properties);
@@ -92,9 +84,9 @@ CreateGraph::build_child_events()
Resource::Graph::EXTERNAL);
_child_events.push_back(
- new events::CreatePort(_engine, _request_client, -1, _time,
- _path.child(Raul::Symbol("notify")),
- out_properties));
+ make_unique<events::CreatePort>(_engine, _request_client, -1, _time,
+ _path.child(Raul::Symbol("notify")),
+ out_properties));
}
bool
@@ -184,7 +176,7 @@ CreateGraph::pre_process(PreProcessContext& ctx)
// Build and pre-process child events to create standard ports
build_child_events();
- for (Event* ev : _child_events) {
+ for (const auto& ev : _child_events) {
ev->pre_process(ctx);
}
@@ -204,7 +196,7 @@ CreateGraph::execute(RunContext& context)
_graph->enable();
}
- for (Event* ev : _child_events) {
+ for (const auto& ev : _child_events) {
ev->execute(context);
}
}
@@ -219,7 +211,7 @@ CreateGraph::post_process()
}
if (_graph) {
- for (Event* ev : _child_events) {
+ for (const auto& ev : _child_events) {
ev->post_process();
}
}
diff --git a/src/server/events/CreateGraph.hpp b/src/server/events/CreateGraph.hpp
index 1537283e..565a3278 100644
--- a/src/server/events/CreateGraph.hpp
+++ b/src/server/events/CreateGraph.hpp
@@ -20,6 +20,7 @@
#include <list>
#include "ingen/Resource.hpp"
+#include "ingen/types.hpp"
#include "CompiledGraph.hpp"
#include "Event.hpp"
@@ -46,8 +47,6 @@ public:
const Raul::Path& path,
const Properties& properties);
- ~CreateGraph();
-
bool pre_process(PreProcessContext& ctx) override;
void execute(RunContext& context) override;
void post_process() override;
@@ -58,13 +57,13 @@ public:
private:
void build_child_events();
- const Raul::Path _path;
- Properties _properties;
- ClientUpdate _update;
- GraphImpl* _graph;
- GraphImpl* _parent;
- MPtr<CompiledGraph> _compiled_graph;
- std::list<Event*> _child_events;
+ const Raul::Path _path;
+ Properties _properties;
+ ClientUpdate _update;
+ GraphImpl* _graph;
+ GraphImpl* _parent;
+ MPtr<CompiledGraph> _compiled_graph;
+ std::list<UPtr<Event>> _child_events;
};
} // namespace events
diff --git a/src/server/events/Delete.cpp b/src/server/events/Delete.cpp
index 4e1aa69b..f6168c9c 100644
--- a/src/server/events/Delete.cpp
+++ b/src/server/events/Delete.cpp
@@ -51,7 +51,6 @@ Delete::Delete(Engine& engine,
Delete::~Delete()
{
- delete _disconnect_event;
for (ControlBindings::Binding* b : _removed_bindings) {
delete b;
}
@@ -92,12 +91,14 @@ Delete::pre_process(PreProcessContext& ctx)
if (_block) {
parent->remove_block(*_block);
- _disconnect_event = new DisconnectAll(_engine, parent, _block.get());
+ _disconnect_event =
+ make_unique<DisconnectAll>(_engine, parent, _block.get());
_disconnect_event->pre_process(ctx);
_compiled_graph = ctx.maybe_compile(*_engine.maid(), *parent);
} else if (_port) {
parent->remove_port(*_port);
- _disconnect_event = new DisconnectAll(_engine, parent, _port.get());
+ _disconnect_event =
+ make_unique<DisconnectAll>(_engine, parent, _port.get());
_disconnect_event->pre_process(ctx);
_compiled_graph = ctx.maybe_compile(*_engine.maid(), *parent);
diff --git a/src/server/events/Delete.hpp b/src/server/events/Delete.hpp
index 4b0c314b..4925a856 100644
--- a/src/server/events/Delete.hpp
+++ b/src/server/events/Delete.hpp
@@ -72,7 +72,7 @@ private:
EnginePort* _engine_port;
MPtr<GraphImpl::Ports> _ports_array; ///< New (external) ports for Graph
MPtr<CompiledGraph> _compiled_graph; ///< Graph's new process order
- DisconnectAll* _disconnect_event;
+ UPtr<DisconnectAll> _disconnect_event;
Store::Objects _removed_objects;
IndexChanges _port_index_changes;
diff --git a/src/server/events/Delta.cpp b/src/server/events/Delta.cpp
index da957fd3..efc50bce 100644
--- a/src/server/events/Delta.cpp
+++ b/src/server/events/Delta.cpp
@@ -84,7 +84,6 @@ Delta::Delta(Engine& engine,
SampleCount timestamp,
const ingen::SetProperty& msg)
: Event(engine, client, msg.seq, timestamp)
- , _create_event(nullptr)
, _subject(msg.subject)
, _properties{{msg.predicate, msg.value}}
, _object(nullptr)
@@ -100,11 +99,6 @@ Delta::Delta(Engine& engine,
Delta::~Delta()
{
- for (auto& s : _set_events) {
- delete s;
- }
-
- delete _create_event;
}
void
@@ -137,11 +131,10 @@ Delta::add_set_event(const char* port_symbol,
return;
}
- SetPortValue* ev = new SetPortValue(
- _engine, _request_client, _request_id, _time,
- port, Atom(size, type, value), false, true);
-
- _set_events.push_back(ev);
+ _set_events.emplace_back(
+ make_unique<SetPortValue>(
+ _engine, _request_client, _request_id, _time,
+ port, Atom(size, type, value), false, true));
}
static void
@@ -232,13 +225,13 @@ Delta::pre_process(PreProcessContext& ctx)
ingen::Resource::type(uris, _properties, is_graph, is_block, is_port, is_output);
if (is_graph) {
- _create_event = new CreateGraph(
+ _create_event = make_unique<CreateGraph>(
_engine, _request_client, _request_id, _time, path, _properties);
} else if (is_block) {
- _create_event = new CreateBlock(
+ _create_event = make_unique<CreateBlock>(
_engine, _request_client, _request_id, _time, path, _properties);
} else if (is_port) {
- _create_event = new CreatePort(
+ _create_event = make_unique<CreatePort>(
_engine, _request_client, _request_id, _time,
path, _properties);
}
@@ -333,10 +326,10 @@ Delta::pre_process(PreProcessContext& ctx)
_status = Status::BAD_VALUE_TYPE;
}
} else if (key == uris.ingen_value || key == uris.ingen_activity) {
- SetPortValue* ev = new SetPortValue(
- _engine, _request_client, _request_id, _time, port, value,
- key == uris.ingen_activity);
- _set_events.push_back(ev);
+ _set_events.emplace_back(
+ make_unique<SetPortValue>(
+ _engine, _request_client, _request_id, _time,
+ port, value, key == uris.ingen_activity));
} else if (key == uris.midi_binding) {
if (port->is_a(PortType::CONTROL) || port->is_a(PortType::CV)) {
if (value == uris.patch_wildcard) {
@@ -444,12 +437,11 @@ Delta::pre_process(PreProcessContext& ctx)
LilvNode* bundle = get_file_node(lworld, uris, value);
if (bundle) {
lilv_world_load_bundle(lworld, bundle);
- const std::set<PluginImpl*> new_plugins =
- _engine.block_factory()->refresh();
+ const auto new_plugins = _engine.block_factory()->refresh();
- for (PluginImpl* p : new_plugins) {
+ for (const auto& p : new_plugins) {
if (p->bundle_uri() == lilv_node_as_string(bundle)) {
- _update.put_plugin(p);
+ _update.put_plugin(p.get());
}
}
lilv_node_free(bundle);
diff --git a/src/server/events/Delta.hpp b/src/server/events/Delta.hpp
index d36e81aa..0fda067a 100644
--- a/src/server/events/Delta.hpp
+++ b/src/server/events/Delta.hpp
@@ -96,11 +96,11 @@ private:
LOADED_BUNDLE
};
- typedef std::vector<SetPortValue*> SetEvents;
+ typedef std::vector<UPtr<SetPortValue>> SetEvents;
void init();
- Event* _create_event;
+ UPtr<Event> _create_event;
SetEvents _set_events;
std::vector<SpecialType> _types;
std::vector<SpecialType> _remove_types;
diff --git a/src/server/events/Disconnect.cpp b/src/server/events/Disconnect.cpp
index e803ce3d..3abf23e4 100644
--- a/src/server/events/Disconnect.cpp
+++ b/src/server/events/Disconnect.cpp
@@ -44,15 +44,9 @@ Disconnect::Disconnect(Engine& engine,
: Event(engine, client, msg.seq, timestamp)
, _msg(msg)
, _graph(nullptr)
- , _impl(nullptr)
{
}
-Disconnect::~Disconnect()
-{
- delete _impl;
-}
-
Disconnect::Impl::Impl(Engine& e,
GraphImpl* graph,
PortImpl* t,
@@ -154,10 +148,10 @@ Disconnect::pre_process(PreProcessContext& ctx)
return Event::pre_process_done(Status::PARENT_NOT_FOUND, _msg.head);
}
- _impl = new Impl(_engine,
- _graph,
- dynamic_cast<PortImpl*>(tail),
- dynamic_cast<InputPort*>(head));
+ _impl = make_unique<Impl>(_engine,
+ _graph,
+ dynamic_cast<PortImpl*>(tail),
+ dynamic_cast<InputPort*>(head));
_compiled_graph = ctx.maybe_compile(*_engine.maid(), *_graph);
diff --git a/src/server/events/Disconnect.hpp b/src/server/events/Disconnect.hpp
index de4bfe57..566a7721 100644
--- a/src/server/events/Disconnect.hpp
+++ b/src/server/events/Disconnect.hpp
@@ -49,8 +49,6 @@ public:
SampleCount timestamp,
const ingen::Disconnect& msg);
- ~Disconnect();
-
bool pre_process(PreProcessContext& ctx) override;
void execute(RunContext& context) override;
void post_process() override;
@@ -76,7 +74,7 @@ public:
private:
const ingen::Disconnect _msg;
GraphImpl* _graph;
- Impl* _impl;
+ UPtr<Impl> _impl;
MPtr<CompiledGraph> _compiled_graph;
};
diff --git a/src/server/ingen_lv2.cpp b/src/server/ingen_lv2.cpp
index 8e5b2189..2d1769a0 100644
--- a/src/server/ingen_lv2.cpp
+++ b/src/server/ingen_lv2.cpp
@@ -429,7 +429,7 @@ struct IngenPlugin {
UPtr<ingen::World> world;
SPtr<Engine> engine;
- std::thread* main;
+ UPtr<std::thread> main;
LV2_URID_Map* map;
int argc;
char** argv;
@@ -613,7 +613,7 @@ ingen_activate(LV2_Handle instance)
SPtr<server::Engine> engine = static_ptr_cast<server::Engine>(me->world->engine());
const SPtr<LV2Driver>& driver = static_ptr_cast<LV2Driver>(engine->driver());
engine->activate();
- me->main = new std::thread(ingen_lv2_main, engine, driver);
+ me->main = make_unique<std::thread>(ingen_lv2_main, engine, driver);
}
static void
@@ -636,8 +636,7 @@ ingen_deactivate(LV2_Handle instance)
me->world->engine()->deactivate();
if (me->main) {
me->main->join();
- delete me->main;
- me->main = nullptr;
+ me->main.reset();
}
}
@@ -649,7 +648,7 @@ ingen_cleanup(LV2_Handle instance)
me->world->set_interface(SPtr<ingen::Interface>());
if (me->main) {
me->main->join();
- delete me->main;
+ me->main.reset();
}
auto world = std::move(me->world);