summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.clang-tidy1
-rw-r--r--src/server/ArcImpl.cpp38
-rw-r--r--src/server/BlockFactory.cpp6
-rw-r--r--src/server/BlockImpl.cpp1
-rw-r--r--src/server/BlockImpl.hpp4
-rw-r--r--src/server/Buffer.cpp11
-rw-r--r--src/server/Buffer.hpp3
-rw-r--r--src/server/DuplexPort.cpp1
-rw-r--r--src/server/DuplexPort.hpp3
-rw-r--r--src/server/InputPort.cpp1
-rw-r--r--src/server/InputPort.hpp3
-rw-r--r--src/server/JackDriver.cpp8
-rw-r--r--src/server/PortImpl.cpp12
-rw-r--r--src/server/PortImpl.hpp3
-rw-r--r--src/server/PortType.hpp106
-rw-r--r--src/server/events/CreatePort.cpp2
-rw-r--r--src/server/events/CreatePort.hpp2
17 files changed, 100 insertions, 105 deletions
diff --git a/.clang-tidy b/.clang-tidy
index 53dace0f..6e3cd008 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -26,6 +26,7 @@ Checks: >
-modernize-use-nodiscard,
-modernize-use-trailing-return-type,
-performance-enum-size,
+ -readability-avoid-nested-conditional-operator,
-readability-identifier-length,
-readability-implicit-bool-conversion,
CheckOptions:
diff --git a/src/server/ArcImpl.cpp b/src/server/ArcImpl.cpp
index 0b503534..5c8f384b 100644
--- a/src/server/ArcImpl.cpp
+++ b/src/server/ArcImpl.cpp
@@ -84,32 +84,30 @@ ArcImpl::can_connect(const PortImpl* src, const InputPort* dst)
{
const ingen::URIs& uris = src->bufs().uris();
return (
- // (Audio | Control | CV) => (Audio | Control | CV)
- ( (src->is_a(PortType::ID::CONTROL) ||
- src->is_a(PortType::ID::AUDIO) ||
- src->is_a(PortType::ID::CV))
- && (dst->is_a(PortType::ID::CONTROL)
- || dst->is_a(PortType::ID::AUDIO)
- || dst->is_a(PortType::ID::CV)))
+ // (Audio | Control | CV) => (Audio | Control | CV)
+ ((src->is_a(PortType::CONTROL) || src->is_a(PortType::AUDIO) ||
+ src->is_a(PortType::CV)) &&
+ (dst->is_a(PortType::CONTROL) || dst->is_a(PortType::AUDIO) ||
+ dst->is_a(PortType::CV)))
- // Equal types
- || (src->type() == dst->type() &&
- src->buffer_type() == dst->buffer_type())
+ // Equal types
+ ||
+ (src->type() == dst->type() && src->buffer_type() == dst->buffer_type())
- // Control => atom:Float Value
- || (src->is_a(PortType::ID::CONTROL) && dst->supports(uris.atom_Float))
+ // Control => atom:Float Value
+ || (src->is_a(PortType::CONTROL) && dst->supports(uris.atom_Float))
- // Audio => atom:Sound Value
- || (src->is_a(PortType::ID::AUDIO) && dst->supports(uris.atom_Sound))
+ // Audio => atom:Sound Value
+ || (src->is_a(PortType::AUDIO) && dst->supports(uris.atom_Sound))
- // atom:Float Value => Control
- || (src->supports(uris.atom_Float) && dst->is_a(PortType::ID::CONTROL))
+ // atom:Float Value => Control
+ || (src->supports(uris.atom_Float) && dst->is_a(PortType::CONTROL))
- // atom:Float Value => CV
- || (src->supports(uris.atom_Float) && dst->is_a(PortType::ID::CV))
+ // atom:Float Value => CV
+ || (src->supports(uris.atom_Float) && dst->is_a(PortType::CV))
- // atom:Sound Value => Audio
- || (src->supports(uris.atom_Sound) && dst->is_a(PortType::ID::AUDIO)));
+ // atom:Sound Value => Audio
+ || (src->supports(uris.atom_Sound) && dst->is_a(PortType::AUDIO)));
}
} // namespace ingen::server
diff --git a/src/server/BlockFactory.cpp b/src/server/BlockFactory.cpp
index 4c8dd1d7..87ef4a9c 100644
--- a/src/server/BlockFactory.cpp
+++ b/src/server/BlockFactory.cpp
@@ -148,8 +148,10 @@ BlockFactory::load_lv2_plugins()
// Build an array of port type nodes for checking compatibility
using Types = std::vector<std::shared_ptr<LilvNode>>;
Types types;
- for (unsigned t = PortType::ID::AUDIO; t <= PortType::ID::ATOM; ++t) {
- const URI uri{PortType(static_cast<PortType::ID>(t)).uri()};
+ for (auto t = static_cast<unsigned>(PortType::AUDIO);
+ t <= static_cast<unsigned>(PortType::ATOM);
+ ++t) {
+ const URI uri = port_type_uri(static_cast<PortType>(t));
types.push_back(std::shared_ptr<LilvNode>(
lilv_new_uri(_world.lilv_world(), uri.c_str()), lilv_node_free));
}
diff --git a/src/server/BlockImpl.cpp b/src/server/BlockImpl.cpp
index cae6b252..658df0b6 100644
--- a/src/server/BlockImpl.cpp
+++ b/src/server/BlockImpl.cpp
@@ -20,6 +20,7 @@
#include "GraphImpl.hpp"
#include "PluginImpl.hpp"
#include "PortImpl.hpp"
+#include "PortType.hpp"
#include "RunContext.hpp"
#include "ThreadManager.hpp"
diff --git a/src/server/BlockImpl.hpp b/src/server/BlockImpl.hpp
index ef76e9bf..a24bf411 100644
--- a/src/server/BlockImpl.hpp
+++ b/src/server/BlockImpl.hpp
@@ -19,7 +19,6 @@
#include "BufferRef.hpp"
#include "NodeImpl.hpp"
-#include "PortType.hpp"
#include "State.hpp"
#include "types.hpp"
@@ -43,6 +42,9 @@ class Symbol;
} // namespace raul
namespace ingen {
+
+enum class PortType;
+
class Node;
namespace server {
diff --git a/src/server/Buffer.cpp b/src/server/Buffer.cpp
index 553ae92e..ea3205fb 100644
--- a/src/server/Buffer.cpp
+++ b/src/server/Buffer.cpp
@@ -18,6 +18,7 @@
#include "BufferFactory.hpp"
#include "Engine.hpp"
+#include "PortType.hpp"
#include "RunContext.hpp"
#include "ingen_config.h"
@@ -182,18 +183,18 @@ Buffer::resize(uint32_t capacity)
void*
Buffer::port_data(PortType port_type, SampleCount offset)
{
- switch (port_type.id()) {
- case PortType::ID::CONTROL:
+ switch (port_type) {
+ case PortType::CONTROL:
return &_value_buffer->get<LV2_Atom_Float>()->body;
- case PortType::ID::CV:
- case PortType::ID::AUDIO:
+ case PortType::CV:
+ case PortType::AUDIO:
if (_type == _factory.uris().atom_Float) {
return &get<LV2_Atom_Float>()->body;
} else if (_type == _factory.uris().atom_Sound) {
return static_cast<Sample*>(_buf) + offset;
}
break;
- case PortType::ID::ATOM:
+ case PortType::ATOM:
if (_type != _factory.uris().atom_Sound) {
return _buf;
}
diff --git a/src/server/Buffer.hpp b/src/server/Buffer.hpp
index 8a64e621..5997281e 100644
--- a/src/server/Buffer.hpp
+++ b/src/server/Buffer.hpp
@@ -19,7 +19,6 @@
#include "BufferFactory.hpp"
#include "BufferRef.hpp"
-#include "PortType.hpp"
#include "server.h"
#include "types.hpp"
@@ -34,6 +33,8 @@
namespace ingen {
+enum class PortType;
+
class Atom;
namespace server {
diff --git a/src/server/DuplexPort.cpp b/src/server/DuplexPort.cpp
index 941beb10..ce47fa86 100644
--- a/src/server/DuplexPort.cpp
+++ b/src/server/DuplexPort.cpp
@@ -23,6 +23,7 @@
#include "Engine.hpp"
#include "GraphImpl.hpp"
#include "NodeImpl.hpp"
+#include "PortType.hpp"
#include "ingen/Atom.hpp"
#include "ingen/Forge.hpp"
diff --git a/src/server/DuplexPort.hpp b/src/server/DuplexPort.hpp
index 3cc0efba..c06ad85f 100644
--- a/src/server/DuplexPort.hpp
+++ b/src/server/DuplexPort.hpp
@@ -19,7 +19,6 @@
#include "InputPort.hpp"
#include "PortImpl.hpp"
-#include "PortType.hpp"
#include "server.h"
#include "types.hpp"
@@ -38,6 +37,8 @@ class Symbol;
namespace ingen {
+enum class PortType;
+
class Atom;
class Properties;
diff --git a/src/server/InputPort.cpp b/src/server/InputPort.cpp
index 4a464ea8..5d3c4eb7 100644
--- a/src/server/InputPort.cpp
+++ b/src/server/InputPort.cpp
@@ -23,6 +23,7 @@
#include "BufferRef.hpp"
#include "GraphImpl.hpp"
#include "NodeImpl.hpp"
+#include "PortType.hpp"
#include "RunContext.hpp"
#include "mix.hpp"
diff --git a/src/server/InputPort.hpp b/src/server/InputPort.hpp
index ab4c3e54..a90e7390 100644
--- a/src/server/InputPort.hpp
+++ b/src/server/InputPort.hpp
@@ -19,7 +19,6 @@
#include "ArcImpl.hpp" // IWYU pragma: keep
#include "PortImpl.hpp"
-#include "PortType.hpp"
#include "types.hpp"
#include "lv2/urid/urid.h"
@@ -37,6 +36,8 @@ class Symbol;
namespace ingen {
+enum class PortType;
+
class Atom;
namespace server {
diff --git a/src/server/JackDriver.cpp b/src/server/JackDriver.cpp
index 68974b12..6624939e 100644
--- a/src/server/JackDriver.cpp
+++ b/src/server/JackDriver.cpp
@@ -533,15 +533,19 @@ JackDriver::_shutdown_cb()
int
JackDriver::_block_length_cb(jack_nframes_t nframes)
{
+ const URIs& uris = _engine.world().uris();
+
if (_engine.root_graph()) {
_block_length = nframes;
_seq_size = static_cast<uint32_t>(
jack_port_type_get_buffer_size(_client, JACK_DEFAULT_MIDI_TYPE));
_engine.root_graph()->set_buffer_size(
- _engine.run_context(), *_engine.buffer_factory(), PortType::AUDIO,
+ _engine.run_context(), *_engine.buffer_factory(),
+ uris.atom_Sound,
_engine.buffer_factory()->audio_buffer_size(nframes));
_engine.root_graph()->set_buffer_size(
- _engine.run_context(), *_engine.buffer_factory(), PortType::ATOM,
+ _engine.run_context(), *_engine.buffer_factory(),
+ uris.atom_Sequence,
_seq_size);
}
return 0;
diff --git a/src/server/PortImpl.cpp b/src/server/PortImpl.cpp
index c7b20f2b..2c9ab3ac 100644
--- a/src/server/PortImpl.cpp
+++ b/src/server/PortImpl.cpp
@@ -136,13 +136,13 @@ PortImpl::set_type(PortType port_type, LV2_URID buffer_type)
remove_property(uris.rdf_type, uris.lv2_CVPort);
remove_property(uris.rdf_type, uris.lv2_ControlPort);
remove_property(uris.rdf_type, uris.atom_AtomPort);
- add_property(uris.rdf_type, world.forge().make_urid(port_type.uri()));
+ add_property(uris.rdf_type, world.forge().make_urid(port_type_uri(port_type)));
// Update audio thread types
_type = port_type;
_buffer_type = buffer_type;
if (!_buffer_type) {
- switch (_type.id()) {
+ switch (_type) {
case PortType::CONTROL:
_buffer_type = uris.atom_Float;
break;
@@ -238,7 +238,7 @@ PortImpl::set_voice_value(const RunContext& ctx,
FrameTime time,
Sample value)
{
- switch (_type.id()) {
+ switch (_type) {
case PortType::CONTROL:
if (buffer(voice)->value()) {
const_cast<LV2_Atom_Float*>(
@@ -420,7 +420,7 @@ PortImpl::set_is_driver_port(BufferFactory&)
void
PortImpl::clear_buffers(const RunContext& ctx)
{
- switch (_type.id()) {
+ switch (_type) {
case PortType::AUDIO:
default:
for (uint32_t v = 0; v < _poly; ++v) {
@@ -453,7 +453,7 @@ PortImpl::monitor(RunContext& ctx, bool send_now)
_frames_since_monitor += ctx.nframes();
const bool time_to_send = send_now || _frames_since_monitor >= period;
- const bool is_sequence = (_type.id() == PortType::ATOM &&
+ const bool is_sequence = (_type == PortType::ATOM &&
_buffer_type == _bufs.uris().atom_Sequence);
if (!time_to_send && !(is_sequence && _monitored) && (!is_sequence && buffer(0)->value())) {
return;
@@ -463,7 +463,7 @@ PortImpl::monitor(RunContext& ctx, bool send_now)
const URIs& uris = ctx.engine().world().uris();
LV2_URID key = 0;
float val = 0.0f;
- switch (_type.id()) {
+ switch (_type) {
case PortType::UNKNOWN:
break;
case PortType::AUDIO:
diff --git a/src/server/PortImpl.hpp b/src/server/PortImpl.hpp
index 64c3322f..3a1500bc 100644
--- a/src/server/PortImpl.hpp
+++ b/src/server/PortImpl.hpp
@@ -20,7 +20,6 @@
#include "BufferFactory.hpp"
#include "BufferRef.hpp"
#include "NodeImpl.hpp"
-#include "PortType.hpp"
#include "RunContext.hpp"
#include "server.h"
#include "types.hpp"
@@ -42,6 +41,8 @@ class Symbol;
namespace ingen {
+enum class PortType;
+
class Properties;
namespace server {
diff --git a/src/server/PortType.hpp b/src/server/PortType.hpp
index 65f87d02..c403ba5b 100644
--- a/src/server/PortType.hpp
+++ b/src/server/PortType.hpp
@@ -14,81 +14,61 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef INGEN_INTERFACE_PORTTYPE_HPP
-#define INGEN_INTERFACE_PORTTYPE_HPP
+#ifndef INGEN_ENGINE_PORTTYPE_HPP
+#define INGEN_ENGINE_PORTTYPE_HPP
#include "ingen/URI.hpp"
#include "lv2/atom/atom.h"
#include "lv2/core/lv2.h"
-#include <cassert>
-
namespace ingen {
-/** The type of a port.
- *
- * This type refers to the type of the port itself (not necessarily the type
- * of its contents). Ports with different types can contain the same type of
- * data, but may e.g. have different access semantics.
- */
-class PortType
-{
-public:
- enum ID {
- UNKNOWN = 0,
- AUDIO = 1,
- CONTROL = 2,
- CV = 3,
- ATOM = 4
- };
+/// The type of a port
+enum class PortType {
+ UNKNOWN,
+ AUDIO,
+ CONTROL,
+ CV,
+ ATOM,
+};
- explicit PortType(const URI& uri)
- : _id(UNKNOWN)
- {
- if (uri == type_uri(AUDIO)) {
- _id = AUDIO;
- } else if (uri == type_uri(CONTROL)) {
- _id = CONTROL;
- } else if (uri == type_uri(CV)) {
- _id = CV;
- } else if (uri == type_uri(ATOM)) {
- _id = ATOM;
- }
+/// Return the URI for `port_type`
+inline URI
+port_type_uri(const PortType port_type)
+{
+ switch (port_type) {
+ case PortType::UNKNOWN:
+ break;
+ case PortType::AUDIO:
+ return URI{LV2_CORE__AudioPort};
+ case PortType::CONTROL:
+ return URI{LV2_CORE__ControlPort};
+ case PortType::CV:
+ return URI{LV2_CORE__CVPort};
+ case PortType::ATOM:
+ return URI{LV2_ATOM__AtomPort};
}
- PortType(ID id) noexcept : _id(id) {}
-
- const URI& uri() const { return type_uri(_id); }
- ID id() const { return _id; }
-
- bool operator==(const ID& id) const { return (_id == id); }
- bool operator!=(const ID& id) const { return (_id != id); }
- bool operator==(const PortType& type) const { return (_id == type._id); }
- bool operator!=(const PortType& type) const { return (_id != type._id); }
- bool operator<(const PortType& type) const { return (_id < type._id); }
+ return URI{"http://www.w3.org/2002/07/owl#Nothing"};
+}
- bool is_audio() { return _id == AUDIO; }
- bool is_control() { return _id == CONTROL; }
- bool is_cv() { return _id == CV; }
- bool is_atom() { return _id == ATOM; }
-
-private:
- static const URI& type_uri(unsigned id_num) {
- assert(id_num <= ATOM);
- static const URI uris[] = {
- URI("http://www.w3.org/2002/07/owl#Nothing"),
- URI(LV2_CORE__AudioPort),
- URI(LV2_CORE__ControlPort),
- URI(LV2_CORE__CVPort),
- URI(LV2_ATOM__AtomPort)
- };
- return uris[id_num];
- }
-
- ID _id;
-};
+/// Return the type with the given `uri`, or #PortType::UNKNOWN
+inline PortType
+port_type_from_uri(const URI& uri)
+{
+ static const URI lv2_AudioPort = URI{LV2_CORE__AudioPort};
+ static const URI lv2_ControlPort = URI{LV2_CORE__ControlPort};
+ static const URI lv2_CVPort = URI{LV2_CORE__CVPort};
+ static const URI atom_AtomPort = URI{LV2_ATOM__AtomPort};
+
+ return (uri == lv2_AudioPort) ? PortType::AUDIO
+ : (uri == lv2_ControlPort) ? PortType::CONTROL
+ : (uri == lv2_CVPort) ? PortType::CV
+ : (uri == atom_AtomPort) ? PortType::ATOM
+ : PortType::UNKNOWN;
+}
} // namespace ingen
-#endif // INGEN_INTERFACE_PORTTYPE_HPP
+#endif // INGEN_ENGINE_PORTTYPE_HPP
diff --git a/src/server/events/CreatePort.cpp b/src/server/events/CreatePort.cpp
index 4c054fd9..a4dbbf3f 100644
--- a/src/server/events/CreatePort.cpp
+++ b/src/server/events/CreatePort.cpp
@@ -23,6 +23,7 @@
#include "Engine.hpp"
#include "GraphImpl.hpp"
#include "PortImpl.hpp"
+#include "PortType.hpp"
#include "ingen/Atom.hpp"
#include "ingen/Forge.hpp"
@@ -55,7 +56,6 @@ CreatePort::CreatePort(Engine& engine,
const Properties& properties)
: Event(engine, client, id, timestamp)
, _path(std::move(path))
- , _port_type(PortType::UNKNOWN)
, _properties(properties)
{
const ingen::URIs& uris = _engine.world().uris();
diff --git a/src/server/events/CreatePort.hpp b/src/server/events/CreatePort.hpp
index 6d3e9ca2..acf81dd1 100644
--- a/src/server/events/CreatePort.hpp
+++ b/src/server/events/CreatePort.hpp
@@ -72,7 +72,7 @@ private:
};
raul::Path _path;
- PortType _port_type;
+ PortType _port_type{PortType::UNKNOWN};
LV2_URID _buf_type{0};
GraphImpl* _graph{nullptr};
DuplexPort* _graph_port{nullptr};