From 967a8b9d6690a5ece385d07af04c322d645de23f Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 17 Dec 2017 23:46:20 +0100 Subject: Reduce port memory overhead --- src/server/ControlBindings.cpp | 4 ++-- src/server/DuplexPort.cpp | 8 ++++---- src/server/Engine.cpp | 12 ++++++------ src/server/LV2Block.cpp | 4 ++-- src/server/PortImpl.cpp | 4 ++-- src/server/PortImpl.hpp | 30 +++++++++++++++--------------- src/server/events/Delta.cpp | 6 +++--- src/server/events/Get.cpp | 6 +++--- 8 files changed, 37 insertions(+), 37 deletions(-) (limited to 'src/server') diff --git a/src/server/ControlBindings.cpp b/src/server/ControlBindings.cpp index 94a12a7e..2a269cac 100644 --- a/src/server/ControlBindings.cpp +++ b/src/server/ControlBindings.cpp @@ -210,8 +210,8 @@ ControlBindings::start_learn(PortImpl* port) static void get_range(RunContext& context, const PortImpl* port, float* min, float* max) { - *min = port->minimum().get(); - *max = port->maximum().get(); + *min = port->minimum(); + *max = port->maximum(); if (port->is_sample_rate()) { *min *= context.engine().sample_rate(); *max *= context.engine().sample_rate(); diff --git a/src/server/DuplexPort.cpp b/src/server/DuplexPort.cpp index 2823da05..7279dfb3 100644 --- a/src/server/DuplexPort.cpp +++ b/src/server/DuplexPort.cpp @@ -100,15 +100,15 @@ DuplexPort::inherit_neighbour(const PortImpl* port, /* TODO: This needs to become more sophisticated, and correct the situation if the port is disconnected. */ if (_type == PortType::CONTROL || _type == PortType::CV) { - if (port->minimum().get() < _min.get()) { + if (port->minimum() < _min) { _min = port->minimum(); remove.emplace(uris.lv2_minimum, uris.patch_wildcard); - add.emplace(uris.lv2_minimum, port->minimum()); + add.emplace(uris.lv2_minimum, _bufs.forge().make(port->minimum())); } - if (port->maximum().get() > _max.get()) { + if (port->maximum() > _max) { _max = port->maximum(); remove.emplace(uris.lv2_maximum, uris.patch_wildcard); - add.emplace(uris.lv2_maximum, port->maximum()); + add.emplace(uris.lv2_maximum, _bufs.forge().make(port->maximum())); } } else if (_type == PortType::ATOM) { for (auto i = port->properties().find(uris.atom_supports); diff --git a/src/server/Engine.cpp b/src/server/Engine.cpp index b880abf7..bef2aa3c 100644 --- a/src/server/Engine.cpp +++ b/src/server/Engine.cpp @@ -312,12 +312,12 @@ Engine::load_properties() const { const ingen::URIs& uris = world()->uris(); - return { { uris.ingen_meanRunLoad, - uris.forge.make(floorf(_run_load.mean) / 100.0f) }, - { uris.ingen_minRunLoad, - uris.forge.make(_run_load.min / 100.0f) }, - { uris.ingen_maxRunLoad, - uris.forge.make(_run_load.max / 100.0f) } }; + return {{uris.ingen_meanRunLoad, + Atom(uris.forge.make(floorf(_run_load.mean) / 100.0f))}, + {uris.ingen_minRunLoad, + Atom(uris.forge.make(_run_load.min / 100.0f))}, + {uris.ingen_maxRunLoad, + Atom(uris.forge.make(_run_load.max / 100.0f))}}; } bool diff --git a/src/server/LV2Block.cpp b/src/server/LV2Block.cpp index c2b8e973..765643d6 100644 --- a/src/server/LV2Block.cpp +++ b/src/server/LV2Block.cpp @@ -380,10 +380,10 @@ LV2Block::instantiate(BufferFactory& bufs, const LilvState* state) || port_type == PortType::CV)) { port->set_value(val); if (!std::isnan(min_values[j])) { - port->set_minimum(forge.make(min_values[j])); + port->set_minimum(min_values[j]); } if (!std::isnan(max_values[j])) { - port->set_maximum(forge.make(max_values[j])); + port->set_maximum(max_values[j]); } } diff --git a/src/server/PortImpl.cpp b/src/server/PortImpl.cpp index f03939d3..abb08c1c 100644 --- a/src/server/PortImpl.cpp +++ b/src/server/PortImpl.cpp @@ -62,8 +62,8 @@ PortImpl::PortImpl(BufferFactory& bufs, , _type(type) , _buffer_type(buffer_type) , _value(value) - , _min(bufs.forge().make(0.0f)) - , _max(bufs.forge().make(1.0f)) + , _min(0.0f) + , _max(1.0f) , _voices(bufs.maid().make_managed(poly)) , _connected_flag(false) , _monitored(false) diff --git a/src/server/PortImpl.hpp b/src/server/PortImpl.hpp index d9b81a16..aa58cfdb 100644 --- a/src/server/PortImpl.hpp +++ b/src/server/PortImpl.hpp @@ -125,15 +125,15 @@ public: const Atom& value() const { return _value; } void set_value(const Atom& v) { _value = v; } - const Atom& minimum() const { return _min; } - const Atom& maximum() const { return _max; } + float minimum() const { return _min; } + float maximum() const { return _max; } /* The following two methods store the range in variables so it can be accessed in the process thread, which is required for applying control bindings from incoming MIDI data. */ - void set_minimum(const Atom& min) { _min.set_rt(min); } - void set_maximum(const Atom& max) { _max.set_rt(max); } + void set_minimum(float min) { _min = min; } + void set_maximum(float max) { _max = max; } inline BufferRef buffer(uint32_t voice) const { return _voices->at((_poly == 1) ? 0 : voice).buffer; @@ -289,21 +289,21 @@ protected: PortType _type; LV2_URID _buffer_type; Atom _value; - Atom _min; - Atom _max; + float _min; + float _max; MPtr _voices; MPtr _prepared_voices; BufferRef _user_buffer; std::atomic_flag _connected_flag; - bool _monitored; - bool _force_monitor_update; - bool _is_morph; - bool _is_auto_morph; - bool _is_logarithmic; - bool _is_sample_rate; - bool _is_toggled; - bool _is_driver_port; - bool _is_output; + bool _monitored : 1; + bool _force_monitor_update : 1; + bool _is_morph : 1; + bool _is_auto_morph : 1; + bool _is_logarithmic : 1; + bool _is_sample_rate : 1; + bool _is_toggled : 1; + bool _is_driver_port : 1; + bool _is_output : 1; }; } // namespace server diff --git a/src/server/events/Delta.cpp b/src/server/events/Delta.cpp index 7404aea6..a0b7f2ef 100644 --- a/src/server/events/Delta.cpp +++ b/src/server/events/Delta.cpp @@ -561,11 +561,11 @@ Delta::execute(RunContext& context) block->set_enabled(false); break; case SpecialType::NONE: - if (port) { + if (port && value.type() == uris.atom_Float) { if (key == uris.lv2_minimum) { - port->set_minimum(value); + port->set_minimum(value.get()); } else if (key == uris.lv2_maximum) { - port->set_maximum(value); + port->set_maximum(value.get()); } } case SpecialType::LOADED_BUNDLE: diff --git a/src/server/events/Get.cpp b/src/server/events/Get.cpp index ad412beb..1134983d 100644 --- a/src/server/events/Get.cpp +++ b/src/server/events/Get.cpp @@ -91,11 +91,11 @@ Get::post_process() URIs& uris = _engine.world()->uris(); Properties props = { { uris.param_sampleRate, - uris.forge.make(int32_t(_engine.sample_rate())) }, + Atom(uris.forge.make(int32_t(_engine.sample_rate()))) }, { uris.bufsz_maxBlockLength, - uris.forge.make(int32_t(_engine.block_length())) }, + Atom(uris.forge.make(int32_t(_engine.block_length()))) }, { uris.ingen_numThreads, - uris.forge.make(int32_t(_engine.n_threads())) } }; + Atom(uris.forge.make(int32_t(_engine.n_threads()))) } }; const Properties load_props = _engine.load_properties(); props.insert(load_props.begin(), load_props.end()); -- cgit v1.2.1