From 7be6d5d05756a7dea20c494d56f364b4dc064c88 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 11 May 2012 03:01:26 +0000 Subject: Clean up and better document World interface. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4344 a436a847-0d15-0410-975c-d299462d15a1 --- src/server/Buffer.cpp | 2 +- src/server/BufferFactory.cpp | 18 ++++++++---------- src/server/BufferFactory.hpp | 20 +++++++++----------- src/server/ControlBindings.cpp | 12 ++++++------ src/server/Engine.cpp | 3 ++- src/server/EventWriter.cpp | 2 +- src/server/JackDriver.cpp | 7 ++++--- src/server/LV2Info.cpp | 4 ++-- src/server/LV2Node.cpp | 5 ++--- src/server/LV2Plugin.cpp | 2 +- src/server/NodeFactory.cpp | 2 +- src/server/Notification.cpp | 2 +- src/server/PatchImpl.cpp | 4 ++-- src/server/events/CreateNode.cpp | 2 +- src/server/events/CreatePatch.cpp | 2 +- src/server/events/CreatePort.cpp | 6 +++--- src/server/events/Get.cpp | 2 +- src/server/events/SetMetadata.cpp | 8 ++++---- src/server/events/SetPortValue.cpp | 6 +++--- src/server/ingen_jack.cpp | 2 ++ src/server/ingen_lv2.cpp | 10 +++++----- 21 files changed, 60 insertions(+), 61 deletions(-) (limited to 'src/server') diff --git a/src/server/Buffer.cpp b/src/server/Buffer.cpp index a89d19df..f8a9f499 100644 --- a/src/server/Buffer.cpp +++ b/src/server/Buffer.cpp @@ -118,7 +118,7 @@ Buffer::port_data(PortType port_type, SampleCount offset) } else { Raul::warn << "Audio data requested from non-audio buffer " << this << " :: " << _atom->type << " - " - << _factory.engine().world()->uri_map()->unmap_uri(_atom->type) + << _factory.engine().world()->uri_map().unmap_uri(_atom->type) << std::endl; assert(false); return NULL; diff --git a/src/server/BufferFactory.cpp b/src/server/BufferFactory.cpp index 535da6b5..f43fa7a4 100644 --- a/src/server/BufferFactory.cpp +++ b/src/server/BufferFactory.cpp @@ -30,13 +30,11 @@ namespace Server { static const size_t EVENT_BYTES_PER_FRAME = 4; // FIXME -BufferFactory::BufferFactory(Engine& engine, - SharedPtr uris) +BufferFactory::BufferFactory(Engine& engine, Shared::URIs& uris) : _engine(engine) , _uris(uris) , _silent_buffer(NULL) { - assert(_uris); } BufferFactory::~BufferFactory() @@ -66,7 +64,7 @@ BufferFactory::free_list(Buffer* head) void BufferFactory::set_block_length(SampleCount block_length) { - _silent_buffer = create(_uris->atom_Sound, audio_buffer_size(block_length)); + _silent_buffer = create(_uris.atom_Sound, audio_buffer_size(block_length)); } uint32_t @@ -78,11 +76,11 @@ BufferFactory::audio_buffer_size(SampleCount nframes) uint32_t BufferFactory::default_buffer_size(LV2_URID type) { - if (type == _uris->atom_Float) { + if (type == _uris.atom_Float) { return sizeof(LV2_Atom_Float); - } else if (type == _uris->atom_Sound) { + } else if (type == _uris.atom_Sound) { return audio_buffer_size(_engine.driver()->block_length()); - } else if (type == _uris->atom_Sequence) { + } else if (type == _uris.atom_Sequence) { return _engine.driver()->block_length() * EVENT_BYTES_PER_FRAME; } else { return 0; @@ -136,11 +134,11 @@ BufferFactory::create(LV2_URID type, uint32_t capacity) capacity = default_buffer_size(type); } - if (type == _uris->atom_Float) { + if (type == _uris.atom_Float) { assert(capacity >= sizeof(LV2_Atom_Float)); buffer = new AudioBuffer(*this, type, capacity); - } else if (type == _uris->atom_Sound) { - assert(capacity >= default_buffer_size(_uris->atom_Sound)); + } else if (type == _uris.atom_Sound) { + assert(capacity >= default_buffer_size(_uris.atom_Sound)); buffer = new AudioBuffer(*this, type, capacity); } else { buffer = new Buffer(*this, type, capacity); diff --git a/src/server/BufferFactory.hpp b/src/server/BufferFactory.hpp index 1ec11ca1..04b9bf9d 100644 --- a/src/server/BufferFactory.hpp +++ b/src/server/BufferFactory.hpp @@ -46,9 +46,7 @@ class Engine; class BufferFactory { public: - BufferFactory(Engine& engine, - SharedPtr uris); - + BufferFactory(Engine& engine, Shared::URIs& uris); ~BufferFactory(); static uint32_t audio_buffer_size(SampleCount nframes); @@ -60,9 +58,9 @@ public: void set_block_length(SampleCount block_length); - Ingen::Forge& forge(); - Ingen::Shared::URIs& uris() { return *_uris.get(); } - Engine& engine() { return _engine; } + Forge& forge(); + Shared::URIs& uris() { return _uris; } + Engine& engine() { return _engine; } private: friend class Buffer; @@ -71,9 +69,9 @@ private: BufferRef create(LV2_URID type, uint32_t capacity=0); inline Raul::AtomicPtr& free_list(LV2_URID type) { - if (type == _uris->atom_Float) { + if (type == _uris.atom_Float) { return _free_control; - } else if (type == _uris->atom_Sound) { + } else if (type == _uris.atom_Sound) { return _free_audio; } else { return _free_object; @@ -86,9 +84,9 @@ private: Raul::AtomicPtr _free_control; Raul::AtomicPtr _free_object; - Glib::Mutex _mutex; - Engine& _engine; - SharedPtr _uris; + Glib::Mutex _mutex; + Engine& _engine; + Shared::URIs& _uris; BufferRef _silent_buffer; }; diff --git a/src/server/ControlBindings.cpp b/src/server/ControlBindings.cpp index 1cf8e969..2ff5259b 100644 --- a/src/server/ControlBindings.cpp +++ b/src/server/ControlBindings.cpp @@ -42,7 +42,7 @@ ControlBindings::ControlBindings(Engine& engine) , _learn_port(NULL) , _bindings(new Bindings()) , _feedback(new Buffer(*_engine.buffer_factory(), - engine.world()->uris()->atom_Sequence, + engine.world()->uris().atom_Sequence, 4096)) // FIXME: capacity? { } @@ -56,7 +56,7 @@ ControlBindings::Key ControlBindings::port_binding(PortImpl* port) const { ThreadManager::assert_thread(THREAD_PRE_PROCESS); - const Ingen::Shared::URIs& uris = *_engine.world()->uris().get(); + const Ingen::Shared::URIs& uris = _engine.world()->uris(); const Raul::Atom& binding = port->get_property(uris.ingen_controlBinding); return binding_key(binding); } @@ -64,7 +64,7 @@ ControlBindings::port_binding(PortImpl* port) const ControlBindings::Key ControlBindings::binding_key(const Raul::Atom& binding) const { - const Ingen::Shared::URIs& uris = *_engine.world()->uris().get(); + const Ingen::Shared::URIs& uris = _engine.world()->uris(); Key key; if (binding.type() == _engine.world()->forge().Dict) { const Raul::Atom::DictValue& dict = binding.get_dict(); @@ -126,7 +126,7 @@ ControlBindings::port_value_changed(ProcessContext& context, const Raul::Atom& value_atom) { Ingen::Shared::World* world = context.engine().world(); - const Ingen::Shared::URIs& uris = *world->uris().get(); + const Ingen::Shared::URIs& uris = world->uris(); if (key) { int16_t value = port_value_to_control( port, key.type, value_atom, port->minimum(), port->maximum()); @@ -274,7 +274,7 @@ ControlBindings::set_port_value(ProcessContext& context, bool ControlBindings::bind(ProcessContext& context, Key key) { - const Ingen::Shared::URIs& uris = *context.engine().world()->uris().get(); + const Ingen::Shared::URIs& uris = context.engine().world()->uris(); assert(_learn_port); if (key.type == MIDI_NOTE) { bool toggled = _learn_port->has_property(uris.lv2_portProperty, uris.lv2_toggled); @@ -345,7 +345,7 @@ ControlBindings::pre_process(ProcessContext& context, Buffer* buffer) _feedback->clear(); Ingen::Shared::World* world = context.engine().world(); - const Ingen::Shared::URIs& uris = *world->uris().get(); + const Ingen::Shared::URIs& uris = world->uris(); if (!_learn_port && bindings->empty()) { // Don't bother reading input diff --git a/src/server/Engine.cpp b/src/server/Engine.cpp index 5652db27..8029e607 100644 --- a/src/server/Engine.cpp +++ b/src/server/Engine.cpp @@ -19,6 +19,7 @@ #include #include "events/CreatePort.hpp" +#include "ingen/shared/Configuration.hpp" #include "ingen/shared/LV2Features.hpp" #include "ingen/shared/Store.hpp" #include "ingen/shared/URIs.hpp" @@ -148,7 +149,7 @@ Engine::activate() _message_context->Thread::start(); - const Ingen::Shared::URIs& uris = *world()->uris().get(); + const Ingen::Shared::URIs& uris = world()->uris(); Ingen::Forge& forge = world()->forge(); // Create root patch diff --git a/src/server/EventWriter.cpp b/src/server/EventWriter.cpp index 7286cc9e..8dbd4425 100644 --- a/src/server/EventWriter.cpp +++ b/src/server/EventWriter.cpp @@ -148,7 +148,7 @@ EventWriter::set_property(const Raul::URI& uri, } } else { Resource::Properties remove; - remove.insert(make_pair(predicate, _engine.world()->uris()->wildcard)); + remove.insert(make_pair(predicate, _engine.world()->uris().wildcard)); Resource::Properties add; add.insert(make_pair(predicate, value)); _engine.enqueue_event( diff --git a/src/server/JackDriver.cpp b/src/server/JackDriver.cpp index 8803c0c6..da2d434a 100644 --- a/src/server/JackDriver.cpp +++ b/src/server/JackDriver.cpp @@ -26,6 +26,9 @@ #include "ingen/serialisation/Serialiser.hpp" #endif +#include "ingen/shared/Configuration.hpp" +#include "ingen/shared/LV2Features.hpp" +#include "ingen/shared/World.hpp" #include "lv2/lv2plug.in/ns/ext/atom/util.h" #include "raul/List.hpp" #include "raul/log.hpp" @@ -43,8 +46,6 @@ #include "PostProcessor.hpp" #include "ProcessSlave.hpp" #include "ThreadManager.hpp" -#include "ingen/shared/LV2Features.hpp" -#include "ingen/shared/World.hpp" #include "util.hpp" #define LOG(s) (s("[JackDriver] ")) @@ -184,7 +185,7 @@ JackDriver::JackDriver(Engine& engine) , _sample_rate(0) , _is_activated(false) { - _midi_event_type = _engine.world()->uris()->midi_MidiEvent; + _midi_event_type = _engine.world()->uris().midi_MidiEvent; } JackDriver::~JackDriver() diff --git a/src/server/LV2Info.cpp b/src/server/LV2Info.cpp index 9180b421..2aa68271 100644 --- a/src/server/LV2Info.cpp +++ b/src/server/LV2Info.cpp @@ -42,9 +42,9 @@ LV2Info::LV2Info(Ingen::Shared::World* world) { assert(world); - world->lv2_features()->add_feature( + world->lv2_features().add_feature( SharedPtr(new ResizeFeature())); - world->lv2_features()->add_feature( + world->lv2_features().add_feature( SharedPtr(new RequestRunFeature())); } diff --git a/src/server/LV2Node.cpp b/src/server/LV2Node.cpp index 68a771e8..f1bf2d3d 100644 --- a/src/server/LV2Node.cpp +++ b/src/server/LV2Node.cpp @@ -150,8 +150,7 @@ LV2Node::instantiate(BufferFactory& bufs) _ports = new Raul::Array(num_ports, NULL); _instances = new Instances(_polyphony, SharedPtr()); - _features = info->world().lv2_features()->lv2_features(&info->world(), - this); + _features = info->world().lv2_features().lv2_features(&info->world(), this); uint32_t port_buffer_size = 0; LilvNode* work_schedule = lilv_new_uri(info->lv2_world(), @@ -247,7 +246,7 @@ LV2Node::instantiate(BufferFactory& bufs) if (lilv_node_is_uri(type)) { port->add_property(uris.atom_bufferType, forge.alloc_uri(lilv_node_as_uri(type))); - buffer_type = bufs.engine().world()->uri_map()->map_uri( + buffer_type = bufs.engine().world()->uri_map().map_uri( lilv_node_as_uri(type)); } } diff --git a/src/server/LV2Plugin.cpp b/src/server/LV2Plugin.cpp index 93e2d1d6..20f68c17 100644 --- a/src/server/LV2Plugin.cpp +++ b/src/server/LV2Plugin.cpp @@ -34,7 +34,7 @@ namespace Ingen { namespace Server { LV2Plugin::LV2Plugin(SharedPtr lv2_info, const std::string& uri) - : PluginImpl(*lv2_info->world().uris().get(), Plugin::LV2, uri) + : PluginImpl(lv2_info->world().uris(), Plugin::LV2, uri) , _lilv_plugin(NULL) , _lv2_info(lv2_info) { diff --git a/src/server/NodeFactory.cpp b/src/server/NodeFactory.cpp index 231a7db1..e64257be 100644 --- a/src/server/NodeFactory.cpp +++ b/src/server/NodeFactory.cpp @@ -99,7 +99,7 @@ NodeFactory::load_plugins() void NodeFactory::load_internal_plugins() { - Ingen::Shared::URIs& uris = *_world->uris().get(); + Ingen::Shared::URIs& uris = _world->uris(); InternalPlugin* controller_plug = ControllerNode::internal_plugin(uris); _plugins.insert(make_pair(controller_plug->uri(), controller_plug)); diff --git a/src/server/Notification.cpp b/src/server/Notification.cpp index 05570a0f..b4c55da1 100644 --- a/src/server/Notification.cpp +++ b/src/server/Notification.cpp @@ -28,7 +28,7 @@ void Notification::post_process(Notification& note, Engine& engine) { - const Ingen::Shared::URIs& uris = *engine.world()->uris().get(); + const Ingen::Shared::URIs& uris = engine.world()->uris(); Ingen::Forge& forge = engine.world()->forge(); switch (note.type) { case PORT_VALUE: diff --git a/src/server/PatchImpl.cpp b/src/server/PatchImpl.cpp index b17d0475..f24ab574 100644 --- a/src/server/PatchImpl.cpp +++ b/src/server/PatchImpl.cpp @@ -44,8 +44,8 @@ PatchImpl::PatchImpl(Engine& engine, PatchImpl* parent, SampleRate srate, uint32_t internal_poly) - : NodeImpl(new PatchPlugin(*engine.world()->uris().get(), - engine.world()->uris()->ingen_Patch.c_str(), + : NodeImpl(new PatchPlugin(engine.world()->uris(), + engine.world()->uris().ingen_Patch.c_str(), "patch", "Ingen Patch"), symbol, poly, parent, srate) , _engine(engine) diff --git a/src/server/events/CreateNode.cpp b/src/server/events/CreateNode.cpp index 9a9df50e..2b9c6766 100644 --- a/src/server/events/CreateNode.cpp +++ b/src/server/events/CreateNode.cpp @@ -55,7 +55,7 @@ CreateNode::CreateNode(Engine& engine, , _properties(properties) { const Resource::Properties::const_iterator p = properties.find( - engine.world()->uris()->ingen_polyphonic); + engine.world()->uris().ingen_polyphonic); if (p != properties.end() && p->second.type() == engine.world()->forge().Bool && p->second.get_bool()) _polyphonic = true; diff --git a/src/server/events/CreatePatch.cpp b/src/server/events/CreatePatch.cpp index d23c4506..22c4a817 100644 --- a/src/server/events/CreatePatch.cpp +++ b/src/server/events/CreatePatch.cpp @@ -76,7 +76,7 @@ CreatePatch::pre_process() if (_parent != NULL && _poly > 1 && _poly == static_cast(_parent->internal_poly())) poly = _poly; - const Ingen::Shared::URIs& uris = *_engine.world()->uris().get(); + const Ingen::Shared::URIs& uris = _engine.world()->uris(); _patch = new PatchImpl(_engine, path.symbol(), poly, _parent, _engine.driver()->sample_rate(), _poly); diff --git a/src/server/events/CreatePort.cpp b/src/server/events/CreatePort.cpp index 448f7768..872b79c4 100644 --- a/src/server/events/CreatePort.cpp +++ b/src/server/events/CreatePort.cpp @@ -55,7 +55,7 @@ CreatePort::CreatePort(Engine& engine, , _properties(properties) , _is_output(is_output) { - const Ingen::Shared::URIs& uris = *_engine.world()->uris().get(); + const Ingen::Shared::URIs& uris = _engine.world()->uris(); typedef Resource::Properties::const_iterator Iterator; typedef std::pair Range; @@ -77,7 +77,7 @@ CreatePort::CreatePort(Engine& engine, const Range buffer_types = properties.equal_range(uris.atom_bufferType); for (Iterator i = buffer_types.first; i != buffer_types.second; ++i) { if (i->second.type() == _engine.world()->forge().URI) { - _buffer_type = _engine.world()->uri_map()->map_uri(i->second.get_uri()); + _buffer_type = _engine.world()->uri_map().map_uri(i->second.get_uri()); } } @@ -96,7 +96,7 @@ CreatePort::pre_process() _patch = _engine.engine_store()->find_patch(_path.parent()); - const Ingen::Shared::URIs& uris = *_engine.world()->uris().get(); + const Ingen::Shared::URIs& uris = _engine.world()->uris(); if (_patch != NULL) { assert(_patch->path() == _path.parent()); diff --git a/src/server/events/Get.cpp b/src/server/events/Get.cpp index 0f1a16d7..503726a3 100644 --- a/src/server/events/Get.cpp +++ b/src/server/events/Get.cpp @@ -69,7 +69,7 @@ Get::post_process() respond(SUCCESS); // TODO: Keep a proper RDF model of the engine if (_request_client) { - Shared::URIs& uris = *_engine.world()->uris().get(); + Shared::URIs& uris = _engine.world()->uris(); _request_client->set_property( uris.ingen_engine, uris.ingen_sampleRate, diff --git a/src/server/events/SetMetadata.cpp b/src/server/events/SetMetadata.cpp index 38e7490c..5d447895 100644 --- a/src/server/events/SetMetadata.cpp +++ b/src/server/events/SetMetadata.cpp @@ -79,13 +79,13 @@ SetMetadata::SetMetadata(Engine& engine, for (iterator i = properties.begin(); i != properties.end(); ++i) { LOG(info) << " + " << i->first << " = " << engine.world()->forge().str(i->second) - << " :: " << engine.world()->uri_map()->unmap_uri(i->second.type()) << endl; + << " :: " << engine.world()->uri_map().unmap_uri(i->second.type()) << endl; } typedef Resource::Properties::const_iterator iterator; for (iterator i = remove.begin(); i != remove.end(); ++i) { LOG(info) << " - " << i->first << " = " << engine.world()->forge().str(i->second) - << " :: " << engine.world()->uri_map()->unmap_uri(i->second.type()) << endl; + << " :: " << engine.world()->uri_map().unmap_uri(i->second.type()) << endl; } LOG(info) << "}" << endl; */ @@ -118,7 +118,7 @@ SetMetadata::pre_process() return; } - const Ingen::Shared::URIs& uris = *_engine.world()->uris().get(); + const Ingen::Shared::URIs& uris = _engine.world()->uris(); if (is_graph_object && !_object) { Raul::Path path(_subject.str()); @@ -272,7 +272,7 @@ SetMetadata::execute(ProcessContext& context) return; } - const Ingen::Shared::URIs& uris = *_engine.world()->uris().get(); + const Ingen::Shared::URIs& uris = _engine.world()->uris(); if (_create_event) { _create_event->execute(context); diff --git a/src/server/events/SetPortValue.cpp b/src/server/events/SetPortValue.cpp index 6305ff1e..db3a72e4 100644 --- a/src/server/events/SetPortValue.cpp +++ b/src/server/events/SetPortValue.cpp @@ -91,7 +91,7 @@ SetPortValue::pre_process() if (_port) { _port->set_value(_value); - _port->set_property(_engine.world()->uris()->ingen_value, _value); + _port->set_property(_engine.world()->uris().ingen_value, _value); } _binding = _engine.control_bindings()->port_binding(_port); @@ -119,7 +119,7 @@ SetPortValue::apply(Context& context) if (_status == SUCCESS && !_port) _port = _engine.engine_store()->find_port(_port_path); - Ingen::Shared::URIs& uris = *_engine.world()->uris().get(); + Ingen::Shared::URIs& uris = _engine.world()->uris(); if (!_port) { if (_status == SUCCESS) @@ -153,7 +153,7 @@ SetPortValue::post_process() if (!_status) { _engine.broadcaster()->set_property( _port_path, - _engine.world()->uris()->ingen_value, + _engine.world()->uris().ingen_value, _value); } } diff --git a/src/server/ingen_jack.cpp b/src/server/ingen_jack.cpp index a1f068fe..928996e5 100644 --- a/src/server/ingen_jack.cpp +++ b/src/server/ingen_jack.cpp @@ -14,8 +14,10 @@ along with Ingen. If not, see . */ +#include "ingen/shared/Configuration.hpp" #include "ingen/shared/Module.hpp" #include "ingen/shared/World.hpp" +#include "raul/Configuration.hpp" #include "raul/log.hpp" #include "JackDriver.hpp" diff --git a/src/server/ingen_lv2.cpp b/src/server/ingen_lv2.cpp index 3d3a367c..d6602173 100644 --- a/src/server/ingen_lv2.cpp +++ b/src/server/ingen_lv2.cpp @@ -140,12 +140,12 @@ private: public: LV2Driver(Engine& engine, SampleCount buffer_size, SampleCount sample_rate) : _context(engine) - , _reader(*engine.world()->uri_map().get(), - *engine.world()->uris().get(), + , _reader(engine.world()->uri_map(), + engine.world()->uris(), engine.world()->forge(), *engine.world()->interface().get()) - , _writer(*engine.world()->uri_map().get(), - *engine.world()->uris().get(), + , _writer(engine.world()->uri_map(), + engine.world()->uris(), *this) , _to_ui(buffer_size * sizeof(float)) // FIXME: size , _root_patch(NULL) @@ -240,7 +240,7 @@ public: const uint32_t capacity = seq->atom.size; // Initialise output port buffer to an empty Sequence - seq->atom.type = _context.engine().world()->uris()->atom_Sequence; + seq->atom.type = _context.engine().world()->uris().atom_Sequence; seq->atom.size = sizeof(LV2_Atom_Sequence_Body); const uint32_t read_space = _to_ui.read_space(); -- cgit v1.2.1