summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/.clang-tidy29
-rw-r--r--src/AtomReader.cpp53
-rw-r--r--src/AtomWriter.cpp6
-rw-r--r--src/ClashAvoider.cpp125
-rw-r--r--src/ColorContext.cpp4
-rw-r--r--src/Configuration.cpp42
-rw-r--r--src/FilePath.cpp12
-rw-r--r--src/Forge.cpp2
-rw-r--r--src/LV2Features.cpp8
-rw-r--r--src/Log.cpp10
-rw-r--r--src/Parser.cpp67
-rw-r--r--src/Resource.cpp36
-rw-r--r--src/Serialiser.cpp14
-rw-r--r--src/SocketReader.cpp24
-rw-r--r--src/SocketWriter.cpp1
-rw-r--r--src/Store.cpp27
-rw-r--r--src/TurtleWriter.cpp20
-rw-r--r--src/URI.cpp9
-rw-r--r--src/URIMap.cpp3
-rw-r--r--src/URIs.cpp1
-rw-r--r--src/World.cpp20
-rw-r--r--src/client/.clang-tidy3
-rw-r--r--src/client/BlockModel.cpp15
-rw-r--r--src/client/ClientStore.cpp46
-rw-r--r--src/client/GraphModel.cpp27
-rw-r--r--src/client/ObjectModel.cpp6
-rw-r--r--src/client/PluginModel.cpp36
-rw-r--r--src/client/PluginUI.cpp10
-rw-r--r--src/client/ingen_client.cpp2
-rw-r--r--src/client/meson.build50
-rw-r--r--src/client/wscript24
-rw-r--r--src/gui/.clang-tidy49
-rw-r--r--src/gui/App.cpp15
-rw-r--r--src/gui/App.hpp24
-rw-r--r--src/gui/Arc.hpp4
-rw-r--r--src/gui/BreadCrumbs.cpp17
-rw-r--r--src/gui/BreadCrumbs.hpp2
-rw-r--r--src/gui/ConnectWindow.cpp40
-rw-r--r--src/gui/ConnectWindow.hpp44
-rw-r--r--src/gui/GraphBox.cpp18
-rw-r--r--src/gui/GraphCanvas.cpp33
-rw-r--r--src/gui/GraphCanvas.hpp8
-rw-r--r--src/gui/GraphPortModule.cpp4
-rw-r--r--src/gui/GraphPortModule.hpp2
-rw-r--r--src/gui/GraphTreeWindow.cpp59
-rw-r--r--src/gui/GraphTreeWindow.hpp10
-rw-r--r--src/gui/GraphView.cpp3
-rw-r--r--src/gui/GraphWindow.cpp4
-rw-r--r--src/gui/GraphWindow.hpp8
-rw-r--r--src/gui/LoadGraphWindow.cpp4
-rw-r--r--src/gui/LoadGraphWindow.hpp4
-rw-r--r--src/gui/LoadPluginWindow.cpp45
-rw-r--r--src/gui/LoadPluginWindow.hpp6
-rw-r--r--src/gui/MessagesWindow.cpp3
-rw-r--r--src/gui/MessagesWindow.hpp6
-rw-r--r--src/gui/NewSubgraphWindow.hpp14
-rw-r--r--src/gui/NodeMenu.cpp1
-rw-r--r--src/gui/NodeMenu.hpp10
-rw-r--r--src/gui/NodeModule.cpp20
-rw-r--r--src/gui/NodeModule.hpp8
-rw-r--r--src/gui/ObjectMenu.cpp7
-rw-r--r--src/gui/ObjectMenu.hpp22
-rw-r--r--src/gui/PluginMenu.cpp12
-rw-r--r--src/gui/PluginMenu.hpp8
-rw-r--r--src/gui/Port.cpp19
-rw-r--r--src/gui/Port.hpp4
-rw-r--r--src/gui/PortMenu.cpp3
-rw-r--r--src/gui/PortMenu.hpp12
-rw-r--r--src/gui/PropertiesWindow.cpp48
-rw-r--r--src/gui/PropertiesWindow.hpp24
-rw-r--r--src/gui/RDFS.cpp17
-rw-r--r--src/gui/RDFS.hpp4
-rw-r--r--src/gui/RenameWindow.hpp10
-rw-r--r--src/gui/Style.cpp42
-rw-r--r--src/gui/Style.hpp11
-rw-r--r--src/gui/ThreadedLoader.cpp2
-rw-r--r--src/gui/ThreadedLoader.hpp8
-rw-r--r--src/gui/URIEntry.cpp4
-rw-r--r--src/gui/URIEntry.hpp3
-rw-r--r--src/gui/WidgetFactory.cpp6
-rw-r--r--src/gui/WidgetFactory.hpp3
-rw-r--r--src/gui/Window.hpp6
-rw-r--r--src/gui/WindowFactory.cpp17
-rw-r--r--src/gui/WindowFactory.hpp16
-rw-r--r--src/gui/ingen_gui.cpp2
-rw-r--r--src/gui/ingen_gui.ui.in (renamed from src/gui/ingen_gui.ui)0
-rw-r--r--src/gui/ingen_gui_lv2.cpp18
-rw-r--r--src/gui/meson.build163
-rw-r--r--src/gui/rgba.hpp8
-rw-r--r--src/gui/wscript127
-rw-r--r--src/include/ingen_config.h216
-rw-r--r--src/ingen/.clang-tidy3
-rw-r--r--src/ingen/ingen.cpp15
-rw-r--r--src/meson.build65
-rw-r--r--src/runtime_paths.cpp24
-rw-r--r--src/server/.clang-tidy48
-rw-r--r--src/server/ArcImpl.hpp4
-rw-r--r--src/server/BlockFactory.cpp18
-rw-r--r--src/server/BlockFactory.hpp2
-rw-r--r--src/server/BlockImpl.cpp9
-rw-r--r--src/server/BlockImpl.hpp10
-rw-r--r--src/server/Broadcaster.cpp1
-rw-r--r--src/server/Broadcaster.hpp3
-rw-r--r--src/server/Buffer.cpp31
-rw-r--r--src/server/Buffer.hpp67
-rw-r--r--src/server/BufferFactory.cpp32
-rw-r--r--src/server/BufferFactory.hpp33
-rw-r--r--src/server/BufferRef.hpp6
-rw-r--r--src/server/CompiledGraph.cpp6
-rw-r--r--src/server/CompiledGraph.hpp2
-rw-r--r--src/server/ControlBindings.cpp87
-rw-r--r--src/server/ControlBindings.hpp25
-rw-r--r--src/server/DirectDriver.hpp3
-rw-r--r--src/server/Driver.hpp7
-rw-r--r--src/server/DuplexPort.cpp10
-rw-r--r--src/server/DuplexPort.hpp8
-rw-r--r--src/server/Engine.cpp10
-rw-r--r--src/server/Engine.hpp18
-rw-r--r--src/server/EnginePort.hpp9
-rw-r--r--src/server/Event.hpp29
-rw-r--r--src/server/EventWriter.cpp4
-rw-r--r--src/server/EventWriter.hpp6
-rw-r--r--src/server/FrameTimer.hpp3
-rw-r--r--src/server/GraphImpl.cpp19
-rw-r--r--src/server/GraphImpl.hpp21
-rw-r--r--src/server/InputPort.cpp1
-rw-r--r--src/server/InputPort.hpp8
-rw-r--r--src/server/InternalPlugin.cpp20
-rw-r--r--src/server/JackDriver.cpp36
-rw-r--r--src/server/JackDriver.hpp42
-rw-r--r--src/server/LV2Block.cpp22
-rw-r--r--src/server/LV2Block.hpp9
-rw-r--r--src/server/LV2Options.hpp5
-rw-r--r--src/server/LV2Plugin.cpp10
-rw-r--r--src/server/Load.hpp3
-rw-r--r--src/server/NodeImpl.cpp3
-rw-r--r--src/server/PluginImpl.hpp9
-rw-r--r--src/server/PortAudioDriver.cpp36
-rw-r--r--src/server/PortAudioDriver.hpp36
-rw-r--r--src/server/PortImpl.cpp31
-rw-r--r--src/server/PortImpl.hpp39
-rw-r--r--src/server/PortType.hpp29
-rw-r--r--src/server/PostProcessor.cpp10
-rw-r--r--src/server/PostProcessor.hpp5
-rw-r--r--src/server/PreProcessContext.hpp8
-rw-r--r--src/server/PreProcessor.cpp15
-rw-r--r--src/server/PreProcessor.hpp22
-rw-r--r--src/server/RunContext.cpp24
-rw-r--r--src/server/RunContext.hpp50
-rw-r--r--src/server/SocketListener.cpp14
-rw-r--r--src/server/SocketServer.hpp2
-rw-r--r--src/server/State.hpp3
-rw-r--r--src/server/Task.cpp5
-rw-r--r--src/server/Task.hpp26
-rw-r--r--src/server/ThreadManager.hpp13
-rw-r--r--src/server/UndoStack.cpp34
-rw-r--r--src/server/UndoStack.hpp11
-rw-r--r--src/server/Worker.cpp8
-rw-r--r--src/server/Worker.hpp6
-rw-r--r--src/server/events/Connect.cpp5
-rw-r--r--src/server/events/Connect.hpp4
-rw-r--r--src/server/events/Copy.cpp27
-rw-r--r--src/server/events/Copy.hpp6
-rw-r--r--src/server/events/CreateBlock.cpp31
-rw-r--r--src/server/events/CreateBlock.hpp4
-rw-r--r--src/server/events/CreateGraph.cpp25
-rw-r--r--src/server/events/CreateGraph.hpp6
-rw-r--r--src/server/events/CreatePort.cpp41
-rw-r--r--src/server/events/CreatePort.hpp8
-rw-r--r--src/server/events/Delete.cpp4
-rw-r--r--src/server/events/Delete.hpp2
-rw-r--r--src/server/events/Delta.cpp38
-rw-r--r--src/server/events/Delta.hpp13
-rw-r--r--src/server/events/Disconnect.cpp8
-rw-r--r--src/server/events/Disconnect.hpp9
-rw-r--r--src/server/events/DisconnectAll.cpp9
-rw-r--r--src/server/events/Get.cpp21
-rw-r--r--src/server/events/Get.hpp4
-rw-r--r--src/server/events/Move.cpp11
-rw-r--r--src/server/events/SetPortValue.cpp3
-rw-r--r--src/server/events/Undo.cpp3
-rw-r--r--src/server/ingen_engine.cpp2
-rw-r--r--src/server/ingen_jack.cpp2
-rw-r--r--src/server/ingen_lv2.cpp35
-rw-r--r--src/server/ingen_portaudio.cpp4
-rw-r--r--src/server/internals/Controller.cpp3
-rw-r--r--src/server/internals/Controller.hpp2
-rw-r--r--src/server/internals/Note.cpp5
-rw-r--r--src/server/internals/Note.hpp2
-rw-r--r--src/server/internals/Trigger.cpp3
-rw-r--r--src/server/internals/Trigger.hpp2
-rw-r--r--src/server/meson.build135
-rw-r--r--src/server/mix.cpp6
-rw-r--r--src/server/server.h31
-rw-r--r--src/server/wscript106
-rw-r--r--src/wscript47
196 files changed, 2138 insertions, 1801 deletions
diff --git a/src/.clang-tidy b/src/.clang-tidy
new file mode 100644
index 00000000..8b9aa445
--- /dev/null
+++ b/src/.clang-tidy
@@ -0,0 +1,29 @@
+Checks: >
+ -*-avoid-c-arrays,
+ -*-uppercase-literal-suffix,
+ -*-vararg,
+ -android-cloexec-*,
+ -bugprone-easily-swappable-parameters,
+ -cert-dcl50-cpp,
+ -cert-err33-c,
+ -cert-err34-c,
+ -clang-analyzer-optin.cplusplus.VirtualCall,
+ -clang-analyzer-valist.Uninitialized,
+ -concurrency-mt-unsafe,
+ -cppcoreguidelines-avoid-non-const-global-variables,
+ -cppcoreguidelines-no-malloc,
+ -cppcoreguidelines-owning-memory,
+ -cppcoreguidelines-pro-bounds-array-to-pointer-decay,
+ -cppcoreguidelines-pro-bounds-pointer-arithmetic,
+ -cppcoreguidelines-pro-type-const-cast,
+ -cppcoreguidelines-pro-type-reinterpret-cast,
+ -cppcoreguidelines-pro-type-union-access,
+ -fuchsia-statically-constructed-objects,
+ -google-readability-casting,
+ -hicpp-no-array-decay,
+ -hicpp-no-malloc,
+ -misc-no-recursion,
+ -misc-unused-parameters,
+ -readability-function-cognitive-complexity,
+ -readability-use-anyofallof,
+InheritParentConfig: true
diff --git a/src/AtomReader.cpp b/src/AtomReader.cpp
index 74476b83..ac52082f 100644
--- a/src/AtomReader.cpp
+++ b/src/AtomReader.cpp
@@ -14,8 +14,9 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "ingen/Atom.hpp"
#include "ingen/AtomReader.hpp"
+
+#include "ingen/Atom.hpp"
#include "ingen/Interface.hpp"
#include "ingen/Log.hpp"
#include "ingen/Message.hpp"
@@ -71,7 +72,7 @@ AtomReader::get_props(const LV2_Atom_Object* obj,
const Atom type(sizeof(int32_t), _uris.atom_URID, &obj->body.otype);
props.emplace(_uris.rdf_type, type);
}
- LV2_ATOM_OBJECT_FOREACH(obj, p) {
+ LV2_ATOM_OBJECT_FOREACH (obj, p) {
Atom val;
get_atom(&p->value, val);
props.emplace(URI(_map.unmap_uri(p->key)), val);
@@ -82,31 +83,36 @@ boost::optional<URI>
AtomReader::atom_to_uri(const LV2_Atom* atom)
{
if (!atom) {
- return boost::optional<URI>();
- } else if (atom->type == _uris.atom_URI) {
+ return {};
+ }
+
+ if (atom->type == _uris.atom_URI) {
const char* str = static_cast<const char*>(LV2_ATOM_BODY_CONST(atom));
if (URI::is_valid(str)) {
return URI(str);
- } else {
- _log.warn("Invalid URI <%1%>\n", str);
}
+
+ _log.warn("Invalid URI <%1%>\n", str);
} else if (atom->type == _uris.atom_Path) {
const char* str = static_cast<const char*>(LV2_ATOM_BODY_CONST(atom));
if (!strncmp(str, "file://", 5)) {
return URI(str);
- } else {
- return URI(std::string("file://") + str);
}
- } else if (atom->type == _uris.atom_URID) {
+
+ return URI(std::string("file://") + str);
+ }
+
+ if (atom->type == _uris.atom_URID) {
const char* str =
_map.unmap_uri(reinterpret_cast<const LV2_Atom_URID*>(atom)->body);
if (str) {
return URI(str);
- } else {
- _log.warn("Unknown URID %1%\n", str);
}
+
+ _log.warn("Unknown URID %1%\n", str);
}
- return boost::optional<URI>();
+
+ return {};
}
boost::optional<raul::Path>
@@ -116,7 +122,7 @@ AtomReader::atom_to_path(const LV2_Atom* atom)
if (uri && uri_is_path(*uri)) {
return uri_to_path(*uri);
}
- return boost::optional<raul::Path>();
+ return {};
}
Resource::Graph
@@ -195,7 +201,9 @@ AtomReader::write(const LV2_Atom* msg, int32_t default_id)
if (subject_uri && !body) {
_iface(Del{seq, *subject_uri});
return true;
- } else if (body && body->body.otype == _uris.ingen_Arc) {
+ }
+
+ if (body && body->body.otype == _uris.ingen_Arc) {
const LV2_Atom* tail = nullptr;
const LV2_Atom* head = nullptr;
const LV2_Atom* incidentTo = nullptr;
@@ -228,7 +236,9 @@ AtomReader::write(const LV2_Atom* msg, int32_t default_id)
if (!body) {
_log.warn("Put message has no body\n");
return false;
- } else if (!subject_uri) {
+ }
+
+ if (!subject_uri) {
_log.warn("Put message has no subject\n");
return false;
}
@@ -275,7 +285,9 @@ AtomReader::write(const LV2_Atom* msg, int32_t default_id)
reinterpret_cast<const LV2_Atom*>(prop)->type != _uris.atom_URID) {
_log.warn("Set message missing property\n");
return false;
- } else if (!value) {
+ }
+
+ if (!value) {
_log.warn("Set message missing value\n");
return false;
}
@@ -304,7 +316,9 @@ AtomReader::write(const LV2_Atom* msg, int32_t default_id)
if (!remove) {
_log.warn("Patch message has no remove\n");
return false;
- } else if (!add) {
+ }
+
+ if (!add) {
_log.warn("Patch message has no add\n");
return false;
}
@@ -377,10 +391,13 @@ AtomReader::write(const LV2_Atom* msg, int32_t default_id)
if (!number || number->type != _uris.atom_Int) {
_log.warn("Response message has no sequence number\n");
return false;
- } else if (!body || body->type != _uris.atom_Int) {
+ }
+
+ if (!body || body->type != _uris.atom_Int) {
_log.warn("Response message body is not integer\n");
return false;
}
+
_iface(Response{reinterpret_cast<const LV2_Atom_Int*>(number)->body,
static_cast<ingen::Status>(
reinterpret_cast<const LV2_Atom_Int*>(body)->body),
diff --git a/src/AtomWriter.cpp b/src/AtomWriter.cpp
index 6b60a3a5..e8418de1 100644
--- a/src/AtomWriter.cpp
+++ b/src/AtomWriter.cpp
@@ -79,8 +79,7 @@ AtomWriter::AtomWriter(URIMap& map, URIs& uris, AtomSink& sink)
, _uris(uris)
, _sink(sink)
, _forge(map.urid_map())
-{
-}
+{}
void
AtomWriter::finish_msg()
@@ -630,8 +629,7 @@ AtomWriter::operator()(const Response& response)
void
AtomWriter::operator()(const Error&)
-{
-}
+{}
/** @page protocol
* @section loading Loading and Unloading Bundles
diff --git a/src/ClashAvoider.cpp b/src/ClashAvoider.cpp
index ece002f8..428dd8ba 100644
--- a/src/ClashAvoider.cpp
+++ b/src/ClashAvoider.cpp
@@ -42,9 +42,9 @@ ClashAvoider::map_uri(const URI& in)
{
if (uri_is_path(in)) {
return path_to_uri(map_path(uri_to_path(in)));
- } else {
- return in;
}
+
+ return in;
}
raul::Path
@@ -71,67 +71,68 @@ ClashAvoider::map_path(const raul::Path& in)
auto m = _symbol_map.find(in);
if (m != _symbol_map.end()) {
return m->second;
- } else {
- using InsertRecord = std::pair<SymbolMap::iterator, bool>;
-
- // See if parent is mapped
- raul::Path parent = in.parent();
- do {
- auto p = _symbol_map.find(parent);
- if (p != _symbol_map.end()) {
- const raul::Path mapped = raul::Path(
- p->second.base() + in.substr(parent.base().length()));
- InsertRecord i = _symbol_map.emplace(in, mapped);
- return i.first->second;
- }
- parent = parent.parent();
- } while (!parent.is_root());
+ }
- if (!exists(in) && _symbol_map.find(in) == _symbol_map.end()) {
- // No clash, use symbol unmodified
- InsertRecord i = _symbol_map.emplace(in, in);
- assert(i.second);
+ // See if parent is mapped
+ raul::Path parent = in.parent();
+ do {
+ auto p = _symbol_map.find(parent);
+ if (p != _symbol_map.end()) {
+ const auto mapped = raul::Path{p->second.base() +
+ in.substr(parent.base().length())};
+
+ auto i = _symbol_map.emplace(in, mapped);
return i.first->second;
+ }
+ parent = parent.parent();
+ } while (!parent.is_root());
+
+ if (!exists(in) && _symbol_map.find(in) == _symbol_map.end()) {
+ // No clash, use symbol unmodified
+ auto i = _symbol_map.emplace(in, in);
+ assert(i.second);
+ return i.first->second;
+ }
+ // Append _2 _3 etc until an unused symbol is found
+ while (true) {
+ auto o = _offsets.find(base_path);
+ if (o != _offsets.end()) {
+ offset = ++o->second;
} else {
- // Append _2 _3 etc until an unused symbol is found
- while (true) {
- auto o = _offsets.find(base_path);
- if (o != _offsets.end()) {
- offset = ++o->second;
- } else {
- std::string parent_str = in.parent().base();
- parent_str = parent_str.substr(0, parent_str.find_last_of('/'));
- if (parent_str.empty()) {
- parent_str = "/";
- }
- }
-
- if (offset == 0) {
- offset = 2;
- }
-
- std::stringstream ss;
- ss << base_path << "_" << offset;
- if (!exists(raul::Path(ss.str()))) {
- std::string name = base_path.symbol();
- if (name.empty()) {
- name = "_";
- }
- raul::Symbol sym(name);
- std::string str = ss.str();
- InsertRecord i = _symbol_map.emplace(in, raul::Path(str));
- offset = _store.child_name_offset(in.parent(), sym, false);
- _offsets.emplace(base_path, offset);
- return i.first->second;
- } else {
- if (o != _offsets.end()) {
- offset = ++o->second;
- } else {
- ++offset;
- }
- }
+ std::string parent_str = in.parent().base();
+ parent_str = parent_str.substr(0, parent_str.find_last_of('/'));
+ if (parent_str.empty()) {
+ parent_str = "/";
+ }
+ }
+
+ if (offset == 0) {
+ offset = 2;
+ }
+
+ std::stringstream ss;
+ ss << base_path << "_" << offset;
+ if (!exists(raul::Path(ss.str()))) {
+ std::string name = base_path.symbol();
+ if (name.empty()) {
+ name = "_";
}
+
+ raul::Symbol sym(name);
+ std::string str = ss.str();
+
+ auto i = _symbol_map.emplace(in, raul::Path(str));
+
+ offset = _store.child_name_offset(in.parent(), sym, false);
+ _offsets.emplace(base_path, offset);
+ return i.first->second;
+ }
+
+ if (o != _offsets.end()) {
+ offset = ++o->second;
+ } else {
+ ++offset;
}
}
}
@@ -177,11 +178,11 @@ ClashAvoider::adjust_name(const raul::Path& old_path,
const auto offset = new_suffix - old_suffix;
return (name.substr(0, *name_suffix_start) +
std::to_string(name_suffix + offset));
- } else {
- // Add 1 to previous label suffix
- return (name.substr(0, *name_suffix_start) +
- std::to_string(name_suffix + 1));
}
+
+ // Add 1 to previous label suffix
+ return (name.substr(0, *name_suffix_start) +
+ std::to_string(name_suffix + 1));
}
} // namespace ingen
diff --git a/src/ColorContext.cpp b/src/ColorContext.cpp
index ac797518..a4e60ca5 100644
--- a/src/ColorContext.cpp
+++ b/src/ColorContext.cpp
@@ -17,7 +17,7 @@
#include "ingen/ColorContext.hpp"
#include "ingen_config.h"
-#ifdef HAVE_ISATTY
+#if USE_ISATTY
# include <unistd.h>
#else
inline int isatty(int fd) { return 0; }
@@ -41,4 +41,4 @@ ColorContext::~ColorContext()
}
}
-} // namespace ingen
+} // namespace ingen
diff --git a/src/Configuration.cpp b/src/Configuration.cpp
index 5b5d75bd..5af9fea1 100644
--- a/src/Configuration.cpp
+++ b/src/Configuration.cpp
@@ -54,7 +54,6 @@ Configuration::Configuration(Forge& forge)
" ingen -g # Run GUI, connect to running engine\n"
" ingen -eg # Run engine and GUI in one process\n"
" ingen -eg foo.ingen # Run engine and GUI and load a graph")
- , _max_name_length(0)
{
add("atomicBundles", "atomic-bundles", 'a', "Execute bundles atomically", GLOBAL, forge.Bool, forge.make(false));
add("bufferSize", "buffer-size", 'b', "Buffer size in samples", GLOBAL, forge.Int, forge.make(1024));
@@ -110,9 +109,12 @@ Configuration::variable_string(LV2_URID type) const
{
if (type == _forge.String) {
return "=STRING";
- } else if (type == _forge.Int) {
+ }
+
+ if (type == _forge.Int) {
return "=INT";
}
+
return "";
}
@@ -170,7 +172,7 @@ Configuration::parse(int argc, char** argv)
for (int i = 1; i < argc; ++i) {
if (argv[i][0] != '-' || !strcmp(argv[i], "-")) {
// File argument
- const Options::iterator o = _options.find("load");
+ const auto o = _options.find("load");
if (!o->second.value.is_valid()) {
_options.find("load")->second.value = _forge.alloc(argv[i]);
} else {
@@ -184,14 +186,16 @@ Configuration::parse(int argc, char** argv)
name = name.substr(0, name.find('='));
}
- const Options::iterator o = _options.find(name);
+ const auto o = _options.find(name);
if (o == _options.end()) {
throw OptionError(fmt("Unrecognized option `%1%'", name));
- } else if (o->second.type == _forge.Bool) { // --flag
+ }
+
+ if (o->second.type == _forge.Bool) { // --flag
o->second.value = _forge.make(true);
- } else if (equals) { // --opt=val
+ } else if (equals) { // --opt=val
set_value_from_string(o->second, equals + 1);
- } else if (++i < argc) { // --opt val
+ } else if (++i < argc) { // --opt val
set_value_from_string(o->second, argv[i]);
} else {
throw OptionError(fmt("Missing value for `%1%'", name));
@@ -200,22 +204,22 @@ Configuration::parse(int argc, char** argv)
// Short option
const size_t len = strlen(argv[i]);
for (size_t j = 1; j < len; ++j) {
- const char letter = argv[i][j];
- const ShortNames::iterator n = _short_names.find(letter);
+ const char letter = argv[i][j];
+ const auto n = _short_names.find(letter);
if (n == _short_names.end()) {
throw OptionError(fmt("Unrecognized option `%1%'", letter));
}
- const Options::iterator o = _options.find(n->second);
- if (j < len - 1) { // Non-final POSIX style flag
+ const auto o = _options.find(n->second);
+ if (j < len - 1) { // Non-final POSIX style flag
if (o->second.type != _forge.Bool) {
throw OptionError(
fmt("Missing value for `%1%'", letter));
}
o->second.value = _forge.make(true);
- } else if (o->second.type == _forge.Bool) { // -f
+ } else if (o->second.type == _forge.Bool) { // -f
o->second.value = _forge.make(true);
- } else if (++i < argc) { // -v val
+ } else if (++i < argc) { // -v val
set_value_from_string(o->second, argv[i]);
} else {
throw OptionError(fmt("Missing value for `%1%'", letter));
@@ -244,12 +248,12 @@ Configuration::load(const FilePath& path)
Sord::Node nodemm(world, Sord::Node::URI, reinterpret_cast<const char*>(node.buf));
Sord::Node nil;
- for (Sord::Iter i = model.find(nodemm, nil, nil); !i.end(); ++i) {
- const Sord::Node& pred = i.get_predicate();
- const Sord::Node& obj = i.get_object();
+ for (auto i = model.find(nodemm, nil, nil); !i.end(); ++i) {
+ const auto& pred = i.get_predicate();
+ const auto& obj = i.get_object();
if (pred.to_string().substr(0, sizeof(INGEN_NS) - 1) == INGEN_NS) {
const std::string key = pred.to_string().substr(sizeof(INGEN_NS) - 1);
- const Keys::iterator k = _keys.find(key);
+ const auto k = _keys.find(key);
if (k != _keys.end() && obj.type() == Sord::Node::LITERAL) {
set_value_from_string(_options.find(k->second)->second,
obj.to_string());
@@ -380,9 +384,9 @@ Configuration::option(const std::string& long_name) const
auto o = _options.find(long_name);
if (o == _options.end()) {
return nil;
- } else {
- return o->second.value;
}
+
+ return o->second.value;
}
bool
diff --git a/src/FilePath.cpp b/src/FilePath.cpp
index d16c133c..8cbd3a9e 100644
--- a/src/FilePath.cpp
+++ b/src/FilePath.cpp
@@ -26,7 +26,7 @@ template <typename Char>
static bool
is_sep(const Char chr)
{
-#ifdef USE_WINDOWS_FILE_PATHS
+#if USE_WINDOWS_FILE_PATHS
return chr == L'/' || chr == preferred_separator;
#else
return chr == '/';
@@ -98,20 +98,20 @@ FilePath::operator+=(boost::basic_string_view<value_type> sv)
FilePath
FilePath::root_name()
{
-#ifdef USE_WINDOWS_FILE_PATHS
+#if USE_WINDOWS_FILE_PATHS
if (_str.length() >= 2 && _str[0] >= 'A' && _str[0] <= 'Z' &&
_str[1] == ':') {
return FilePath(_str.substr(0, 2));
}
#endif
- return FilePath();
+ return {};
}
FilePath
FilePath::root_directory() const
{
-#ifdef USE_WINDOWS_FILE_PATHS
+#if USE_WINDOWS_FILE_PATHS
const auto name = root_name().string();
return name.empty() ? Path() : Path(name + preferred_separator);
#endif
@@ -122,7 +122,7 @@ FilePath::root_directory() const
FilePath
FilePath::root_path() const
{
-#ifdef USE_WINDOWS_FILE_PATHS
+#if USE_WINDOWS_FILE_PATHS
const auto name = root_name();
return name.empty() ? FilePath() : name / root_directory();
#endif
@@ -180,7 +180,7 @@ FilePath::extension() const
bool
FilePath::is_absolute() const
{
-#ifdef USE_WINDOWS_FILE_PATHS
+#if USE_WINDOWS_FILE_PATHS
return !root_name().empty();
#else
return !root_directory().empty();
diff --git a/src/Forge.cpp b/src/Forge.cpp
index 6b8f7b14..abce74f2 100644
--- a/src/Forge.cpp
+++ b/src/Forge.cpp
@@ -35,7 +35,7 @@ Atom
Forge::make_urid(const ingen::URI& u)
{
const LV2_URID urid = _map.map_uri(u.string());
- return Atom(sizeof(int32_t), URID, &urid);
+ return {sizeof(int32_t), URID, &urid};
}
std::string
diff --git a/src/LV2Features.cpp b/src/LV2Features.cpp
index ebce8780..65fe6f6b 100644
--- a/src/LV2Features.cpp
+++ b/src/LV2Features.cpp
@@ -37,12 +37,10 @@ LV2Features::add_feature(const std::shared_ptr<Feature>& feature)
}
LV2Features::FeatureArray::FeatureArray(FeatureVector& features)
- : _features(features)
+ : _features(features)
+ , _array{static_cast<LV2_Feature**>(
+ calloc(features.size() + 1, sizeof(LV2_Feature*)))}
{
- _array = static_cast<LV2_Feature**>(
- malloc(sizeof(LV2_Feature*) * (features.size() + 1)));
-
- _array[features.size()] = nullptr;
for (size_t i = 0; i < features.size(); ++i) {
_array[i] = features[i].get();
}
diff --git a/src/Log.cpp b/src/Log.cpp
index 55c2193a..e05caa21 100644
--- a/src/Log.cpp
+++ b/src/Log.cpp
@@ -33,8 +33,6 @@ namespace ingen {
Log::Log(LV2_Log_Log* log, URIs& uris)
: _log(log)
, _uris(uris)
- , _flush(false)
- , _trace(false)
{}
void
@@ -89,7 +87,9 @@ Log::vtprintf(LV2_URID type, const char* fmt, va_list args)
int ret = 0;
if (type == _uris.log_Trace && !_trace) {
return 0;
- } else if (_sink) {
+ }
+
+ if (_sink) {
_sink(type, fmt, args);
}
@@ -162,7 +162,7 @@ Log::Feature::feature(World& world, Node* block)
f->URI = LV2_LOG__log;
f->data = &handle->lv2_log;
- return std::shared_ptr<LV2_Feature>(f, &free_log_feature);
+ return {f, &free_log_feature};
}
-} // namespace ingen
+} // namespace ingen
diff --git a/src/Parser.cpp b/src/Parser.cpp
index f54c4249..7b25031c 100644
--- a/src/Parser.cpp
+++ b/src/Parser.cpp
@@ -66,16 +66,17 @@ Parser::find_resources(Sord::World& world,
model.load_file(env, SERD_TURTLE, manifest_uri.string());
std::set<ResourceRecord> resources;
- for (Sord::Iter i = model.find(nil, rdf_type, type); !i.end(); ++i) {
- const Sord::Node resource = i.get_subject();
- const std::string resource_uri = resource.to_c_string();
- Sord::Iter f = model.find(resource, rdfs_seeAlso, nil);
- std::string file_path;
+ for (auto i = model.find(nil, rdf_type, type); !i.end(); ++i) {
+ const auto resource = i.get_subject();
+ auto f = model.find(resource, rdfs_seeAlso, nil);
+
+ std::string file_path;
if (!f.end()) {
uint8_t* p = serd_file_uri_parse(f.get_object().to_u_string(), nullptr);
file_path = reinterpret_cast<const char*>(p);
serd_free(p);
}
+
resources.insert(ResourceRecord(resource, file_path));
}
@@ -112,7 +113,7 @@ get_properties(ingen::World& world,
const Sord::Node nil;
Properties props;
- for (Sord::Iter i = model.find(subject, nil, nil); !i.end(); ++i) {
+ for (auto i = model.find(subject, nil, nil); !i.end(); ++i) {
if (!skip_property(world.uris(), i.get_predicate())) {
forge.clear();
forge.read(
@@ -162,19 +163,19 @@ get_port(ingen::World& world,
// Get index if requested (for Graphs)
if (index) {
- Properties::const_iterator i = props.find(uris.lv2_index);
+ const auto i = props.find(uris.lv2_index);
if (i == props.end()
|| i->second.type() != world.forge().Int
|| i->second.get<int32_t>() < 0) {
world.log().error("Port %1% has no valid index\n", subject);
- return boost::optional<PortRecord>();
+ return {};
}
*index = i->second.get<int32_t>();
}
// Get symbol
- Properties::const_iterator s = props.find(uris.lv2_symbol);
- std::string sym;
+ auto s = props.find(uris.lv2_symbol);
+ std::string sym;
if (s != props.end() && s->second.type() == world.forge().String) {
sym = s->second.ptr<char>();
} else {
@@ -188,13 +189,13 @@ get_port(ingen::World& world,
if (!raul::Symbol::is_valid(sym)) {
world.log().error("Port %1% has invalid symbol `%2%'\n", subject, sym);
- return boost::optional<PortRecord>();
+ return {};
}
const raul::Symbol port_sym(sym);
const raul::Path port_path(parent.child(port_sym));
- props.erase(uris.lv2_symbol); // Don't set symbol property in engine
+ props.erase(uris.lv2_symbol); // Don't set symbol property in engine
return make_pair(port_path, props);
}
@@ -269,7 +270,7 @@ parse_block(ingen::World& world,
if (!prototype.is_valid()) {
world.log().error("Block %1% (%2%) missing mandatory lv2:prototype\n",
subject, path);
- return boost::optional<raul::Path>();
+ return {};
}
const auto* type_uri =
@@ -337,13 +338,11 @@ parse_graph(ingen::World& world,
const Sord::Node nil;
// Build graph path and symbol
- raul::Path graph_path;
+ raul::Path graph_path{"/"};
if (parent && symbol) {
graph_path = parent->child(*symbol);
} else if (parent) {
graph_path = *parent;
- } else {
- graph_path = raul::Path("/");
}
// Create graph
@@ -353,7 +352,7 @@ parse_graph(ingen::World& world,
// For each port on this graph
using PortRecords = std::map<uint32_t, PortRecord>;
PortRecords ports;
- for (Sord::Iter p = model.find(graph, lv2_port, nil); !p.end(); ++p) {
+ for (auto p = model.find(graph, lv2_port, nil); !p.end(); ++p) {
Sord::Node port = p.get_object();
// Get all properties
@@ -362,7 +361,7 @@ parse_graph(ingen::World& world,
world, model, port, ctx, graph_path, &index);
if (!port_record) {
world.log().error("Invalid port %1%\n", port);
- return boost::optional<raul::Path>();
+ return {};
}
// Store port information in ports map
@@ -382,11 +381,11 @@ parse_graph(ingen::World& world,
}
if (ctx != Resource::Graph::INTERNAL) {
- return {graph_path}; // Not parsing graph internals, finished now
+ return {graph_path}; // Not parsing graph internals, finished now
}
// For each block in this graph
- for (Sord::Iter n = model.find(subject, ingen_block, nil); !n.end(); ++n) {
+ for (auto n = model.find(subject, ingen_block, nil); !n.end(); ++n) {
Sord::Node node = n.get_object();
URI node_uri = node;
assert(!node_uri.path().empty() && node_uri.path() != "/");
@@ -398,7 +397,7 @@ parse_graph(ingen::World& world,
boost::optional<Properties>());
// For each port on this block
- for (Sord::Iter p = model.find(node, lv2_port, nil); !p.end(); ++p) {
+ for (auto p = model.find(node, lv2_port, nil); !p.end(); ++p) {
Sord::Node port = p.get_object();
Resource::Graph subctx = Resource::Graph::DEFAULT;
@@ -413,7 +412,7 @@ parse_graph(ingen::World& world,
world, model, port, subctx, block_path, nullptr);
if (!port_record) {
world.log().error("Invalid port %1%\n", port);
- return boost::optional<raul::Path>();
+ return {};
}
// Create port and/or set all port properties
@@ -443,13 +442,15 @@ parse_arc(ingen::World& world,
const Sord::URI ingen_head(*world.rdf_world(), uris.ingen_head);
const Sord::Node nil;
- Sord::Iter t = model.find(subject, ingen_tail, nil);
- Sord::Iter h = model.find(subject, ingen_head, nil);
+ auto t = model.find(subject, ingen_tail, nil);
+ auto h = model.find(subject, ingen_head, nil);
if (t.end()) {
world.log().error("Arc has no tail\n");
return false;
- } else if (h.end()) {
+ }
+
+ if (h.end()) {
world.log().error("Arc has no head\n");
return false;
}
@@ -471,7 +472,9 @@ parse_arc(ingen::World& world,
if (!(++t).end()) {
world.log().error("Arc has multiple tails\n");
return false;
- } else if (!(++h).end()) {
+ }
+
+ if (!(++h).end()) {
world.log().error("Arc has multiple heads\n");
return false;
}
@@ -492,7 +495,7 @@ parse_arcs(ingen::World& world,
const Sord::URI ingen_arc(*world.rdf_world(), world.uris().ingen_arc);
const Sord::Node nil;
- for (Sord::Iter i = model.find(subject, ingen_arc, nil); !i.end(); ++i) {
+ for (auto i = model.find(subject, ingen_arc, nil); !i.end(); ++i) {
parse_arc(world, target, model, base_uri, i.get_object(), graph);
}
@@ -531,7 +534,7 @@ parse(ingen::World& world,
// Get all subjects and their types (?subject a ?type)
using Subjects = std::map< Sord::Node, std::set<Sord::Node> >;
Subjects subjects;
- for (Sord::Iter i = model.find(subject, rdf_type, nil); !i.end(); ++i) {
+ for (auto i = model.find(subject, rdf_type, nil); !i.end(); ++i) {
const Sord::Node& rdf_class = i.get_object();
assert(rdf_class.is_uri());
@@ -574,7 +577,7 @@ parse(ingen::World& world,
}
}
- return boost::optional<raul::Path>();
+ return {};
}
bool
@@ -659,10 +662,10 @@ Parser::parse_file(ingen::World& world,
URI(INGEN__file),
world.forge().alloc_uri(uri.string()));
return true;
- } else {
- world.log().warn("Document URI lost\n");
- return false;
}
+
+ world.log().warn("Document URI lost\n");
+ return false;
}
boost::optional<URI>
diff --git a/src/Resource.cpp b/src/Resource.cpp
index 0bd4b95f..2171c438 100644
--- a/src/Resource.cpp
+++ b/src/Resource.cpp
@@ -29,9 +29,8 @@ bool
Resource::add_property(const URI& uri, const Atom& value, Graph ctx)
{
// Ignore duplicate statements
- using iterator = Properties::const_iterator;
- const std::pair<iterator, iterator> range = _properties.equal_range(uri);
- for (iterator i = range.first; i != range.second && i != _properties.end(); ++i) {
+ const auto range = _properties.equal_range(uri);
+ for (auto i = range.first; i != range.second && i != _properties.end(); ++i) {
if (i->second == value && i->second.context() == ctx) {
return false;
}
@@ -70,11 +69,11 @@ Resource::set_property(const URI& uri, const Atom& value, Resource::Graph ctx)
const Atom& v = _properties.emplace(uri, Property(value, ctx))->second;
on_property(uri, v);
return v;
- } else {
- // Announce ephemeral activity, but do not store
- on_property(uri, value);
- return value;
}
+
+ // Announce ephemeral activity, but do not store
+ on_property(uri, value);
+ return value;
}
const Atom&
@@ -119,8 +118,9 @@ Resource::has_property(const URI& uri, const Atom& value) const
bool
Resource::has_property(const URI& uri, const URIs::Quark& value) const
{
- Properties::const_iterator i = _properties.find(uri);
- for (; (i != _properties.end()) && (i->first == uri); ++i) {
+ for (auto i = _properties.find(uri);
+ (i != _properties.end()) && (i->first == uri);
+ ++i) {
if (value == i->second) {
return true;
}
@@ -138,7 +138,8 @@ const Atom&
Resource::get_property(const URI& uri) const
{
static const Atom nil;
- Properties::const_iterator i = _properties.find(uri);
+
+ const auto i = _properties.find(uri);
return (i != _properties.end()) ? i->second : nil;
}
@@ -150,11 +151,10 @@ Resource::type(const URIs& uris,
bool& port,
bool& is_output)
{
- using iterator = Properties::const_iterator;
- const std::pair<iterator, iterator> types_range = properties.equal_range(uris.rdf_type);
+ const auto types_range = properties.equal_range(uris.rdf_type);
graph = block = port = is_output = false;
- for (iterator i = types_range.first; i != types_range.second; ++i) {
+ for (auto i = types_range.first; i != types_range.second; ++i) {
const Atom& atom = i->second;
if (atom.type() != uris.forge.URI && atom.type() != uris.forge.URID) {
continue; // Non-URI type, ignore garbage data
@@ -176,14 +176,14 @@ Resource::type(const URIs& uris,
if (graph && block && !port) { // => graph
block = false;
return true;
- } else if (port && (graph || block)) { // nonsense
+ }
+
+ if (port && (graph || block)) { // nonsense
port = false;
return false;
- } else if (graph || block || port) { // recognized type
- return true;
- } else { // unknown
- return false;
}
+
+ return graph || block || port; // recognized type
}
void
diff --git a/src/Serialiser.cpp b/src/Serialiser.cpp
index 3dfa862b..21d8286f 100644
--- a/src/Serialiser.cpp
+++ b/src/Serialiser.cpp
@@ -53,16 +53,12 @@
namespace ingen {
-struct Serialiser::Impl
-{
+struct Serialiser::Impl {
explicit Impl(World& world)
: _root_path("/")
- , _mode(Mode::TO_FILE)
, _world(world)
- , _model(nullptr)
, _sratom(sratom_new(&_world.uri_map().urid_map()))
- {
- }
+ {}
~Impl() { sratom_free(_sratom); }
@@ -105,11 +101,11 @@ struct Serialiser::Impl
std::string finish();
raul::Path _root_path;
- Mode _mode;
+ Mode _mode{Mode::TO_FILE};
URI _base_uri;
FilePath _basename;
World& _world;
- Sord::Model* _model;
+ Sord::Model* _model{nullptr};
Sratom* _sratom;
};
@@ -352,7 +348,7 @@ Serialiser::Impl::serialise_graph(const std::shared_ptr<const Node>& graph,
std::set<const Resource*> plugins;
const Store::const_range kids = _world.store()->children_range(graph);
- for (Store::const_iterator n = kids.first; n != kids.second; ++n) {
+ for (auto n = kids.first; n != kids.second; ++n) {
if (n->first.parent() != graph->path()) {
continue;
}
diff --git a/src/SocketReader.cpp b/src/SocketReader.cpp
index e643b9a2..83854bf9 100644
--- a/src/SocketReader.cpp
+++ b/src/SocketReader.cpp
@@ -23,6 +23,8 @@
#include "ingen/World.hpp"
#include "lv2/urid/urid.h"
#include "raul/Socket.hpp"
+#include "serd/serd.h"
+#include "sord/sord.h"
#include "sord/sordmm.hpp"
#include <cerrno>
@@ -31,7 +33,6 @@
#include <mutex>
#include <poll.h>
#include <sys/socket.h>
-#include <sys/types.h>
#include <utility>
namespace ingen {
@@ -41,12 +42,7 @@ SocketReader::SocketReader(ingen::World& world,
std::shared_ptr<raul::Socket> sock)
: _world(world)
, _iface(iface)
- , _env()
- , _inserter(nullptr)
- , _msg_node(nullptr)
, _socket(std::move(sock))
- , _socket_error(0)
- , _exit_flag(false)
, _thread(&SocketReader::run, this)
{}
@@ -170,9 +166,11 @@ SocketReader::run()
const int ret = poll(&pfd, 1, -1);
if (ret == -1 || (pfd.revents & (POLLERR|POLLHUP|POLLNVAL))) {
on_hangup();
- break; // Hangup
- } else if (!ret) {
- continue; // No data, shouldn't happen
+ break; // Hangup
+ }
+
+ if (!ret) {
+ continue; // No data, shouldn't happen
}
// Lock RDF world
@@ -181,8 +179,10 @@ SocketReader::run()
// Read until the next '.'
SerdStatus st = serd_reader_read_chunk(reader);
if (st == SERD_FAILURE || !_msg_node) {
- continue; // Read nothing, e.g. just whitespace
- } else if (st) {
+ continue; // Read nothing, e.g. just whitespace
+ }
+
+ if (st) {
_world.log().error("Read error: %1%\n", serd_strerror(st));
continue;
}
@@ -210,4 +210,4 @@ SocketReader::run()
_socket.reset();
}
-} // namespace ingen
+} // namespace ingen
diff --git a/src/SocketWriter.cpp b/src/SocketWriter.cpp
index 0e5948e5..c705ed96 100644
--- a/src/SocketWriter.cpp
+++ b/src/SocketWriter.cpp
@@ -23,7 +23,6 @@
#include <memory>
#include <sys/socket.h>
-#include <sys/types.h>
#include <utility>
#ifndef MSG_NOSIGNAL
diff --git a/src/Store.cpp b/src/Store.cpp
index fe5527a5..d85d5932 100644
--- a/src/Store.cpp
+++ b/src/Store.cpp
@@ -67,7 +67,7 @@ Store::find_descendants_end(const iterator parent)
Store::const_iterator
Store::find_descendants_end(const const_iterator parent) const
{
- const_iterator descendants_end = parent;
+ auto descendants_end = parent;
++descendants_end;
while (descendants_end != end() &&
descendants_end->first.is_child_of(parent->first)) {
@@ -80,9 +80,9 @@ Store::find_descendants_end(const const_iterator parent) const
Store::const_range
Store::children_range(const std::shared_ptr<const Node>& o) const
{
- const const_iterator parent = find(o->path());
+ const auto parent = find(o->path());
if (parent != end()) {
- const_iterator first_child = parent;
+ auto first_child = parent;
++first_child;
return std::make_pair(first_child, find_descendants_end(parent));
}
@@ -93,7 +93,7 @@ void
Store::remove(const iterator top, Objects& removed)
{
if (top != end()) {
- const iterator descendants_end = find_descendants_end(top);
+ const auto descendants_end = find_descendants_end(top);
removed.insert(top, descendants_end);
erase(top, descendants_end);
}
@@ -109,15 +109,15 @@ Store::rename(const iterator top, const raul::Path& new_path)
remove(top, removed);
// Rename all the removed objects
- for (Objects::const_iterator i = removed.begin(); i != removed.end(); ++i) {
- const raul::Path path = (i->first == old_path)
+ for (const auto& r : removed) {
+ const auto path = (r.first == old_path)
? new_path
: new_path.child(
- raul::Path(i->first.substr(old_path.base().length() - 1)));
+ raul::Path(r.first.substr(old_path.base().length() - 1)));
- i->second->set_path(path);
- assert(find(path) == end()); // Shouldn't be dropping objects!
- emplace(path, i->second);
+ r.second->set_path(path);
+ assert(find(path) == end()); // Shouldn't be dropping objects!
+ emplace(path, r.second);
}
}
@@ -134,14 +134,13 @@ Store::child_name_offset(const raul::Path& parent,
if (offset > 0) {
ss << "_" << offset;
}
+
if (find(parent.child(raul::Symbol(ss.str()))) == end() &&
(allow_zero || offset > 0)) {
break;
- } else if (offset == 0) {
- offset = 2;
- } else {
- ++offset;
}
+
+ offset = (offset == 0) ? 2 : (offset + 1);
}
return offset;
diff --git a/src/TurtleWriter.cpp b/src/TurtleWriter.cpp
index 07e06afe..1f5b0529 100644
--- a/src/TurtleWriter.cpp
+++ b/src/TurtleWriter.cpp
@@ -18,6 +18,7 @@
#include "ingen/URIMap.hpp"
#include "lv2/atom/atom.h"
+#include "serd/serd.h"
#include <utility>
@@ -40,20 +41,18 @@ write_prefix(void* handle, const SerdNode* name, const SerdNode* uri)
}
TurtleWriter::TurtleWriter(URIMap& map, URIs& uris, URI uri)
- : AtomWriter(map, uris, *this)
- , _map(map)
- , _sratom(sratom_new(&map.urid_map()))
- , _base(SERD_NODE_NULL)
- , _base_uri(SERD_URI_NULL)
- , _uri(std::move(uri))
- , _wrote_prefixes(false)
+ : AtomWriter{map, uris, *this}
+ , _map{map}
+ , _sratom{sratom_new(&map.urid_map())}
+ , _base{serd_node_from_string(SERD_URI, USTR("ingen:/"))}
+ , _env{serd_env_new(&_base)}
+ , _uri{std::move(uri)}
{
// Use <ingen:/> as base URI, so relative URIs are like bundle paths
- _base = serd_node_from_string(SERD_URI, USTR("ingen:/"));
- serd_uri_parse(_base.buf, &_base_uri);
+
+ serd_uri_parse(USTR("ingen:/"), &_base_uri);
// Set up serialisation environment
- _env = serd_env_new(&_base);
serd_env_set_prefix_from_strings(_env, USTR("atom"), USTR("http://lv2plug.in/ns/ext/atom#"));
serd_env_set_prefix_from_strings(_env, USTR("doap"), USTR("http://usefulinc.com/ns/doap#"));
serd_env_set_prefix_from_strings(_env, USTR("ingen"), USTR(INGEN_NS));
@@ -66,6 +65,7 @@ TurtleWriter::TurtleWriter(URIMap& map, URIs& uris, URI uri)
serd_env_set_prefix_from_strings(_env, USTR("xsd"), USTR("http://www.w3.org/2001/XMLSchema#"));
// Make a Turtle writer that writes to text_sink
+ // NOLINTNEXTLINE(cppcoreguidelines-prefer-member-initializer)
_writer = serd_writer_new(
SERD_TURTLE,
static_cast<SerdStyle>(SERD_STYLE_RESOLVED|SERD_STYLE_ABBREVIATED|SERD_STYLE_CURIED),
diff --git a/src/URI.cpp b/src/URI.cpp
index 1763a8bd..cc40a9a3 100644
--- a/src/URI.cpp
+++ b/src/URI.cpp
@@ -17,6 +17,8 @@
#include "ingen/URI.hpp"
#include "ingen/FilePath.hpp"
+#include "serd/serd.h"
+#include "sord/sordmm.hpp"
#include <cassert>
@@ -66,8 +68,7 @@ URI::URI(SerdNode node, SerdURI uri)
URI::URI(const Sord::Node& node)
: URI(*node.to_serd_node())
-{
-}
+{}
URI::URI(const FilePath& path)
: _uri(SERD_URI_NULL)
@@ -124,7 +125,7 @@ URI::make_relative(const URI& base) const
{
SerdURI uri;
SerdNode node = serd_node_new_relative_uri(&_uri, &base._uri, nullptr, &uri);
- return URI(node, uri);
+ return {node, uri};
}
-} // namespace ingen
+} // namespace ingen
diff --git a/src/URIMap.cpp b/src/URIMap.cpp
index 1f627e1e..0d6654a5 100644
--- a/src/URIMap.cpp
+++ b/src/URIMap.cpp
@@ -29,8 +29,7 @@ namespace ingen {
URIMap::URIMap(Log& log, LV2_URID_Map* map, LV2_URID_Unmap* unmap)
: _urid_map_feature(new URIDMapFeature(this, map, log))
, _urid_unmap_feature(new URIDUnmapFeature(this, unmap))
-{
-}
+{}
URIMap::URIDMapFeature::URIDMapFeature(URIMap* map,
LV2_URID_Map* impl,
diff --git a/src/URIs.cpp b/src/URIs.cpp
index a2ad6819..41706868 100644
--- a/src/URIs.cpp
+++ b/src/URIs.cpp
@@ -155,6 +155,7 @@ URIs::URIs(Forge& ingen_forge, URIMap* map, LilvWorld* lworld)
, midi_binding (forge, map, lworld, LV2_MIDI__binding)
, midi_controllerNumber (forge, map, lworld, LV2_MIDI__controllerNumber)
, midi_noteNumber (forge, map, lworld, LV2_MIDI__noteNumber)
+ , midi_channel (forge, map, lworld, LV2_MIDI__channel)
, morph_AutoMorphPort (forge, map, lworld, LV2_MORPH__AutoMorphPort)
, morph_MorphPort (forge, map, lworld, LV2_MORPH__MorphPort)
, morph_currentType (forge, map, lworld, LV2_MORPH__currentType)
diff --git a/src/World.cpp b/src/World.cpp
index 27d92632..e2db1a57 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -72,6 +72,8 @@ ingen_load_library(Log& log, const string& name)
return nullptr;
}
+ log.info("Loading module %1%\n", path);
+
std::unique_ptr<Library> library = std::make_unique<Library>(path);
if (*library) {
return library;
@@ -88,9 +90,7 @@ class World::Impl
{
public:
Impl(LV2_URID_Map* map, LV2_URID_Unmap* unmap, LV2_Log_Log* log_feature)
- : argc(nullptr)
- , argv(nullptr)
- , lv2_features(nullptr)
+ : lv2_features(new LV2Features())
, rdf_world(new Sord::World())
, lilv_world(lilv_world_new(), lilv_world_free)
, uri_map(log, map, unmap)
@@ -99,7 +99,6 @@ public:
, conf(forge)
, log(log_feature, 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(std::make_shared<InstanceAccess>());
@@ -185,8 +184,8 @@ public:
using LilvWorldUPtr =
std::unique_ptr<LilvWorld, decltype(&lilv_world_free)>;
- int* argc;
- char*** argv;
+ int* argc{nullptr};
+ char*** argv{nullptr};
LV2Features* lv2_features;
std::unique_ptr<Sord::World> rdf_world;
LilvWorldUPtr lilv_world;
@@ -344,7 +343,7 @@ World::load_module(const char* name)
if (i != _impl->modules.end()) {
return true;
}
- log().info("Loading %1% module\n", name);
+
std::unique_ptr<ingen::Library> lib = ingen_load_library(log(), name);
ingen::Module* (*module_load)() =
@@ -387,8 +386,8 @@ std::shared_ptr<Interface>
World::new_interface(const URI& engine_uri,
const std::shared_ptr<Interface>& respondee)
{
- const Impl::InterfaceFactories::const_iterator i =
- _impl->interface_factories.find(std::string(engine_uri.scheme()));
+ const auto i =
+ _impl->interface_factories.find(std::string{engine_uri.scheme()});
if (i == _impl->interface_factories.end()) {
log().warn("Unknown URI scheme `%1%'\n", engine_uri.scheme());
return nullptr;
@@ -401,8 +400,7 @@ World::new_interface(const URI& engine_uri,
bool
World::run(const std::string& mime_type, const std::string& filename)
{
- const Impl::ScriptRunners::const_iterator i =
- _impl->script_runners.find(mime_type);
+ const auto i = _impl->script_runners.find(mime_type);
if (i == _impl->script_runners.end()) {
log().warn("Unknown script MIME type `%1%'\n", mime_type);
return false;
diff --git a/src/client/.clang-tidy b/src/client/.clang-tidy
new file mode 100644
index 00000000..2561514f
--- /dev/null
+++ b/src/client/.clang-tidy
@@ -0,0 +1,3 @@
+Checks: >
+ -google-readability-todo,
+InheritParentConfig: true
diff --git a/src/client/BlockModel.cpp b/src/client/BlockModel.cpp
index cdfb3fcd..aa4ef663 100644
--- a/src/client/BlockModel.cpp
+++ b/src/client/BlockModel.cpp
@@ -26,7 +26,6 @@
#include "raul/Path.hpp"
#include "raul/Symbol.hpp"
-#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdlib>
@@ -47,8 +46,7 @@ BlockModel::BlockModel(URIs& uris,
, _num_values(0)
, _min_values(nullptr)
, _max_values(nullptr)
-{
-}
+{}
BlockModel::BlockModel(URIs& uris, URI plugin_uri, const raul::Path& path)
: ObjectModel(uris, path)
@@ -56,8 +54,7 @@ BlockModel::BlockModel(URIs& uris, URI plugin_uri, const raul::Path& path)
, _num_values(0)
, _min_values(nullptr)
, _max_values(nullptr)
-{
-}
+{}
BlockModel::BlockModel(const BlockModel& copy)
: ObjectModel(copy)
@@ -247,11 +244,13 @@ BlockModel::label() const
const Atom& name_property = get_property(_uris.lv2_name);
if (name_property.type() == _uris.forge.String) {
return name_property.ptr<char>();
- } else if (plugin_model()) {
+ }
+
+ if (plugin_model()) {
return plugin_model()->human_name();
- } else {
- return symbol().c_str();
}
+
+ return symbol().c_str();
}
std::string
diff --git a/src/client/ClientStore.cpp b/src/client/ClientStore.cpp
index d8238c8a..80143265 100644
--- a/src/client/ClientStore.cpp
+++ b/src/client/ClientStore.cpp
@@ -103,7 +103,7 @@ std::shared_ptr<ObjectModel>
ClientStore::remove_object(const raul::Path& path)
{
// Find the object, the "top" of the tree to remove
- const iterator top = find(path);
+ const auto top = find(path);
if (top == end()) {
return nullptr;
}
@@ -142,7 +142,7 @@ ClientStore::remove_object(const raul::Path& path)
std::shared_ptr<PluginModel>
ClientStore::_plugin(const URI& uri)
{
- const Plugins::iterator i = _plugins->find(uri);
+ const auto i = _plugins->find(uri);
return (i == _plugins->end()) ? std::shared_ptr<PluginModel>() : (*i).second;
}
@@ -152,7 +152,7 @@ ClientStore::_plugin(const Atom& uri)
/* FIXME: Should probably be stored with URIs rather than strings, to make
this a fast case. */
- const Plugins::iterator i = _plugins->find(URI(_uris.forge.str(uri, false)));
+ const auto i = _plugins->find(URI(_uris.forge.str(uri, false)));
return (i == _plugins->end()) ? std::shared_ptr<PluginModel>() : (*i).second;
}
@@ -165,15 +165,15 @@ ClientStore::plugin(const URI& uri) const
std::shared_ptr<ObjectModel>
ClientStore::_object(const raul::Path& path)
{
- const iterator i = find(path);
+ const auto i = find(path);
if (i == end()) {
return nullptr;
- } else {
- auto model = std::dynamic_pointer_cast<ObjectModel>(i->second);
- assert(model);
- assert(model->path().is_root() || model->parent());
- return model;
}
+
+ auto model = std::dynamic_pointer_cast<ObjectModel>(i->second);
+ assert(model);
+ assert(model->path().is_root() || model->parent());
+ return model;
}
std::shared_ptr<const ObjectModel>
@@ -187,9 +187,9 @@ ClientStore::_resource(const URI& uri)
{
if (uri_is_path(uri)) {
return _object(uri_to_path(uri));
- } else {
- return _plugin(uri);
}
+
+ return _plugin(uri);
}
std::shared_ptr<const Resource>
@@ -235,7 +235,7 @@ ClientStore::operator()(const Copy&)
void
ClientStore::operator()(const Move& msg)
{
- const iterator top = find(msg.old_path);
+ const auto top = find(msg.old_path);
if (top != end()) {
rename(top, msg.new_path);
}
@@ -250,8 +250,6 @@ ClientStore::message(const Message& msg)
void
ClientStore::operator()(const Put& msg)
{
- using Iterator = Properties::const_iterator;
-
const auto& uri = msg.uri;
const auto& properties = msg.properties;
@@ -263,12 +261,12 @@ ClientStore::operator()(const Put& msg)
is_graph, is_block, is_port, is_output);
// Check for specially handled types
- const Iterator t = properties.find(_uris.rdf_type);
+ const auto t = properties.find(_uris.rdf_type);
if (t != properties.end()) {
const Atom& type(t->second);
if (_uris.pset_Preset == type) {
- const Iterator p = properties.find(_uris.lv2_appliesTo);
- const Iterator l = properties.find(_uris.rdfs_label);
+ const auto p = properties.find(_uris.lv2_appliesTo);
+ const auto l = properties.find(_uris.rdfs_label);
std::shared_ptr<PluginModel> plug;
if (p == properties.end()) {
_log.error("Preset <%1%> with no plugin\n", uri.c_str());
@@ -283,7 +281,9 @@ ClientStore::operator()(const Put& msg)
plug->add_preset(uri, l->second.ptr<char>());
}
return;
- } else if (_uris.ingen_Graph == type) {
+ }
+
+ if (_uris.ingen_Graph == type) {
is_graph = true;
} else if (_uris.ingen_Internal == type || _uris.lv2_Plugin == type) {
std::shared_ptr<PluginModel> p(new PluginModel(uris(), uri, type, properties));
@@ -341,8 +341,8 @@ ClientStore::operator()(const Put& msg)
PortModel::Direction pdir = (is_output)
? PortModel::Direction::OUTPUT
: PortModel::Direction::INPUT;
- uint32_t index = 0;
- const Iterator i = properties.find(_uris.lv2_index);
+ uint32_t index = 0;
+ const auto i = properties.find(_uris.lv2_index);
if (i != properties.end() && i->second.type() == _uris.forge.Int) {
index = i->second.get<int32_t>();
}
@@ -454,10 +454,10 @@ ClientStore::attempt_connection(const raul::Path& tail_path,
std::shared_ptr<ArcModel> arc(new ArcModel(tail, head));
graph->add_arc(arc);
return true;
- } else {
- _log.warn("Failed to connect %1% => %2%\n", tail_path, head_path);
- return false;
}
+
+ _log.warn("Failed to connect %1% => %2%\n", tail_path, head_path);
+ return false;
}
void
diff --git a/src/client/GraphModel.cpp b/src/client/GraphModel.cpp
index d4104742..a8a40ec7 100644
--- a/src/client/GraphModel.cpp
+++ b/src/client/GraphModel.cpp
@@ -75,7 +75,7 @@ GraphModel::remove_arcs_on(const std::shared_ptr<PortModel>& p)
{
// Remove any connections which referred to this object,
// since they can't possibly exist anymore
- for (auto j = _arcs.begin(); j != _arcs.end();) {
+ for (auto j = _graph_arcs.begin(); j != _graph_arcs.end();) {
auto next = j;
++next;
@@ -85,7 +85,7 @@ GraphModel::remove_arcs_on(const std::shared_ptr<PortModel>& p)
|| arc->head_path().parent() == p->path()
|| arc->head_path() == p->path()) {
_signal_removed_arc.emit(arc);
- _arcs.erase(j); // Cuts our reference
+ _graph_arcs.erase(j); // Cuts our reference
}
j = next;
}
@@ -94,23 +94,23 @@ GraphModel::remove_arcs_on(const std::shared_ptr<PortModel>& p)
void
GraphModel::clear()
{
- _arcs.clear();
+ _graph_arcs.clear();
BlockModel::clear();
- assert(_arcs.empty());
+ assert(_graph_arcs.empty());
assert(_ports.empty());
}
std::shared_ptr<ArcModel>
GraphModel::get_arc(const Node* tail, const Node* head)
{
- auto i = _arcs.find(std::make_pair(tail, head));
- if (i != _arcs.end()) {
+ auto i = _graph_arcs.find(std::make_pair(tail, head));
+ if (i != _graph_arcs.end()) {
return std::dynamic_pointer_cast<ArcModel>(i->second);
- } else {
- return nullptr;
}
+
+ return nullptr;
}
/** Add a connection to this graph.
@@ -142,8 +142,9 @@ GraphModel::add_arc(const std::shared_ptr<ArcModel>& arc)
assert(arc->tail() == existing->tail());
assert(arc->head() == existing->head());
} else {
- _arcs.emplace(std::make_pair(arc->tail().get(), arc->head().get()),
- arc);
+ _graph_arcs.emplace(std::make_pair(arc->tail().get(),
+ arc->head().get()),
+ arc);
_signal_new_arc.emit(arc);
}
}
@@ -151,11 +152,11 @@ GraphModel::add_arc(const std::shared_ptr<ArcModel>& arc)
void
GraphModel::remove_arc(const Node* tail, const Node* head)
{
- auto i = _arcs.find(std::make_pair(tail, head));
- if (i != _arcs.end()) {
+ auto i = _graph_arcs.find(std::make_pair(tail, head));
+ if (i != _graph_arcs.end()) {
auto arc = std::dynamic_pointer_cast<ArcModel>(i->second);
_signal_removed_arc.emit(arc);
- _arcs.erase(i);
+ _graph_arcs.erase(i);
}
}
diff --git a/src/client/ObjectModel.cpp b/src/client/ObjectModel.cpp
index c172c445..9db429c5 100644
--- a/src/client/ObjectModel.cpp
+++ b/src/client/ObjectModel.cpp
@@ -36,16 +36,14 @@ ObjectModel::ObjectModel(URIs& uris, const raul::Path& path)
: Node(uris, path)
, _path(path)
, _symbol((path == "/") ? "root" : path.symbol())
-{
-}
+{}
ObjectModel::ObjectModel(const ObjectModel& copy)
: Node(copy)
, _parent(copy._parent)
, _path(copy._path)
, _symbol(copy._symbol)
-{
-}
+{}
bool
ObjectModel::is_a(const URIs::Quark& type) const
diff --git a/src/client/PluginModel.cpp b/src/client/PluginModel.cpp
index 4dddd147..306846ee 100644
--- a/src/client/PluginModel.cpp
+++ b/src/client/PluginModel.cpp
@@ -24,7 +24,6 @@
#include <cctype>
#include <cstring>
-#include <iosfwd>
#include <memory>
#include <string>
#include <utility>
@@ -45,13 +44,12 @@ PluginModel::PluginModel(URIs& uris,
const Properties& properties)
: Resource(uris, uri)
, _type(type)
- , _fetched(false)
{
if (!_type.is_valid()) {
if (uri.string().find("ingen-internals") != string::npos) {
_type = uris.ingen_Internal.urid_atom();
} else {
- _type = uris.lv2_Plugin.urid_atom(); // Assume LV2 and hope for the best...
+ _type = uris.lv2_Plugin.urid_atom(); // Assume LV2 and hope for the best...
}
}
@@ -121,21 +119,27 @@ PluginModel::get_property(const URI& key) const
LilvNode* lv2_pred = lilv_new_uri(_lilv_world, key.c_str());
LilvNodes* values = lilv_plugin_get_value(_lilv_plugin, lv2_pred);
lilv_node_free(lv2_pred);
- LILV_FOREACH(nodes, i, values) {
+ LILV_FOREACH (nodes, i, values) {
const LilvNode* value = lilv_nodes_get(values, i);
if (lilv_node_is_uri(value)) {
ret = set_property(
key, _uris.forge.make_urid(URI(lilv_node_as_uri(value))));
break;
- } else if (lilv_node_is_string(value)) {
+ }
+
+ if (lilv_node_is_string(value)) {
ret = set_property(
key, _uris.forge.alloc(lilv_node_as_string(value)));
break;
- } else if (lilv_node_is_float(value)) {
+ }
+
+ if (lilv_node_is_float(value)) {
ret = set_property(
key, _uris.forge.make(lilv_node_as_float(value)));
break;
- } else if (lilv_node_is_int(value)) {
+ }
+
+ if (lilv_node_is_int(value)) {
ret = set_property(
key, _uris.forge.make(lilv_node_as_int(value)));
break;
@@ -181,9 +185,9 @@ PluginModel::default_block_symbol() const
const Atom& name_atom = get_property(_uris.lv2_symbol);
if (name_atom.is_valid() && name_atom.type() == _uris.forge.String) {
return raul::Symbol::symbolify(name_atom.ptr<char>());
- } else {
- return raul::Symbol("_");
}
+
+ return raul::Symbol("_");
}
string
@@ -192,9 +196,9 @@ PluginModel::human_name() const
const Atom& name_atom = get_property(_uris.doap_name);
if (name_atom.type() == _uris.forge.String) {
return name_atom.ptr<char>();
- } else {
- return default_block_symbol().c_str();
}
+
+ return default_block_symbol().c_str();
}
string
@@ -218,7 +222,7 @@ PluginModel::port_scale_points(const uint32_t index) const
if (_lilv_plugin) {
const LilvPort* port = lilv_plugin_get_port_by_index(_lilv_plugin, index);
LilvScalePoints* sp = lilv_port_get_scale_points(_lilv_plugin, port);
- LILV_FOREACH(scale_points, i, sp) {
+ LILV_FOREACH (scale_points, i, sp) {
const LilvScalePoint* p = lilv_scale_points_get(sp, i);
points.emplace(
lilv_node_as_float(lilv_scale_point_get_value(p)),
@@ -257,9 +261,9 @@ heading(const std::string& text, bool html, unsigned level)
if (html) {
const std::string tag = std::string("h") + std::to_string(level);
return std::string("<") + tag + ">" + text + "</" + tag + ">\n";
- } else {
- return text + ":\n\n";
}
+
+ return text + ":\n\n";
}
static std::string
@@ -267,9 +271,9 @@ link(const std::string& addr, bool html)
{
if (html) {
return std::string("<a href=\"") + addr + "\">" + addr + "</a>";
- } else {
- return addr;
}
+
+ return addr;
}
std::string
diff --git a/src/client/PluginUI.cpp b/src/client/PluginUI.cpp
index 7292d8b2..031caceb 100644
--- a/src/client/PluginUI.cpp
+++ b/src/client/PluginUI.cpp
@@ -78,7 +78,7 @@ lv2_ui_write(SuilController controller,
const float value = *static_cast<const float*>(buffer);
if (port->value().type() == uris.atom_Float &&
value == port->value().get<float>()) {
- return; // Ignore feedback
+ return; // Ignore feedback
}
ui->signal_property_changed()(
@@ -166,13 +166,11 @@ PluginUI::PluginUI(ingen::World& world,
const LilvNode* ui_type)
: _world(world)
, _block(std::move(block))
- , _instance(nullptr)
, _uis(uis)
, _ui(ui)
, _ui_node(lilv_node_duplicate(lilv_ui_get_uri(ui)))
, _ui_type(lilv_node_duplicate(ui_type))
-{
-}
+{}
PluginUI::~PluginUI()
{
@@ -205,7 +203,7 @@ PluginUI::create(ingen::World& world,
LilvUIs* uis = lilv_plugin_get_uis(plugin);
const LilvUI* ui = nullptr;
const LilvNode* ui_type = nullptr;
- LILV_FOREACH(uis, u, uis) {
+ LILV_FOREACH (uis, u, uis) {
const LilvUI* this_ui = lilv_uis_get(uis, u);
if (lilv_ui_is_supported(this_ui,
suil_ui_supported,
@@ -247,7 +245,7 @@ PluginUI::instantiate()
LilvNode* ui_plugin = lilv_new_uri(lworld, LV2_UI__plugin);
LilvNodes* notes = lilv_world_find_nodes(
lworld, lilv_ui_get_uri(_ui), ui_portNotification, nullptr);
- LILV_FOREACH(nodes, n, notes) {
+ LILV_FOREACH (nodes, n, notes) {
const LilvNode* note = lilv_nodes_get(notes, n);
const LilvNode* sym = lilv_world_get(lworld, note, uris.lv2_symbol, nullptr);
const LilvNode* plug = lilv_world_get(lworld, note, ui_plugin, nullptr);
diff --git a/src/client/ingen_client.cpp b/src/client/ingen_client.cpp
index f4d6bbc7..63705ebc 100644
--- a/src/client/ingen_client.cpp
+++ b/src/client/ingen_client.cpp
@@ -31,7 +31,7 @@ struct ClientModule : public ingen::Module {
extern "C" {
-ingen::Module*
+INGEN_MODULE_EXPORT ingen::Module*
ingen_module_load()
{
return new ingen::client::ClientModule();
diff --git a/src/client/meson.build b/src/client/meson.build
new file mode 100644
index 00000000..7c040634
--- /dev/null
+++ b/src/client/meson.build
@@ -0,0 +1,50 @@
+# Copyright 2022 David Robillard <d@drobilla.net>
+# SPDX-License-Identifier: 0BSD OR GPL-3.0-or-later
+
+################
+# Dependencies #
+################
+
+sigcpp_dep = dependency('sigc++-2.0', include_type: 'system')
+
+##########
+# Module #
+##########
+
+client_sources = files(
+ 'BlockModel.cpp',
+ 'ClientStore.cpp',
+ 'GraphModel.cpp',
+ 'ObjectModel.cpp',
+ 'PluginModel.cpp',
+ 'PluginUI.cpp',
+ 'PortModel.cpp',
+ 'ingen_client.cpp',
+)
+
+client_dependencies = [
+ boost_dep,
+ ingen_dep,
+ lilv_dep,
+ lv2_dep,
+ raul_dep,
+ sigcpp_dep,
+ suil_dep,
+]
+
+libingen_client = shared_library(
+ 'ingen_client',
+ client_sources,
+ cpp_args: cpp_suppressions + platform_defines + ['-DINGEN_CLIENT_INTERNAL'],
+ dependencies: client_dependencies,
+ gnu_symbol_visibility: 'hidden',
+ implicit_include_directories: false,
+ include_directories: ingen_include_dirs,
+ install: true,
+ install_dir: ingen_module_dir,
+)
+
+ingen_client_dep = declare_dependency(
+ dependencies: client_dependencies,
+ link_with: libingen_client,
+)
diff --git a/src/client/wscript b/src/client/wscript
deleted file mode 100644
index d63fb56c..00000000
--- a/src/client/wscript
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/usr/bin/env python
-
-
-def build(bld):
- obj = bld(features = 'cxx cxxshlib',
- cflags = ['-fvisibility=hidden'],
- includes = ['../../', '../../include'],
- export_includes = ['../../include'],
- name = 'libingen_client',
- target = 'ingen_client',
- install_path = '${LIBDIR}',
- use = 'libingen',
- uselib = 'GLIBMM LV2 LILV SUIL RAUL SERD SORD SIGCPP')
-
- obj.source = '''
- BlockModel.cpp
- ClientStore.cpp
- GraphModel.cpp
- ObjectModel.cpp
- PluginModel.cpp
- PluginUI.cpp
- PortModel.cpp
- ingen_client.cpp
- '''
diff --git a/src/gui/.clang-tidy b/src/gui/.clang-tidy
index 7f216d2c..5f6e0c3f 100644
--- a/src/gui/.clang-tidy
+++ b/src/gui/.clang-tidy
@@ -1,74 +1,29 @@
Checks: >
- *,
- -*-avoid-c-arrays,
- -*-else-after-return,
- -*-magic-numbers,
- -*-member-init,
- -*-named-parameter,
- -*-narrowing-conversions,
- -*-non-private-member-variables-in-classes,
- -*-special-member-functions,
- -*-uppercase-literal-suffix,
- -abseil-string-find-str-contains,
-android-cloexec-*,
-bugprone-branch-clone,
-bugprone-exception-escape,
-bugprone-macro-parentheses,
-bugprone-parent-virtual-call,
-bugprone-reserved-identifier,
- -bugprone-signed-char-misuse,
-bugprone-suspicious-string-compare,
-cert-dcl21-cpp,
-cert-dcl37-c,
- -cert-dcl50-cpp,
-cert-dcl51-cpp,
- -cert-err34-c,
-cert-err58-cpp,
-cert-str34-c,
- -clang-analyzer-alpha.*,
-clang-analyzer-core.CallAndMessage,
- -clang-analyzer-optin.cplusplus.VirtualCall,
- -clang-analyzer-valist.Uninitialized,
- -cppcoreguidelines-avoid-non-const-global-variables,
-cppcoreguidelines-macro-usage,
- -cppcoreguidelines-no-malloc,
- -cppcoreguidelines-owning-memory,
- -cppcoreguidelines-pro-bounds-array-to-pointer-decay,
-cppcoreguidelines-pro-bounds-constant-array-index,
- -cppcoreguidelines-pro-bounds-pointer-arithmetic,
- -cppcoreguidelines-pro-type-const-cast,
-cppcoreguidelines-pro-type-cstyle-cast,
- -cppcoreguidelines-pro-type-reinterpret-cast,
-cppcoreguidelines-pro-type-static-cast-downcast,
- -cppcoreguidelines-pro-type-union-access,
-cppcoreguidelines-pro-type-vararg,
-cppcoreguidelines-slicing,
- -fuchsia-*,
-google-default-arguments,
- -google-explicit-constructor,
-google-readability-todo,
-google-runtime-int,
-google-runtime-references,
- -hicpp-explicit-conversions,
-hicpp-multiway-paths-covered,
- -hicpp-no-array-decay,
- -hicpp-no-malloc,
- -hicpp-signed-bitwise,
-hicpp-vararg,
- -llvm-header-guard,
- -llvmlibc-*,
- -misc-no-recursion,
- -misc-unused-parameters,
- -modernize-use-trailing-return-type,
+ -modernize-avoid-bind,
-readability-convert-member-functions-to-static,
- -readability-implicit-bool-conversion,
- -readability-use-anyofallof,
-CheckOptions:
- - key: modernize-use-override.AllowOverrideAndFinal
- value: 'true'
-CheckOptions:
- - key: cppcoreguidelines-explicit-virtual-functions.AllowOverrideAndFinal
- value: 'true'
-WarningsAsErrors: '*'
-HeaderFilterRegex: 'include/ingen/.*|tests/.*|src/.*'
-FormatStyle: file
+InheritParentConfig: true
diff --git a/src/gui/App.cpp b/src/gui/App.cpp
index dc51df1d..ff9636b9 100644
--- a/src/gui/App.cpp
+++ b/src/gui/App.cpp
@@ -83,15 +83,6 @@ App::App(ingen::World& world)
: _style(new Style(*this))
, _window_factory(new WindowFactory(*this))
, _world(world)
- , _sample_rate(48000)
- , _block_length(1024)
- , _n_threads(1)
- , _mean_run_load(0.0f)
- , _min_run_load(0.0f)
- , _max_run_load(0.0f)
- , _enable_signal(true)
- , _requested_plugins(false)
- , _is_plugin(false)
{
_world.conf().load_default("ingen", "gui.ttl");
@@ -326,7 +317,9 @@ App::property_change(const URI& subject,
{
if (subject != URI("ingen:/engine")) {
return;
- } else if (key == uris().param_sampleRate && value.type() == forge().Int) {
+ }
+
+ if (key == uris().param_sampleRate && value.type() == forge().Int) {
_sample_rate = value.get<int32_t>();
} else if (key == uris().bufsz_maxBlockLength && value.type() == forge().Int) {
_block_length = value.get<int32_t>();
@@ -376,7 +369,7 @@ App::status_text() const
void
App::port_activity(Port* port)
{
- std::pair<ActivityPorts::iterator, bool> inserted = _activity_ports.emplace(port, false);
+ const auto inserted = _activity_ports.emplace(port, false);
if (inserted.second) {
inserted.first->second = false;
}
diff --git a/src/gui/App.hpp b/src/gui/App.hpp
index c09d1cd5..bb17e126 100644
--- a/src/gui/App.hpp
+++ b/src/gui/App.hpp
@@ -139,9 +139,9 @@ public:
sigc::signal<void, const std::string&> signal_status_text_changed;
- inline ingen::World& world() const { return _world; }
- inline ingen::URIs& uris() const { return _world.uris(); }
- inline ingen::Log& log() const { return _world.log(); }
+ ingen::World& world() const { return _world; }
+ ingen::URIs& uris() const { return _world.uris(); }
+ ingen::Log& log() const { return _world.log(); }
protected:
explicit App(ingen::World& world);
@@ -177,20 +177,20 @@ protected:
ingen::World& _world;
- int32_t _sample_rate;
- int32_t _block_length;
- int32_t _n_threads;
- float _mean_run_load;
- float _min_run_load;
- float _max_run_load;
+ int32_t _sample_rate{48000};
+ int32_t _block_length{1024};
+ int32_t _n_threads{1};
+ float _mean_run_load{0.0f};
+ float _min_run_load{0.0f};
+ float _max_run_load{0.0f};
std::string _status_text;
using ActivityPorts = std::unordered_map<Port*, bool>;
ActivityPorts _activity_ports;
- bool _enable_signal;
- bool _requested_plugins;
- bool _is_plugin;
+ bool _enable_signal{true};
+ bool _requested_plugins{false};
+ bool _is_plugin{false};
};
} // namespace gui
diff --git a/src/gui/Arc.hpp b/src/gui/Arc.hpp
index 746f6d61..82467a5a 100644
--- a/src/gui/Arc.hpp
+++ b/src/gui/Arc.hpp
@@ -28,7 +28,9 @@ class Node;
namespace ingen {
-namespace client { class ArcModel; }
+namespace client {
+class ArcModel;
+} // namespace client
namespace gui {
diff --git a/src/gui/BreadCrumbs.cpp b/src/gui/BreadCrumbs.cpp
index 4e257d88..46a0757a 100644
--- a/src/gui/BreadCrumbs.cpp
+++ b/src/gui/BreadCrumbs.cpp
@@ -37,7 +37,6 @@ using std::string;
BreadCrumbs::BreadCrumbs(App& app)
: _active_path("/")
, _full_path("/")
- , _enable_signal(true)
{
app.sig_client()->signal_message().connect(
sigc::mem_fun(this, &BreadCrumbs::message));
@@ -78,7 +77,7 @@ BreadCrumbs::build(const raul::Path& path,
b->set_view(view);
}
- // views are expensive, having two around for the same graph is a bug
+ // Views are expensive, having two around is a bug
assert(b->view() == view);
} else {
@@ -90,7 +89,7 @@ BreadCrumbs::build(const raul::Path& path,
_enable_signal = old_enable_signal;
} else if (!_breadcrumbs.empty() && path.is_child_of(_full_path)) {
- // Moving to a child of the full path, just append crumbs (preserve view cache)
+ // Moving to a child of the full path, append crumbs (preserve cache)
string suffix = path.substr(_full_path.length());
while (suffix.length() > 0) {
@@ -105,9 +104,9 @@ BreadCrumbs::build(const raul::Path& path,
but->show();
if (suffix.find('/') == string::npos) {
break;
- } else {
- suffix = suffix.substr(suffix.find('/') + 1);
}
+
+ suffix = suffix.substr(suffix.find('/') + 1);
}
for (const auto& b : _breadcrumbs) {
@@ -116,8 +115,8 @@ BreadCrumbs::build(const raul::Path& path,
_breadcrumbs.back()->set_active(true);
} else {
- // Rebuild from scratch
- // Getting here is bad unless absolutely necessary, since the GraphView cache is lost
+ /* Rebuild from scratch. Getting here is bad unless absolutely
+ necessary, since the GraphView cache is lost. */
_full_path = path;
_active_path = path;
@@ -149,9 +148,9 @@ BreadCrumbs::build(const raul::Path& path,
but->show();
if (suffix.find('/') == string::npos) {
break;
- } else {
- suffix = suffix.substr(suffix.find('/')+1);
}
+
+ suffix = suffix.substr(suffix.find('/')+1);
}
}
diff --git a/src/gui/BreadCrumbs.hpp b/src/gui/BreadCrumbs.hpp
index d877d0c5..9ed6f04a 100644
--- a/src/gui/BreadCrumbs.hpp
+++ b/src/gui/BreadCrumbs.hpp
@@ -118,7 +118,7 @@ private:
raul::Path _active_path;
raul::Path _full_path;
- bool _enable_signal;
+ bool _enable_signal{true};
std::list<BreadCrumb*> _breadcrumbs;
};
diff --git a/src/gui/ConnectWindow.cpp b/src/gui/ConnectWindow.cpp
index ea1a6e27..a4c8a433 100644
--- a/src/gui/ConnectWindow.cpp
+++ b/src/gui/ConnectWindow.cpp
@@ -70,29 +70,7 @@ ConnectWindow::ConnectWindow(BaseObjectType* cobject,
Glib::RefPtr<Gtk::Builder> xml)
: Dialog(cobject)
, _xml(std::move(xml))
- , _icon(nullptr)
- , _progress_bar(nullptr)
- , _progress_label(nullptr)
- , _url_entry(nullptr)
- , _server_radio(nullptr)
- , _port_spinbutton(nullptr)
- , _launch_radio(nullptr)
- , _internal_radio(nullptr)
- , _activate_button(nullptr)
- , _deactivate_button(nullptr)
- , _disconnect_button(nullptr)
- , _connect_button(nullptr)
- , _quit_button(nullptr)
- , _mode(Mode::CONNECT_REMOTE)
- , _connect_uri("unix:///tmp/ingen.sock")
- , _ping_id(-1)
- , _attached(false)
- , _finished_connecting(false)
- , _widgets_loaded(false)
- , _connect_stage(0)
- , _quit_flag(false)
-{
-}
+{}
void
ConnectWindow::message(const Message& msg)
@@ -236,10 +214,10 @@ ConnectWindow::connect(bool existing)
if (_app->client()) {
error("Already connected");
return;
- } else if (_attached) {
- _attached = false;
}
+ _attached = false;
+
set_connecting_widget_states();
_connect_stage = 0;
@@ -286,10 +264,14 @@ ConnectWindow::connect(bool existing)
if (!world.load_module("server")) {
error("Failed to load server module");
return;
- } else if (!world.load_module("jack")) {
+ }
+
+ if (!world.load_module("jack")) {
error("Failed to load jack module");
return;
- } else if (!world.engine()->activate()) {
+ }
+
+ if (!world.engine()->activate()) {
error("Failed to activate engine");
return;
}
@@ -577,9 +559,9 @@ ConnectWindow::gtk_callback()
_progress_label->set_text(std::string("Disconnected"));
}
return false;
- } else {
- return true;
}
+
+ return true;
}
void
diff --git a/src/gui/ConnectWindow.hpp b/src/gui/ConnectWindow.hpp
index 6fc4dbfb..b0e03850 100644
--- a/src/gui/ConnectWindow.hpp
+++ b/src/gui/ConnectWindow.hpp
@@ -100,28 +100,28 @@ private:
const Glib::RefPtr<Gtk::Builder> _xml;
- Gtk::Image* _icon;
- Gtk::ProgressBar* _progress_bar;
- Gtk::Label* _progress_label;
- Gtk::Entry* _url_entry;
- Gtk::RadioButton* _server_radio;
- Gtk::SpinButton* _port_spinbutton;
- Gtk::RadioButton* _launch_radio;
- Gtk::RadioButton* _internal_radio;
- Gtk::Button* _activate_button;
- Gtk::Button* _deactivate_button;
- Gtk::Button* _disconnect_button;
- Gtk::Button* _connect_button;
- Gtk::Button* _quit_button;
-
- Mode _mode;
- URI _connect_uri;
- int32_t _ping_id;
- bool _attached;
- bool _finished_connecting;
- bool _widgets_loaded;
- int _connect_stage;
- bool _quit_flag;
+ Gtk::Image* _icon{nullptr};
+ Gtk::ProgressBar* _progress_bar{nullptr};
+ Gtk::Label* _progress_label{nullptr};
+ Gtk::Entry* _url_entry{nullptr};
+ Gtk::RadioButton* _server_radio{nullptr};
+ Gtk::SpinButton* _port_spinbutton{nullptr};
+ Gtk::RadioButton* _launch_radio{nullptr};
+ Gtk::RadioButton* _internal_radio{nullptr};
+ Gtk::Button* _activate_button{nullptr};
+ Gtk::Button* _deactivate_button{nullptr};
+ Gtk::Button* _disconnect_button{nullptr};
+ Gtk::Button* _connect_button{nullptr};
+ Gtk::Button* _quit_button{nullptr};
+
+ Mode _mode{Mode::CONNECT_REMOTE};
+ URI _connect_uri{"unix:///tmp/ingen.sock"};
+ int32_t _ping_id{-1};
+ bool _attached{false};
+ bool _finished_connecting{false};
+ bool _widgets_loaded{false};
+ int _connect_stage{0};
+ bool _quit_flag{false};
};
} // namespace gui
diff --git a/src/gui/GraphBox.cpp b/src/gui/GraphBox.cpp
index f994d47c..14258a5a 100644
--- a/src/gui/GraphBox.cpp
+++ b/src/gui/GraphBox.cpp
@@ -27,6 +27,7 @@
#include "ThreadedLoader.hpp"
#include "WidgetFactory.hpp"
#include "WindowFactory.hpp"
+#include "ingen_config.h"
#include "ganv/canvas.h"
#include "ingen/Atom.hpp"
@@ -87,8 +88,8 @@
#include <sigc++/functors/mem_fun.h>
#include <sigc++/signal.h>
-#ifdef HAVE_WEBKIT
-#include <webkit/webkit.h>
+#if USE_WEBKIT
+# include <webkit/webkit.h>
#endif
#include <cassert>
@@ -449,7 +450,7 @@ GraphBox::set_documentation(const std::string& doc, bool html)
_doc_scrolledwindow->hide();
return;
}
-#ifdef HAVE_WEBKIT
+#if USE_WEBKIT
WebKitWebView* view = WEBKIT_WEB_VIEW(webkit_web_view_new());
webkit_web_view_load_html_string(view, doc.c_str(), "");
Gtk::Widget* widget = Gtk::manage(Glib::wrap(GTK_WIDGET(view)));
@@ -716,18 +717,17 @@ GraphBox::event_export_image()
dialog.set_transient_for(*_window);
}
- using Types = std::map<std::string, std::string>;
- Types types;
+ std::map<std::string, std::string> types;
types["*.dot"] = "Graphviz DOT";
types["*.pdf"] = "Portable Document Format";
types["*.ps"] = "PostScript";
types["*.svg"] = "Scalable Vector Graphics";
- for (Types::const_iterator t = types.begin(); t != types.end(); ++t) {
+ for (const auto& t : types) {
Gtk::FileFilter filt;
- filt.add_pattern(t->first);
- filt.set_name(t->second);
+ filt.add_pattern(t.first);
+ filt.set_name(t.second);
dialog.add_filter(filt);
- if (t->first == "*.pdf") {
+ if (t.first == "*.pdf") {
dialog.set_filter(filt);
}
}
diff --git a/src/gui/GraphCanvas.cpp b/src/gui/GraphCanvas.cpp
index 77c33052..3acd510d 100644
--- a/src/gui/GraphCanvas.cpp
+++ b/src/gui/GraphCanvas.cpp
@@ -14,9 +14,10 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "GraphCanvas.hpp"
+
#include "App.hpp"
#include "Arc.hpp"
-#include "GraphCanvas.hpp"
#include "GraphPortModule.hpp"
#include "GraphWindow.hpp"
#include "NodeModule.hpp"
@@ -129,10 +130,6 @@ GraphCanvas::GraphCanvas(App& app,
: Canvas(width, height)
, _app(app)
, _graph(std::move(graph))
- , _auto_position_count(0)
- , _menu_x(0)
- , _menu_y(0)
- , _paste_count(0)
{
Glib::RefPtr<Gtk::Builder> xml = WidgetFactory::create("canvas_menu");
xml->get_widget("canvas_menu", _menu);
@@ -284,7 +281,7 @@ GraphCanvas::build()
const Store::const_range kids = _app.store()->children_range(_graph);
// Create modules for blocks
- for (Store::const_iterator i = kids.first; i != kids.second; ++i) {
+ for (auto i = kids.first; i != kids.second; ++i) {
auto block = std::dynamic_pointer_cast<BlockModel>(i->second);
if (block && block->parent() == _graph) {
add_block(block);
@@ -440,14 +437,14 @@ GraphCanvas::get_port_view(const std::shared_ptr<PortModel>& port)
return ppm
? *ppm->begin()
: dynamic_cast<Ganv::Port*>(module);
- } else {
- module = dynamic_cast<NodeModule*>(_views[port->parent()]);
- if (module) {
- for (auto* p : *module) {
- auto* pv = dynamic_cast<gui::Port*>(p);
- if (pv && pv->model() == port) {
- return pv;
- }
+ }
+
+ module = dynamic_cast<NodeModule*>(_views[port->parent()]);
+ if (module) {
+ for (auto* p : *module) {
+ auto* pv = dynamic_cast<gui::Port*>(p);
+ if (pv && pv->model() == port) {
+ return pv;
}
}
}
@@ -482,7 +479,7 @@ GraphCanvas::disconnection(const std::shared_ptr<const ArcModel>& arc)
if (arc->head()->is_a(_app.uris().lv2_AudioPort)) {
auto* const h = dynamic_cast<gui::Port*>(head);
if (h) {
- h->activity(_app.forge().make(0.0f)); // Reset peaks
+ h->activity(_app.forge().make(0.0f)); // Reset peaks
}
}
} else {
@@ -707,8 +704,6 @@ GraphCanvas::copy_selection()
void
GraphCanvas::paste()
{
- using PropIter = Properties::const_iterator;
-
std::lock_guard<std::mutex> lock(_app.world().rdf_mutex());
const Glib::ustring str = Gtk::Clipboard::get()->wait_for_text();
@@ -807,8 +802,8 @@ GraphCanvas::paste()
}
// Set coordinates so paste origin is at the mouse pointer
- PropIter xi = node->properties().find(uris.ingen_canvasX);
- PropIter yi = node->properties().find(uris.ingen_canvasY);
+ const auto xi = node->properties().find(uris.ingen_canvasX);
+ const auto yi = node->properties().find(uris.ingen_canvasY);
if (xi != node->properties().end()) {
const float x = xi->second.get<float>() - min_x + paste_x;
props.insert({xi->first, Property(_app.forge().make(x),
diff --git a/src/gui/GraphCanvas.hpp b/src/gui/GraphCanvas.hpp
index b1e60aa3..3ebd61df 100644
--- a/src/gui/GraphCanvas.hpp
+++ b/src/gui/GraphCanvas.hpp
@@ -141,12 +141,12 @@ private:
using Views = std::map<std::shared_ptr<const client::ObjectModel>, Ganv::Module*>;
Views _views;
- int _auto_position_count;
+ int _auto_position_count{0};
std::pair<int, int> _auto_position_scroll_offsets;
- int _menu_x;
- int _menu_y;
- int _paste_count;
+ int _menu_x{0};
+ int _menu_y{0};
+ int _paste_count{0};
// Track pasted objects so they can be selected when they arrive
std::set<raul::Path> _pastees;
diff --git a/src/gui/GraphPortModule.cpp b/src/gui/GraphPortModule.cpp
index 3206f80b..4c161f3f 100644
--- a/src/gui/GraphPortModule.cpp
+++ b/src/gui/GraphPortModule.cpp
@@ -14,9 +14,10 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "GraphPortModule.hpp"
+
#include "App.hpp"
#include "GraphCanvas.hpp"
-#include "GraphPortModule.hpp"
#include "Port.hpp"
#include "ingen/Atom.hpp"
@@ -50,7 +51,6 @@ GraphPortModule::GraphPortModule(
const std::shared_ptr<const client::PortModel>& model)
: Ganv::Module(canvas, "", 0, 0, false) // FIXME: coords?
, _model(model)
- , _port(nullptr)
{
assert(model);
diff --git a/src/gui/GraphPortModule.hpp b/src/gui/GraphPortModule.hpp
index 5ce7ea57..b02f63a1 100644
--- a/src/gui/GraphPortModule.hpp
+++ b/src/gui/GraphPortModule.hpp
@@ -76,7 +76,7 @@ protected:
void property_changed(const URI& key, const Atom& value);
std::shared_ptr<const client::PortModel> _model;
- Port* _port;
+ Port* _port{nullptr};
};
} // namespace gui
diff --git a/src/gui/GraphTreeWindow.cpp b/src/gui/GraphTreeWindow.cpp
index e1ef158f..53defd75 100644
--- a/src/gui/GraphTreeWindow.cpp
+++ b/src/gui/GraphTreeWindow.cpp
@@ -14,8 +14,9 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "App.hpp"
#include "GraphTreeWindow.hpp"
+
+#include "App.hpp"
#include "Window.hpp"
#include "WindowFactory.hpp"
@@ -56,8 +57,6 @@ namespace gui {
GraphTreeWindow::GraphTreeWindow(BaseObjectType* cobject,
const Glib::RefPtr<Gtk::Builder>& xml)
: Window(cobject)
- , _graphs_treeview(nullptr)
- , _enable_signal(true)
{
xml->get_widget_derived("graphs_treeview", _graphs_treeview);
@@ -108,8 +107,8 @@ void
GraphTreeWindow::add_graph(const std::shared_ptr<GraphModel>& pm)
{
if (!pm->parent()) {
- Gtk::TreeModel::iterator iter = _graph_treestore->append();
- Gtk::TreeModel::Row row = *iter;
+ const auto iter = _graph_treestore->append();
+ auto row = *iter;
if (pm->path().is_root()) {
row[_graph_tree_columns.name_col] = _app->interface()->uri().string();
} else {
@@ -119,12 +118,13 @@ GraphTreeWindow::add_graph(const std::shared_ptr<GraphModel>& pm)
row[_graph_tree_columns.graph_model_col] = pm;
_graphs_treeview->expand_row(_graph_treestore->get_path(iter), true);
} else {
- Gtk::TreeModel::Children children = _graph_treestore->children();
- Gtk::TreeModel::iterator c = find_graph(children, pm->parent());
+ const auto& children = _graph_treestore->children();
+ auto c = find_graph(children, pm->parent());
if (c != children.end()) {
- Gtk::TreeModel::iterator iter = _graph_treestore->append(c->children());
- Gtk::TreeModel::Row row = *iter;
+ const auto iter = _graph_treestore->append(c->children());
+ auto row = *iter;
+
row[_graph_tree_columns.name_col] = pm->symbol().c_str();
row[_graph_tree_columns.enabled_col] = pm->enabled();
row[_graph_tree_columns.graph_model_col] = pm;
@@ -148,7 +148,7 @@ GraphTreeWindow::add_graph(const std::shared_ptr<GraphModel>& pm)
void
GraphTreeWindow::remove_graph(const std::shared_ptr<GraphModel>& pm)
{
- Gtk::TreeModel::iterator i = find_graph(_graph_treestore->children(), pm);
+ const auto i = find_graph(_graph_treestore->children(), pm);
if (i != _graph_treestore->children().end()) {
_graph_treestore->erase(i);
}
@@ -158,12 +158,14 @@ Gtk::TreeModel::iterator
GraphTreeWindow::find_graph(Gtk::TreeModel::Children root,
const std::shared_ptr<client::ObjectModel>& graph)
{
- for (Gtk::TreeModel::iterator c = root.begin(); c != root.end(); ++c) {
+ for (auto c = root.begin(); c != root.end(); ++c) {
std::shared_ptr<GraphModel> pm = (*c)[_graph_tree_columns.graph_model_col];
if (graph == pm) {
return c;
- } else if (!(*c)->children().empty()) {
- Gtk::TreeModel::iterator ret = find_graph(c->children(), graph);
+ }
+
+ if (!(*c)->children().empty()) {
+ auto ret = find_graph(c->children(), graph);
if (ret != c->children().end()) {
return ret;
}
@@ -177,10 +179,12 @@ GraphTreeWindow::find_graph(Gtk::TreeModel::Children root,
void
GraphTreeWindow::show_graph_menu(GdkEventButton* ev)
{
- Gtk::TreeModel::iterator active = _graph_tree_selection->get_selected();
+ const auto active = _graph_tree_selection->get_selected();
if (active) {
- Gtk::TreeModel::Row row = *active;
- std::shared_ptr<GraphModel> pm = row[_graph_tree_columns.graph_model_col];
+ auto row = *active;
+ auto col = _graph_tree_columns.graph_model_col;
+
+ const std::shared_ptr<GraphModel>& pm = row[col];
if (pm) {
_app->log().warn("TODO: graph menu from tree window");
}
@@ -191,9 +195,10 @@ void
GraphTreeWindow::event_graph_activated(const Gtk::TreeModel::Path& path,
Gtk::TreeView::Column* col)
{
- Gtk::TreeModel::iterator active = _graph_treestore->get_iter(path);
- Gtk::TreeModel::Row row = *active;
- std::shared_ptr<GraphModel> pm = row[_graph_tree_columns.graph_model_col];
+ const auto active = _graph_treestore->get_iter(path);
+ auto row = *active;
+
+ std::shared_ptr<GraphModel> pm = row[_graph_tree_columns.graph_model_col];
_app->window_factory()->present_graph(pm);
}
@@ -201,9 +206,9 @@ GraphTreeWindow::event_graph_activated(const Gtk::TreeModel::Path& path,
void
GraphTreeWindow::event_graph_enabled_toggled(const Glib::ustring& path_str)
{
- Gtk::TreeModel::Path path(path_str);
- Gtk::TreeModel::iterator active = _graph_treestore->get_iter(path);
- Gtk::TreeModel::Row row = *active;
+ Gtk::TreeModel::Path path(path_str);
+ auto active = _graph_treestore->get_iter(path);
+ auto row = *active;
std::shared_ptr<GraphModel> pm = row[_graph_tree_columns.graph_model_col];
assert(pm);
@@ -224,9 +229,9 @@ GraphTreeWindow::graph_property_changed(
const URIs& uris = _app->uris();
_enable_signal = false;
if (key == uris.ingen_enabled && value.type() == uris.forge.Bool) {
- Gtk::TreeModel::iterator i = find_graph(_graph_treestore->children(), graph);
+ const auto i = find_graph(_graph_treestore->children(), graph);
if (i != _graph_treestore->children().end()) {
- Gtk::TreeModel::Row row = *i;
+ auto row = *i;
row[_graph_tree_columns.enabled_col] = value.get<int32_t>();
} else {
_app->log().error("Unable to find graph %1%\n", graph->path());
@@ -240,11 +245,9 @@ GraphTreeWindow::graph_moved(const std::shared_ptr<GraphModel>& graph)
{
_enable_signal = false;
- Gtk::TreeModel::iterator i
- = find_graph(_graph_treestore->children(), graph);
-
+ auto i = find_graph(_graph_treestore->children(), graph);
if (i != _graph_treestore->children().end()) {
- Gtk::TreeModel::Row row = *i;
+ auto row = *i;
row[_graph_tree_columns.name_col] = graph->symbol().c_str();
} else {
_app->log().error("Unable to find graph %1%\n", graph->path());
diff --git a/src/gui/GraphTreeWindow.hpp b/src/gui/GraphTreeWindow.hpp
index 1a719a81..8534d66c 100644
--- a/src/gui/GraphTreeWindow.hpp
+++ b/src/gui/GraphTreeWindow.hpp
@@ -87,10 +87,9 @@ protected:
find_graph(Gtk::TreeModel::Children root,
const std::shared_ptr<client::ObjectModel>& graph);
- GraphTreeView* _graphs_treeview;
+ GraphTreeView* _graphs_treeview{nullptr};
- struct GraphTreeModelColumns : public Gtk::TreeModel::ColumnRecord
- {
+ struct GraphTreeModelColumns : public Gtk::TreeModel::ColumnRecord {
GraphTreeModelColumns() {
add(name_col);
add(enabled_col);
@@ -105,7 +104,7 @@ protected:
GraphTreeModelColumns _graph_tree_columns;
Glib::RefPtr<Gtk::TreeStore> _graph_treestore;
Glib::RefPtr<Gtk::TreeSelection> _graph_tree_selection;
- bool _enable_signal;
+ bool _enable_signal{true};
};
/** Derived TreeView class to support context menus for graphs */
@@ -115,7 +114,6 @@ public:
GraphTreeView(BaseObjectType* cobject,
const Glib::RefPtr<Gtk::Builder>& xml)
: Gtk::TreeView(cobject)
- , _window(nullptr)
{}
void set_window(GraphTreeWindow* win) { _window = win; }
@@ -131,7 +129,7 @@ public:
}
private:
- GraphTreeWindow* _window;
+ GraphTreeWindow* _window{nullptr};
};
} // namespace gui
diff --git a/src/gui/GraphView.cpp b/src/gui/GraphView.cpp
index bd493499..a5ca7dd1 100644
--- a/src/gui/GraphView.cpp
+++ b/src/gui/GraphView.cpp
@@ -14,9 +14,10 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "GraphView.hpp"
+
#include "App.hpp"
#include "GraphCanvas.hpp"
-#include "GraphView.hpp"
#include "WidgetFactory.hpp"
#include "ingen/Atom.hpp"
diff --git a/src/gui/GraphWindow.cpp b/src/gui/GraphWindow.cpp
index 38273a8e..94df34e0 100644
--- a/src/gui/GraphWindow.cpp
+++ b/src/gui/GraphWindow.cpp
@@ -32,10 +32,6 @@ namespace gui {
GraphWindow::GraphWindow(BaseObjectType* cobject,
const Glib::RefPtr<Gtk::Builder>& xml)
: Window(cobject)
- , _box(nullptr)
- , _position_stored(false)
- , _x(0)
- , _y(0)
{
property_visible() = false;
diff --git a/src/gui/GraphWindow.hpp b/src/gui/GraphWindow.hpp
index 290e0e00..d1361ca5 100644
--- a/src/gui/GraphWindow.hpp
+++ b/src/gui/GraphWindow.hpp
@@ -85,10 +85,10 @@ protected:
bool on_key_press_event(GdkEventKey* event) override;
private:
- GraphBox* _box;
- bool _position_stored;
- int _x;
- int _y;
+ GraphBox* _box{nullptr};
+ bool _position_stored{false};
+ int _x{0};
+ int _y{0};
};
} // namespace gui
diff --git a/src/gui/LoadGraphWindow.cpp b/src/gui/LoadGraphWindow.cpp
index 7a80a2bf..b44a1fe7 100644
--- a/src/gui/LoadGraphWindow.cpp
+++ b/src/gui/LoadGraphWindow.cpp
@@ -251,9 +251,9 @@ LoadGraphWindow::avoid_symbol_clash(const raul::Symbol& symbol)
std::stringstream ss;
ss << symbol << "_" << offset;
return raul::Symbol(ss.str());
- } else {
- return symbol;
}
+
+ return symbol;
}
void
diff --git a/src/gui/LoadGraphWindow.hpp b/src/gui/LoadGraphWindow.hpp
index b2063d75..adb6bce1 100644
--- a/src/gui/LoadGraphWindow.hpp
+++ b/src/gui/LoadGraphWindow.hpp
@@ -40,7 +40,9 @@ class SpinButton;
namespace ingen {
-namespace client { class GraphModel; }
+namespace client {
+class GraphModel;
+} // namespace client
namespace gui {
diff --git a/src/gui/LoadPluginWindow.cpp b/src/gui/LoadPluginWindow.cpp
index 5a9536a2..940f09b1 100644
--- a/src/gui/LoadPluginWindow.cpp
+++ b/src/gui/LoadPluginWindow.cpp
@@ -14,8 +14,9 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "App.hpp"
#include "LoadPluginWindow.hpp"
+
+#include "App.hpp"
#include "Window.hpp"
#include "ingen/Atom.hpp"
@@ -102,8 +103,9 @@ LoadPluginWindow::LoadPluginWindow(BaseObjectType* cobject,
_criteria_liststore = Gtk::ListStore::create(_criteria_columns);
_filter_combo->set_model(_criteria_liststore);
- Gtk::TreeModel::iterator iter = _criteria_liststore->append();
- Gtk::TreeModel::Row row = *iter;
+ auto iter = _criteria_liststore->append();
+ auto row = *iter;
+
row[_criteria_columns._col_label] = "Name contains";
row[_criteria_columns._col_criteria] = CriteriaColumns::Criteria::NAME;
_filter_combo->set_active(iter);
@@ -326,8 +328,8 @@ LoadPluginWindow::add_plugin(const std::shared_ptr<const PluginModel>& plugin)
return;
}
- Gtk::TreeModel::iterator iter = _plugins_liststore->append();
- Gtk::TreeModel::Row row = *iter;
+ auto iter = _plugins_liststore->append();
+ auto row = *iter;
_rows.emplace(plugin->uri(), iter);
set_row(row, plugin);
@@ -355,13 +357,16 @@ LoadPluginWindow::plugin_selection_changed()
_name_entry->set_text("");
_name_entry->set_sensitive(false);
} else if (n_selected == 1) {
- Gtk::TreeModel::iterator iter = _plugins_liststore->get_iter(
- *_selection->get_selected_rows().begin());
+ auto iter = _plugins_liststore->get_iter(
+ *_selection->get_selected_rows().begin());
if (iter) {
- Gtk::TreeModel::Row row = *iter;
- auto p = row.get_value(_plugins_columns._col_plugin);
- _name_offset = _app->store()->child_name_offset(
- _graph->path(), p->default_block_symbol());
+ auto row = *iter;
+ auto p = row.get_value(_plugins_columns._col_plugin);
+
+ _name_offset =
+ _app->store()->child_name_offset(_graph->path(),
+ p->default_block_symbol());
+
_name_entry->set_text(generate_module_name(p, _name_offset));
_name_entry->set_sensitive(true);
} else {
@@ -397,11 +402,11 @@ LoadPluginWindow::generate_module_name(
void
LoadPluginWindow::load_plugin(const Gtk::TreeModel::iterator& iter)
{
- const URIs& uris = _app->uris();
- Gtk::TreeModel::Row row = *iter;
- auto plugin = row.get_value(_plugins_columns._col_plugin);
- bool polyphonic = _polyphonic_checkbutton->get_active();
- string name = _name_entry->get_text();
+ const URIs& uris = _app->uris();
+ auto row = *iter;
+ auto plugin = row.get_value(_plugins_columns._col_plugin);
+ bool polyphonic = _polyphonic_checkbutton->get_active();
+ string name = _name_entry->get_text();
if (name.empty()) {
name = generate_module_name(plugin, _name_offset);
@@ -451,7 +456,7 @@ LoadPluginWindow::filter_changed()
transform(search.begin(), search.end(), search.begin(), ::toupper);
// Get selected criteria
- const Gtk::TreeModel::Row row = *(_filter_combo->get_active());
+ const auto row = *(_filter_combo->get_active());
CriteriaColumns::Criteria criteria = row[_criteria_columns._col_criteria];
string field;
@@ -511,9 +516,9 @@ LoadPluginWindow::on_key_press_event(GdkEventKey* event)
if (event->keyval == GDK_w && event->state & GDK_CONTROL_MASK) {
hide();
return true;
- } else {
- return Gtk::Window::on_key_press_event(event);
}
+
+ return Gtk::Window::on_key_press_event(event);
}
void
@@ -523,7 +528,7 @@ LoadPluginWindow::plugin_property_changed(const URI& plugin,
{
const URIs& uris = _app->uris();
if (predicate == uris.doap_name) {
- Rows::const_iterator i = _rows.find(plugin);
+ const auto i = _rows.find(plugin);
if (i != _rows.end() && value.type() == uris.forge.String) {
(*i->second)[_plugins_columns._col_name] = value.ptr<char>();
}
diff --git a/src/gui/LoadPluginWindow.hpp b/src/gui/LoadPluginWindow.hpp
index 46c5e816..7a9313e2 100644
--- a/src/gui/LoadPluginWindow.hpp
+++ b/src/gui/LoadPluginWindow.hpp
@@ -88,7 +88,8 @@ protected:
private:
/** Columns for the plugin list */
- class ModelColumns : public Gtk::TreeModel::ColumnRecord {
+ class ModelColumns : public Gtk::TreeModel::ColumnRecord
+ {
public:
ModelColumns() {
add(_col_name);
@@ -110,7 +111,8 @@ private:
};
/** Column for the filter criteria combo box. */
- class CriteriaColumns : public Gtk::TreeModel::ColumnRecord {
+ class CriteriaColumns : public Gtk::TreeModel::ColumnRecord
+ {
public:
enum class Criteria { NAME, TYPE, PROJECT, AUTHOR, URI, };
diff --git a/src/gui/MessagesWindow.cpp b/src/gui/MessagesWindow.cpp
index 2e0fdb61..9127ad61 100644
--- a/src/gui/MessagesWindow.cpp
+++ b/src/gui/MessagesWindow.cpp
@@ -18,6 +18,7 @@
#include "App.hpp"
#include "Window.hpp"
+#include "ingen_config.h"
#include "ingen/URIs.hpp"
#include "lv2/urid/urid.h"
@@ -102,7 +103,7 @@ MessagesWindow::log(LV2_URID type, const char* fmt, va_list args)
{
std::lock_guard<std::mutex> lock(_mutex);
-#ifdef HAVE_VASPRINTF
+#if USE_VASPRINTF
char* buf = nullptr;
const int len = vasprintf(&buf, fmt, args);
#else
diff --git a/src/gui/MessagesWindow.hpp b/src/gui/MessagesWindow.hpp
index ab82193d..45301889 100644
--- a/src/gui/MessagesWindow.hpp
+++ b/src/gui/MessagesWindow.hpp
@@ -67,9 +67,9 @@ private:
std::mutex _mutex;
std::stringstream _stream;
- Gtk::TextView* _textview;
- Gtk::Button* _clear_button;
- Gtk::Button* _close_button;
+ Gtk::TextView* _textview{nullptr};
+ Gtk::Button* _clear_button{nullptr};
+ Gtk::Button* _close_button{nullptr};
Glib::RefPtr<Gtk::TextTag> _error_tag;
std::map< LV2_URID, Glib::RefPtr<Gtk::TextTag> > _tags;
diff --git a/src/gui/NewSubgraphWindow.hpp b/src/gui/NewSubgraphWindow.hpp
index 9897e6c2..be660da5 100644
--- a/src/gui/NewSubgraphWindow.hpp
+++ b/src/gui/NewSubgraphWindow.hpp
@@ -39,7 +39,9 @@ class SpinButton;
namespace ingen {
-namespace client { class GraphModel; }
+namespace client {
+class GraphModel;
+} // namespace client
namespace gui {
@@ -68,11 +70,11 @@ private:
Properties _initial_data;
std::shared_ptr<const client::GraphModel> _graph;
- Gtk::Entry* _name_entry;
- Gtk::Label* _message_label;
- Gtk::SpinButton* _poly_spinbutton;
- Gtk::Button* _ok_button;
- Gtk::Button* _cancel_button;
+ Gtk::Entry* _name_entry{nullptr};
+ Gtk::Label* _message_label{nullptr};
+ Gtk::SpinButton* _poly_spinbutton{nullptr};
+ Gtk::Button* _ok_button{nullptr};
+ Gtk::Button* _cancel_button{nullptr};
};
} // namespace gui
diff --git a/src/gui/NodeMenu.cpp b/src/gui/NodeMenu.cpp
index 517d0018..faddaae7 100644
--- a/src/gui/NodeMenu.cpp
+++ b/src/gui/NodeMenu.cpp
@@ -68,7 +68,6 @@ namespace gui {
NodeMenu::NodeMenu(BaseObjectType* cobject,
const Glib::RefPtr<Gtk::Builder>& xml)
: ObjectMenu(cobject, xml)
- , _presets_menu(nullptr)
{
xml->get_widget("node_popup_gui_menuitem", _popup_gui_menuitem);
xml->get_widget("node_embed_gui_menuitem", _embed_gui_menuitem);
diff --git a/src/gui/NodeMenu.hpp b/src/gui/NodeMenu.hpp
index 8a1e5f06..f109c3e4 100644
--- a/src/gui/NodeMenu.hpp
+++ b/src/gui/NodeMenu.hpp
@@ -79,11 +79,11 @@ protected:
void on_save_preset_activated();
void on_preset_activated(const std::string& uri);
- Gtk::MenuItem* _popup_gui_menuitem;
- Gtk::CheckMenuItem* _embed_gui_menuitem;
- Gtk::CheckMenuItem* _enabled_menuitem;
- Gtk::MenuItem* _randomize_menuitem;
- Gtk::Menu* _presets_menu;
+ Gtk::MenuItem* _popup_gui_menuitem{nullptr};
+ Gtk::CheckMenuItem* _embed_gui_menuitem{nullptr};
+ Gtk::CheckMenuItem* _enabled_menuitem{nullptr};
+ Gtk::MenuItem* _randomize_menuitem{nullptr};
+ Gtk::Menu* _presets_menu{nullptr};
sigc::connection _preset_connection;
};
diff --git a/src/gui/NodeModule.cpp b/src/gui/NodeModule.cpp
index fe111572..1b090c4f 100644
--- a/src/gui/NodeModule.cpp
+++ b/src/gui/NodeModule.cpp
@@ -25,6 +25,7 @@
#include "SubgraphModule.hpp"
#include "WidgetFactory.hpp"
#include "WindowFactory.hpp"
+#include "ingen_config.h"
#include "ganv/Port.hpp"
#include "ingen/Atom.hpp"
@@ -77,9 +78,6 @@ NodeModule::NodeModule(GraphCanvas& canvas,
const std::shared_ptr<const BlockModel>& block)
: Ganv::Module(canvas, block->path().symbol(), 0, 0, true)
, _block(block)
- , _gui_widget(nullptr)
- , _gui_window(nullptr)
- , _initialised(false)
{
block->signal_new_port().connect(
sigc::mem_fun(this, &NodeModule::new_port_view));
@@ -129,7 +127,7 @@ bool
NodeModule::idle_init()
{
if (_block->ports().empty()) {
- return true; // Need to embed GUI, but ports haven't shown up yet
+ return true; // Need to embed GUI, but ports haven't shown up yet
}
// Ports have arrived, embed GUI and deregister this callback
@@ -410,9 +408,9 @@ NodeModule::popup_gui()
_gui_window->present();
return true;
- } else {
- app().log().warn("No LV2 GUI for %1%\n", _block->path());
}
+
+ app().log().warn("No LV2 GUI for %1%\n", _block->path());
}
return false;
@@ -451,9 +449,13 @@ NodeModule::on_event(GdkEvent* ev)
{
if (ev->type == GDK_BUTTON_PRESS && ev->button.button == 3) {
return show_menu(&ev->button);
- } else if (ev->type == GDK_2BUTTON_PRESS) {
+ }
+
+ if (ev->type == GDK_2BUTTON_PRESS) {
return on_double_click(&ev->button);
- } else if (ev->type == GDK_ENTER_NOTIFY) {
+ }
+
+ if (ev->type == GDK_ENTER_NOTIFY) {
GraphBox* const box = app().window_factory()->graph_box(
std::dynamic_pointer_cast<const GraphModel>(_block->parent()));
if (box) {
@@ -531,7 +533,7 @@ NodeModule::on_selected(gboolean selected)
if (selected && win->documentation_is_visible()) {
std::string doc;
bool html = false;
-#ifdef HAVE_WEBKIT
+#if USE_WEBKIT
html = true;
#endif
if (block()->plugin_model()) {
diff --git a/src/gui/NodeModule.hpp b/src/gui/NodeModule.hpp
index 1ca7955c..f94a10e9 100644
--- a/src/gui/NodeModule.hpp
+++ b/src/gui/NodeModule.hpp
@@ -106,11 +106,11 @@ protected:
bool show_menu(GdkEventButton* ev);
std::shared_ptr<const client::BlockModel> _block;
- NodeMenu* _menu;
+ NodeMenu* _menu{nullptr};
std::shared_ptr<client::PluginUI> _plugin_ui;
- Gtk::Widget* _gui_widget;
- Gtk::Window* _gui_window; ///< iff popped up
- bool _initialised;
+ Gtk::Widget* _gui_widget{nullptr};
+ Gtk::Window* _gui_window{nullptr}; ///< iff popped up
+ bool _initialised{false};
};
} // namespace gui
diff --git a/src/gui/ObjectMenu.cpp b/src/gui/ObjectMenu.cpp
index 5f78144f..87f6f9e9 100644
--- a/src/gui/ObjectMenu.cpp
+++ b/src/gui/ObjectMenu.cpp
@@ -45,13 +45,6 @@ namespace gui {
ObjectMenu::ObjectMenu(BaseObjectType* cobject,
const Glib::RefPtr<Gtk::Builder>& xml)
: Gtk::Menu(cobject)
- , _app(nullptr)
- , _polyphonic_menuitem(nullptr)
- , _disconnect_menuitem(nullptr)
- , _rename_menuitem(nullptr)
- , _destroy_menuitem(nullptr)
- , _properties_menuitem(nullptr)
- , _enable_signal(false)
{
xml->get_widget("object_learn_menuitem", _learn_menuitem);
xml->get_widget("object_unlearn_menuitem", _unlearn_menuitem);
diff --git a/src/gui/ObjectMenu.hpp b/src/gui/ObjectMenu.hpp
index 214c8307..de105364 100644
--- a/src/gui/ObjectMenu.hpp
+++ b/src/gui/ObjectMenu.hpp
@@ -76,18 +76,18 @@ protected:
void property_changed(const URI& predicate, const Atom& value);
- App* _app;
+ App* _app{nullptr};
std::shared_ptr<const client::ObjectModel> _object;
- Gtk::MenuItem* _learn_menuitem;
- Gtk::MenuItem* _unlearn_menuitem;
- Gtk::CheckMenuItem* _polyphonic_menuitem;
- Gtk::MenuItem* _disconnect_menuitem;
- Gtk::MenuItem* _rename_menuitem;
- Gtk::MenuItem* _destroy_menuitem;
- Gtk::MenuItem* _properties_menuitem;
- Gtk::SeparatorMenuItem* _separator_menuitem;
-
- bool _enable_signal;
+ Gtk::MenuItem* _learn_menuitem{nullptr};
+ Gtk::MenuItem* _unlearn_menuitem{nullptr};
+ Gtk::CheckMenuItem* _polyphonic_menuitem{nullptr};
+ Gtk::MenuItem* _disconnect_menuitem{nullptr};
+ Gtk::MenuItem* _rename_menuitem{nullptr};
+ Gtk::MenuItem* _destroy_menuitem{nullptr};
+ Gtk::MenuItem* _properties_menuitem{nullptr};
+ Gtk::SeparatorMenuItem* _separator_menuitem{nullptr};
+
+ bool _enable_signal{false};
};
} // namespace gui
diff --git a/src/gui/PluginMenu.cpp b/src/gui/PluginMenu.cpp
index 7ddfd075..1993a7a7 100644
--- a/src/gui/PluginMenu.cpp
+++ b/src/gui/PluginMenu.cpp
@@ -56,7 +56,7 @@ PluginMenu::clear()
// Build skeleton
LV2Children children;
- LILV_FOREACH(plugin_classes, i, classes) {
+ LILV_FOREACH (plugin_classes, i, classes) {
const LilvPluginClass* c = lilv_plugin_classes_get(classes, i);
const LilvNode* p = lilv_plugin_class_get_parent_uri(c);
if (!p) {
@@ -78,8 +78,6 @@ PluginMenu::clear()
void
PluginMenu::add_plugin(const std::shared_ptr<client::PluginModel>& p)
{
- using iterator = ClassMenus::iterator;
-
if (!p->lilv_plugin() || lilv_plugin_is_replaced(p->lilv_plugin())) {
return;
}
@@ -88,7 +86,7 @@ PluginMenu::add_plugin(const std::shared_ptr<client::PluginModel>& p)
const LilvNode* class_uri = lilv_plugin_class_get_uri(pc);
const char* class_uri_str = lilv_node_as_string(class_uri);
- std::pair<iterator, iterator> range = _class_menus.equal_range(class_uri_str);
+ const auto range = _class_menus.equal_range(class_uri_str);
if (range.first == _class_menus.end() || range.first == range.second
|| range.first->second.menu == this) {
// Add to uncategorized plugin menu
@@ -112,16 +110,14 @@ PluginMenu::build_plugin_class_menu(Gtk::Menu* menu,
const LilvNode* class_uri = lilv_plugin_class_get_uri(plugin_class);
const char* class_uri_str = lilv_node_as_string(class_uri);
- const std::pair<LV2Children::const_iterator, LV2Children::const_iterator> kids
- = children.equal_range(class_uri_str);
-
+ const auto kids = children.equal_range(class_uri_str);
if (kids.first == children.end()) {
return 0;
}
// Add submenus
ancestors.insert(class_uri_str);
- for (LV2Children::const_iterator i = kids.first; i != kids.second; ++i) {
+ for (auto i = kids.first; i != kids.second; ++i) {
const LilvPluginClass* c = i->second;
const char* sub_label_str = lilv_node_as_string(lilv_plugin_class_get_label(c));
const char* sub_uri_str = lilv_node_as_string(lilv_plugin_class_get_uri(c));
diff --git a/src/gui/PluginMenu.hpp b/src/gui/PluginMenu.hpp
index 2cf130bb..b2c75ffe 100644
--- a/src/gui/PluginMenu.hpp
+++ b/src/gui/PluginMenu.hpp
@@ -36,7 +36,9 @@ namespace ingen {
class World;
-namespace client { class PluginModel; }
+namespace client {
+class PluginModel;
+} // namespace client
namespace gui {
@@ -57,7 +59,9 @@ public:
private:
struct MenuRecord {
- MenuRecord(Gtk::MenuItem* i, Gtk::Menu* m) : item(i), menu(m) {}
+ MenuRecord(Gtk::MenuItem* i, Gtk::Menu* m) noexcept : item(i), menu(m)
+ {}
+
Gtk::MenuItem* item;
Gtk::Menu* menu;
};
diff --git a/src/gui/Port.cpp b/src/gui/Port.cpp
index 65b415e3..89b86184 100644
--- a/src/gui/Port.cpp
+++ b/src/gui/Port.cpp
@@ -24,6 +24,7 @@
#include "Style.hpp"
#include "WidgetFactory.hpp"
#include "WindowFactory.hpp"
+#include "ingen_config.h"
#include "rgba.hpp"
#include "ingen/Atom.hpp"
@@ -222,11 +223,11 @@ Port::on_value_changed(double value)
const URIs& uris = _app.uris();
const Atom& current_value = model()->value();
if (current_value.type() != uris.forge.Float) {
- return; // Non-float, unsupported
+ return; // Non-float, unsupported
}
if (current_value.get<float>() == static_cast<float>(value)) {
- return; // No change
+ return; // No change
}
const Atom atom = _app.forge().make(float(value));
@@ -309,7 +310,7 @@ Port::build_uri_menu()
rdfs::URISet ranges;
LilvNodes* range = lilv_world_find_nodes(
world.lilv_world(), designation, rdfs_range, nullptr);
- LILV_FOREACH(nodes, r, range) {
+ LILV_FOREACH (nodes, r, range) {
ranges.insert(URI(lilv_node_as_string(lilv_nodes_get(range, r))));
}
rdfs::classes(world, ranges, false);
@@ -356,7 +357,9 @@ Port::on_event(GdkEvent* ev)
Gtk::Menu* menu = build_enum_menu();
menu->popup(ev->button.button, ev->button.time);
return true;
- } else if (model()->is_uri()) {
+ }
+
+ if (model()->is_uri()) {
Gtk::Menu* menu = build_uri_menu();
if (menu) {
menu->popup(ev->button.button, ev->button.time);
@@ -374,7 +377,7 @@ Port::on_event(GdkEvent* ev)
return false;
}
-inline static uint32_t
+static inline uint32_t
peak_color(float peak)
{
static const uint32_t min = 0x4A8A0EC0;
@@ -384,9 +387,9 @@ peak_color(float peak)
if (peak < 1.0f) {
return rgba_interpolate(min, max, peak);
- } else {
- return rgba_interpolate(peak_min, peak_max, fminf(peak, 2.0f) - 1.0f);
}
+
+ return rgba_interpolate(peak_min, peak_max, fminf(peak, 2.0f) - 1.0f);
}
void
@@ -551,7 +554,7 @@ Port::on_selected(gboolean b)
GraphWindow* win = _app.window_factory()->parent_graph_window(block);
if (win && win->documentation_is_visible() && block->plugin_model()) {
bool html = false;
-#ifdef HAVE_WEBKIT
+#if USE_WEBKIT
html = true;
#endif
const std::string& doc = block->plugin_model()->port_documentation(
diff --git a/src/gui/Port.hpp b/src/gui/Port.hpp
index 534734ad..8e8077bc 100644
--- a/src/gui/Port.hpp
+++ b/src/gui/Port.hpp
@@ -38,7 +38,9 @@ namespace ingen {
class URI;
class Atom;
-namespace client { class PortModel; }
+namespace client {
+class PortModel;
+} // namespace client
namespace gui {
diff --git a/src/gui/PortMenu.cpp b/src/gui/PortMenu.cpp
index 652ac05d..96b0788a 100644
--- a/src/gui/PortMenu.cpp
+++ b/src/gui/PortMenu.cpp
@@ -55,7 +55,6 @@ namespace gui {
PortMenu::PortMenu(BaseObjectType* cobject,
const Glib::RefPtr<Gtk::Builder>& xml)
: ObjectMenu(cobject, xml)
- , _internal_graph_port(false)
{
xml->get_widget("object_menu", _port_menu);
xml->get_widget("port_set_min_menuitem", _set_min_menuitem);
@@ -169,7 +168,7 @@ PortMenu::on_menu_expose()
auto block = std::dynamic_pointer_cast<const BlockModel>(port->parent());
const std::string label = block->label() + " " + block->port_label(port);
- const raul::Path path = raul::Path(block->path() + raul::Symbol("_" + port->symbol()));
+ const auto path = raul::Path{block->path() + raul::Symbol("_" + port->symbol())};
ingen::Resource r(*_object);
r.remove_property(uris.lv2_index, uris.patch_wildcard);
diff --git a/src/gui/PortMenu.hpp b/src/gui/PortMenu.hpp
index 75a25cde..71a5f48b 100644
--- a/src/gui/PortMenu.hpp
+++ b/src/gui/PortMenu.hpp
@@ -63,14 +63,14 @@ private:
void on_menu_reset_range();
void on_menu_expose();
- Gtk::Menu* _port_menu;
- Gtk::MenuItem* _set_min_menuitem;
- Gtk::MenuItem* _set_max_menuitem;
- Gtk::MenuItem* _reset_range_menuitem;
- Gtk::MenuItem* _expose_menuitem;
+ Gtk::Menu* _port_menu{nullptr};
+ Gtk::MenuItem* _set_min_menuitem{nullptr};
+ Gtk::MenuItem* _set_max_menuitem{nullptr};
+ Gtk::MenuItem* _reset_range_menuitem{nullptr};
+ Gtk::MenuItem* _expose_menuitem{nullptr};
/// True iff this is a (flipped) port on a GraphPortModule in its graph
- bool _internal_graph_port;
+ bool _internal_graph_port{false};
};
} // namespace gui
diff --git a/src/gui/PropertiesWindow.cpp b/src/gui/PropertiesWindow.cpp
index afcfa827..4ea1536d 100644
--- a/src/gui/PropertiesWindow.cpp
+++ b/src/gui/PropertiesWindow.cpp
@@ -14,8 +14,9 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "App.hpp"
#include "PropertiesWindow.hpp"
+
+#include "App.hpp"
#include "RDFS.hpp"
#include "URIEntry.hpp"
#include "Window.hpp"
@@ -76,7 +77,6 @@ using URISet = std::set<URI>;
PropertiesWindow::PropertiesWindow(BaseObjectType* cobject,
const Glib::RefPtr<Gtk::Builder>& xml)
: Window(cobject)
- , _value_type(0)
{
xml->get_widget("properties_vbox", _vbox);
xml->get_widget("properties_scrolledwindow", _scrolledwindow);
@@ -185,16 +185,24 @@ PropertiesWindow::datatype_supported(const rdfs::URISet& types,
if (types.find(_app->uris().atom_Int) != types.end()) {
*widget_type = _app->uris().atom_Int;
return true;
- } else if (types.find(_app->uris().atom_Float) != types.end()) {
+ }
+
+ if (types.find(_app->uris().atom_Float) != types.end()) {
*widget_type = _app->uris().atom_Float;
return true;
- } else if (types.find(_app->uris().atom_Bool) != types.end()) {
+ }
+
+ if (types.find(_app->uris().atom_Bool) != types.end()) {
*widget_type = _app->uris().atom_Bool;
return true;
- } else if (types.find(_app->uris().atom_String) != types.end()) {
+ }
+
+ if (types.find(_app->uris().atom_String) != types.end()) {
*widget_type = _app->uris().atom_String;
return true;
- } else if (types.find(_app->uris().atom_URID) != types.end()) {
+ }
+
+ if (types.find(_app->uris().atom_URID) != types.end()) {
*widget_type = _app->uris().atom_URID;
return true;
}
@@ -276,8 +284,9 @@ PropertiesWindow::set_object(const std::shared_ptr<const ObjectModel>& model)
}
for (const auto& e : entries) {
- Gtk::ListStore::iterator ki = _key_store->append();
- Gtk::ListStore::Row row = *ki;
+ auto ki = _key_store->append();
+ auto row = *ki;
+
row[_combo_columns.uri_col] = e.second.string();
row[_combo_columns.label_col] = e.first;
}
@@ -332,7 +341,9 @@ PropertiesWindow::create_value_widget(const URI& key,
widget->signal_value_changed().connect(
sigc::bind(sigc::mem_fun(this, &PropertiesWindow::on_change), key));
return widget;
- } else if (type == _app->uris().atom_Float) {
+ }
+
+ if (type == _app->uris().atom_Float) {
Gtk::SpinButton* widget = manage(new Gtk::SpinButton(0.0, 4));
widget->property_numeric() = true;
widget->set_snap_to_ticks(false);
@@ -344,7 +355,9 @@ PropertiesWindow::create_value_widget(const URI& key,
widget->signal_value_changed().connect(
sigc::bind(sigc::mem_fun(this, &PropertiesWindow::on_change), key));
return widget;
- } else if (type == _app->uris().atom_Bool) {
+ }
+
+ if (type == _app->uris().atom_Bool) {
Gtk::CheckButton* widget = manage(new Gtk::CheckButton());
if (value.is_valid()) {
widget->set_active(value.get<int32_t>());
@@ -352,7 +365,9 @@ PropertiesWindow::create_value_widget(const URI& key,
widget->signal_toggled().connect(
sigc::bind(sigc::mem_fun(this, &PropertiesWindow::on_change), key));
return widget;
- } else if (type == _app->uris().atom_String) {
+ }
+
+ if (type == _app->uris().atom_String) {
Gtk::Entry* widget = manage(new Gtk::Entry());
if (value.is_valid()) {
widget->set_text(value.ptr<char>());
@@ -360,7 +375,9 @@ PropertiesWindow::create_value_widget(const URI& key,
widget->signal_changed().connect(
sigc::bind(sigc::mem_fun(this, &PropertiesWindow::on_change), key));
return widget;
- } else if (type == _app->uris().atom_URID) {
+ }
+
+ if (type == _app->uris().atom_URID) {
const char* str = (value.is_valid()
? world.uri_map().unmap_uri(value.get<int32_t>())
: "");
@@ -486,9 +503,8 @@ PropertiesWindow::get_value(LV2_URID type, Gtk::Widget* value_widget)
auto* uri_entry = dynamic_cast<URIEntry*>(value_widget);
if (uri_entry && URI::is_valid(uri_entry->get_text())) {
return _app->forge().make_urid(URI(uri_entry->get_text()));
- } else {
- _app->log().error("Invalid URI <%1%>\n", uri_entry->get_text());
}
+ _app->log().error("Invalid URI <%1%>\n", uri_entry->get_text());
} else if (type == forge.String) {
auto* entry = dynamic_cast<Gtk::Entry*>(value_widget);
if (entry) {
@@ -496,7 +512,7 @@ PropertiesWindow::get_value(LV2_URID type, Gtk::Widget* value_widget)
}
}
- return Atom();
+ return {};
}
void
@@ -521,7 +537,7 @@ PropertiesWindow::on_change(const URI& key)
std::string
PropertiesWindow::active_key() const
{
- const Gtk::ListStore::iterator iter = _key_combo->get_active();
+ const auto iter = _key_combo->get_active();
if (!iter) {
return "";
}
diff --git a/src/gui/PropertiesWindow.hpp b/src/gui/PropertiesWindow.hpp
index 780c2ba1..60b6bda3 100644
--- a/src/gui/PropertiesWindow.hpp
+++ b/src/gui/PropertiesWindow.hpp
@@ -54,7 +54,9 @@ class Widget;
namespace ingen {
-namespace client { class ObjectModel; }
+namespace client {
+class ObjectModel;
+} // namespace client
namespace gui {
@@ -129,16 +131,16 @@ private:
Glib::RefPtr<Gtk::ListStore> _key_store;
sigc::connection _property_connection;
sigc::connection _property_removed_connection;
- Gtk::VBox* _vbox;
- Gtk::ScrolledWindow* _scrolledwindow;
- Gtk::Table* _table;
- Gtk::ComboBox* _key_combo;
- LV2_URID _value_type;
- Gtk::Bin* _value_bin;
- Gtk::Button* _add_button;
- Gtk::Button* _cancel_button;
- Gtk::Button* _apply_button;
- Gtk::Button* _ok_button;
+ Gtk::VBox* _vbox{nullptr};
+ Gtk::ScrolledWindow* _scrolledwindow{nullptr};
+ Gtk::Table* _table{nullptr};
+ Gtk::ComboBox* _key_combo{nullptr};
+ LV2_URID _value_type{0};
+ Gtk::Bin* _value_bin{nullptr};
+ Gtk::Button* _add_button{nullptr};
+ Gtk::Button* _cancel_button{nullptr};
+ Gtk::Button* _apply_button{nullptr};
+ Gtk::Button* _ok_button{nullptr};
};
} // namespace gui
diff --git a/src/gui/RDFS.cpp b/src/gui/RDFS.cpp
index ed8d7e8c..3a277950 100644
--- a/src/gui/RDFS.cpp
+++ b/src/gui/RDFS.cpp
@@ -76,7 +76,7 @@ closure(World& world, const LilvNode* pred, URISet& types, bool super)
world.lilv_world(), type, pred, nullptr)
: lilv_world_find_nodes(
world.lilv_world(), nullptr, pred, type);
- LILV_FOREACH(nodes, m, matches) {
+ LILV_FOREACH (nodes, m, matches) {
const LilvNode* klass_node = lilv_nodes_get(matches, m);
if (lilv_node_is_uri(klass_node)) {
URI klass(lilv_node_as_uri(klass_node));
@@ -118,20 +118,17 @@ datatypes(World& world, URISet& types, bool super)
URISet
types(World& world, const std::shared_ptr<const client::ObjectModel>& model)
{
- using PropIter = Properties::const_iterator;
- using PropRange = std::pair<PropIter, PropIter>;
-
// Start with every rdf:type
URISet types;
types.insert(URI(LILV_NS_RDFS "Resource"));
- PropRange range = model->properties().equal_range(world.uris().rdf_type);
+ const auto range = model->properties().equal_range(world.uris().rdf_type);
for (auto t = range.first; t != range.second; ++t) {
if (t->second.type() == world.forge().URI ||
t->second.type() == world.forge().URID) {
const URI type(world.forge().str(t->second, false));
types.insert(type);
if (world.uris().ingen_Graph == type) {
- // Add lv2:Plugin as a type for graphs so plugin properties show up
+ // Add lv2:Plugin as a type so plugin properties show up
types.insert(world.uris().lv2_Plugin);
}
} else {
@@ -161,13 +158,13 @@ properties(World& world,
LilvNodes* props = lilv_world_find_nodes(
world.lilv_world(), nullptr, rdf_type, rdf_Property);
- LILV_FOREACH(nodes, p, props) {
+ LILV_FOREACH (nodes, p, props) {
const LilvNode* prop = lilv_nodes_get(props, p);
if (lilv_node_is_uri(prop)) {
LilvNodes* domains = lilv_world_find_nodes(
world.lilv_world(), prop, rdfs_domain, nullptr);
unsigned n_matching_domains = 0;
- LILV_FOREACH(nodes, d, domains) {
+ LILV_FOREACH (nodes, d, domains) {
const LilvNode* domain_node = lilv_nodes_get(domains, d);
if (!lilv_node_is_uri(domain_node)) {
// TODO: Blank node domains (e.g. unions)
@@ -208,7 +205,7 @@ instances(World& world, const URISet& types)
LilvNode* type = lilv_new_uri(world.lilv_world(), t.c_str());
LilvNodes* objects = lilv_world_find_nodes(
world.lilv_world(), nullptr, rdf_type, type);
- LILV_FOREACH(nodes, o, objects) {
+ LILV_FOREACH (nodes, o, objects) {
const LilvNode* object = lilv_nodes_get(objects, o);
if (!lilv_node_is_uri(object)) {
continue;
@@ -233,7 +230,7 @@ range(World& world, const LilvNode* prop, bool recursive)
world.lilv_world(), prop, rdfs_range, nullptr);
URISet ranges;
- LILV_FOREACH(nodes, n, nodes) {
+ LILV_FOREACH (nodes, n, nodes) {
if (lilv_node_is_uri(lilv_nodes_get(nodes, n))) {
ranges.insert(URI(lilv_node_as_string(lilv_nodes_get(nodes, n))));
}
diff --git a/src/gui/RDFS.hpp b/src/gui/RDFS.hpp
index 4fac5546..9a212dff 100644
--- a/src/gui/RDFS.hpp
+++ b/src/gui/RDFS.hpp
@@ -29,7 +29,9 @@ namespace ingen {
class World;
-namespace client { class ObjectModel; }
+namespace client {
+class ObjectModel;
+} // namespace client
namespace gui {
diff --git a/src/gui/RenameWindow.hpp b/src/gui/RenameWindow.hpp
index 004ca784..42db3ff6 100644
--- a/src/gui/RenameWindow.hpp
+++ b/src/gui/RenameWindow.hpp
@@ -63,11 +63,11 @@ private:
std::shared_ptr<const client::ObjectModel> _object;
- Gtk::Entry* _symbol_entry;
- Gtk::Entry* _label_entry;
- Gtk::Label* _message_label;
- Gtk::Button* _cancel_button;
- Gtk::Button* _ok_button;
+ Gtk::Entry* _symbol_entry{nullptr};
+ Gtk::Entry* _label_entry{nullptr};
+ Gtk::Label* _message_label{nullptr};
+ Gtk::Button* _cancel_button{nullptr};
+ Gtk::Button* _ok_button{nullptr};
};
} // namespace gui
diff --git a/src/gui/Style.cpp b/src/gui/Style.cpp
index 5be83688..bce98648 100644
--- a/src/gui/Style.cpp
+++ b/src/gui/Style.cpp
@@ -27,22 +27,15 @@ namespace ingen {
namespace gui {
Style::Style(App& app)
- // Colours from the Tango palette with modified V
- : _app(app)
+ : _app(app)
+{
#ifdef INGEN_USE_LIGHT_THEME
- , _audio_port_color(0xC8E6ABFF) // Green
- , _control_port_color(0xAAC0E6FF) // Blue
- , _cv_port_color(0xACE6E0FF) // Teal (between audio and control)
- , _event_port_color(0xE6ABABFF) // Red
- , _string_port_color(0xD8ABE6FF) // Plum
-#else
- , _audio_port_color(0x4A8A0EFF) // Green
- , _control_port_color(0x244678FF) // Blue
- , _cv_port_color(0x248780FF) // Teal (between audio and control)
- , _event_port_color(0x960909FF) // Red
- , _string_port_color(0x5C3566FF) // Plum
+ _audio_port_color = 0xC8E6ABFF;
+ _control_port_color = 0xAAC0E6FF;
+ _cv_port_color = 0xACE6E0FF;
+ _event_port_color = 0xE6ABABFF;
+ _string_port_color = 0xD8ABE6FF;
#endif
-{
}
/** Loads settings from the rc file. Passing no parameter will load from
@@ -76,17 +69,28 @@ uint32_t
Style::get_port_color(const client::PortModel* p)
{
const URIs& uris = _app.uris();
+
if (p->is_a(uris.lv2_AudioPort)) {
return _audio_port_color;
- } else if (p->is_a(uris.lv2_ControlPort)) {
+ }
+
+ if (p->is_a(uris.lv2_ControlPort)) {
return _control_port_color;
- } else if (p->is_a(uris.lv2_CVPort)) {
+ }
+
+ if (p->is_a(uris.lv2_CVPort)) {
return _cv_port_color;
- } else if (p->supports(uris.atom_String)) {
+ }
+
+ if (p->supports(uris.atom_String)) {
return _string_port_color;
- } else if (_app.can_control(p)) {
+ }
+
+ if (_app.can_control(p)) {
return _control_port_color;
- } else if (p->is_a(uris.atom_AtomPort)) {
+ }
+
+ if (p->is_a(uris.atom_AtomPort)) {
return _event_port_color;
}
diff --git a/src/gui/Style.hpp b/src/gui/Style.hpp
index bc94d64a..20d560a8 100644
--- a/src/gui/Style.hpp
+++ b/src/gui/Style.hpp
@@ -45,11 +45,12 @@ public:
private:
App& _app;
- uint32_t _audio_port_color;
- uint32_t _control_port_color;
- uint32_t _cv_port_color;
- uint32_t _event_port_color;
- uint32_t _string_port_color;
+ // Colours from the Tango palette with modified V
+ uint32_t _audio_port_color{0x4A8A0EFF}; // Green
+ uint32_t _control_port_color{0x244678FF}; // Blue
+ uint32_t _cv_port_color{0x248780FF}; // Teal {between audio/control}
+ uint32_t _event_port_color{0x960909FF}; // Red
+ uint32_t _string_port_color{0x5C3566FF}; // Plum
};
} // namespace gui
diff --git a/src/gui/ThreadedLoader.cpp b/src/gui/ThreadedLoader.cpp
index 663529da..7c5fdd99 100644
--- a/src/gui/ThreadedLoader.cpp
+++ b/src/gui/ThreadedLoader.cpp
@@ -49,9 +49,7 @@ namespace gui {
ThreadedLoader::ThreadedLoader(App& app, std::shared_ptr<Interface> engine)
: _app(app)
- , _sem(0)
, _engine(std::move(engine))
- , _exit_flag(false)
, _thread(&ThreadedLoader::run, this)
{
if (!parser()) {
diff --git a/src/gui/ThreadedLoader.hpp b/src/gui/ThreadedLoader.hpp
index 5e9392bc..d338b63f 100644
--- a/src/gui/ThreadedLoader.hpp
+++ b/src/gui/ThreadedLoader.hpp
@@ -43,7 +43,9 @@ class Parser;
class Properties;
class URI;
-namespace client { class GraphModel; }
+namespace client {
+class GraphModel;
+} // namespace client
namespace gui {
@@ -95,11 +97,11 @@ private:
void run();
App& _app;
- raul::Semaphore _sem;
+ raul::Semaphore _sem{0};
std::shared_ptr<Interface> _engine;
std::mutex _mutex;
std::list<Closure> _events;
- bool _exit_flag;
+ bool _exit_flag{false};
std::thread _thread;
};
diff --git a/src/gui/URIEntry.cpp b/src/gui/URIEntry.cpp
index 036e7a0b..4ae8da10 100644
--- a/src/gui/URIEntry.cpp
+++ b/src/gui/URIEntry.cpp
@@ -131,11 +131,11 @@ URIEntry::build_subclass_menu(const LilvNode* klass)
// Put subclasses/types in a map keyed by label (to sort menu)
std::map<std::string, const LilvNode*> entries;
- LILV_FOREACH(nodes, s, subclasses) {
+ LILV_FOREACH (nodes, s, subclasses) {
const LilvNode* node = lilv_nodes_get(subclasses, s);
entries.emplace(rdfs::label(world, node), node);
}
- LILV_FOREACH(nodes, s, subtypes) {
+ LILV_FOREACH (nodes, s, subtypes) {
const LilvNode* node = lilv_nodes_get(subtypes, s);
entries.emplace(rdfs::label(world, node), node);
}
diff --git a/src/gui/URIEntry.hpp b/src/gui/URIEntry.hpp
index cc8f96a3..04dfaa41 100644
--- a/src/gui/URIEntry.hpp
+++ b/src/gui/URIEntry.hpp
@@ -39,7 +39,8 @@ namespace gui {
class App;
-class URIEntry : public Gtk::HBox {
+class URIEntry : public Gtk::HBox
+{
public:
/** Create a widget for entering URIs.
*
diff --git a/src/gui/WidgetFactory.cpp b/src/gui/WidgetFactory.cpp
index 2bd7b5fd..d70a5084 100644
--- a/src/gui/WidgetFactory.cpp
+++ b/src/gui/WidgetFactory.cpp
@@ -29,7 +29,7 @@ namespace gui {
Glib::ustring WidgetFactory::ui_filename = "";
-inline static bool
+static inline bool
is_readable(const std::string& filename)
{
std::ifstream fs(filename.c_str());
@@ -72,9 +72,9 @@ WidgetFactory::create(const std::string& toplevel_widget)
if (toplevel_widget.empty()) {
return Gtk::Builder::create_from_file(ui_filename);
- } else {
- return Gtk::Builder::create_from_file(ui_filename, toplevel_widget.c_str());
}
+
+ return Gtk::Builder::create_from_file(ui_filename, toplevel_widget.c_str());
}
} // namespace gui
diff --git a/src/gui/WidgetFactory.hpp b/src/gui/WidgetFactory.hpp
index 11ef71d1..d2f449ee 100644
--- a/src/gui/WidgetFactory.hpp
+++ b/src/gui/WidgetFactory.hpp
@@ -31,7 +31,8 @@ namespace gui {
*
* \ingroup GUI
*/
-class WidgetFactory {
+class WidgetFactory
+{
public:
static Glib::RefPtr<Gtk::Builder>
create(const std::string& toplevel_widget="");
diff --git a/src/gui/Window.hpp b/src/gui/Window.hpp
index acf75942..fa2016a8 100644
--- a/src/gui/Window.hpp
+++ b/src/gui/Window.hpp
@@ -38,8 +38,7 @@ public:
explicit Window(BaseObjectType* cobject)
: Gtk::Window(cobject)
- {
- }
+ {}
virtual void init_window(App& app) { _app = &app; }
@@ -66,8 +65,7 @@ public:
explicit Dialog(BaseObjectType* cobject)
: Gtk::Dialog(cobject)
- {
- }
+ {}
virtual void init_dialog(App& app) { _app = &app; }
diff --git a/src/gui/WindowFactory.cpp b/src/gui/WindowFactory.cpp
index 4e48f157..8928b664 100644
--- a/src/gui/WindowFactory.cpp
+++ b/src/gui/WindowFactory.cpp
@@ -14,9 +14,10 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "WindowFactory.hpp"
+
#include "App.hpp"
#include "GraphBox.hpp"
-#include "GraphView.hpp"
#include "GraphWindow.hpp"
#include "LoadGraphWindow.hpp"
#include "LoadPluginWindow.hpp"
@@ -24,7 +25,6 @@
#include "PropertiesWindow.hpp"
#include "RenameWindow.hpp"
#include "WidgetFactory.hpp"
-#include "WindowFactory.hpp"
#include "ingen/Log.hpp"
#include "ingen/client/BlockModel.hpp"
@@ -52,11 +52,6 @@ namespace gui {
WindowFactory::WindowFactory(App& app)
: _app(app)
- , _main_box(nullptr)
- , _load_plugin_win(nullptr)
- , _load_graph_win(nullptr)
- , _new_subgraph_win(nullptr)
- , _properties_win(nullptr)
{
WidgetFactory::get_widget_derived("load_plugin_win", _load_plugin_win);
WidgetFactory::get_widget_derived("load_graph_win", _load_graph_win);
@@ -114,9 +109,9 @@ WindowFactory::graph_box(const std::shared_ptr<const GraphModel>& graph)
GraphWindow* window = graph_window(graph);
if (window) {
return window->box();
- } else {
- return _main_box;
}
+
+ return _main_box;
}
GraphWindow*
@@ -153,8 +148,6 @@ WindowFactory::present_graph(const std::shared_ptr<const GraphModel>& graph,
GraphWindow* preferred,
const std::shared_ptr<GraphView>& view)
{
- assert(!view || view->graph() == graph);
-
auto w = _graph_windows.find(graph->path());
if (w != _graph_windows.end()) {
@@ -178,8 +171,6 @@ GraphWindow*
WindowFactory::new_graph_window(const std::shared_ptr<const GraphModel>& graph,
const std::shared_ptr<GraphView>& view)
{
- assert(!view || view->graph() == graph);
-
GraphWindow* win = nullptr;
WidgetFactory::get_widget_derived("graph_win", win);
if (!win) {
diff --git a/src/gui/WindowFactory.hpp b/src/gui/WindowFactory.hpp
index 581e2e0f..4ef79239 100644
--- a/src/gui/WindowFactory.hpp
+++ b/src/gui/WindowFactory.hpp
@@ -25,6 +25,7 @@
#include <cstddef>
#include <map>
#include <memory>
+#include <string>
namespace ingen {
@@ -52,7 +53,8 @@ class RenameWindow;
* as well as an enumeration of all windows (the goal being to reduce that
* number as much as possible).
*/
-class WindowFactory {
+class WindowFactory
+{
public:
explicit WindowFactory(App& app);
~WindowFactory();
@@ -106,13 +108,13 @@ private:
const std::shared_ptr<GraphView>& view);
App& _app;
- GraphBox* _main_box;
+ GraphBox* _main_box{nullptr};
GraphWindowMap _graph_windows;
- LoadPluginWindow* _load_plugin_win;
- LoadGraphWindow* _load_graph_win;
- NewSubgraphWindow* _new_subgraph_win;
- PropertiesWindow* _properties_win;
- RenameWindow* _rename_win;
+ LoadPluginWindow* _load_plugin_win{nullptr};
+ LoadGraphWindow* _load_graph_win{nullptr};
+ NewSubgraphWindow* _new_subgraph_win{nullptr};
+ PropertiesWindow* _properties_win{nullptr};
+ RenameWindow* _rename_win{nullptr};
};
} // namespace gui
diff --git a/src/gui/ingen_gui.cpp b/src/gui/ingen_gui.cpp
index 118a9000..329e098f 100644
--- a/src/gui/ingen_gui.cpp
+++ b/src/gui/ingen_gui.cpp
@@ -68,7 +68,7 @@ struct GUIModule : public Module {
extern "C" {
-ingen::Module*
+INGEN_MODULE_EXPORT ingen::Module*
ingen_module_load()
{
Glib::thread_init();
diff --git a/src/gui/ingen_gui.ui b/src/gui/ingen_gui.ui.in
index 9e751064..9e751064 100644
--- a/src/gui/ingen_gui.ui
+++ b/src/gui/ingen_gui.ui.in
diff --git a/src/gui/ingen_gui_lv2.cpp b/src/gui/ingen_gui_lv2.cpp
index ffa50779..d80d92c0 100644
--- a/src/gui/ingen_gui_lv2.cpp
+++ b/src/gui/ingen_gui_lv2.cpp
@@ -73,19 +73,13 @@ struct IngenLV2AtomSink : public AtomSink {
};
struct IngenLV2UI {
- IngenLV2UI()
- : argc(0)
- , argv(nullptr)
- , forge(nullptr)
- , world(nullptr)
- , sink(nullptr)
- {}
+ IngenLV2UI() = default;
- int argc;
- char** argv;
- Forge* forge;
- World* world;
- IngenLV2AtomSink* sink;
+ int argc{0};
+ char** argv{nullptr};
+ Forge* forge{nullptr};
+ World* world{nullptr};
+ IngenLV2AtomSink* sink{nullptr};
std::shared_ptr<gui::App> app;
std::shared_ptr<gui::GraphBox> view;
std::shared_ptr<Interface> engine;
diff --git a/src/gui/meson.build b/src/gui/meson.build
new file mode 100644
index 00000000..67914cca
--- /dev/null
+++ b/src/gui/meson.build
@@ -0,0 +1,163 @@
+# Copyright 2022 David Robillard <d@drobilla.net>
+# SPDX-License-Identifier: 0BSD OR GPL-3.0-or-later
+
+################
+# Dependencies #
+################
+
+gui_defines = platform_defines
+
+glibmm_dep = dependency('glibmm-2.4',
+ version: '>= 2.14.0',
+ include_type: 'system',
+ required: get_option('gui'))
+
+gthread_dep = dependency('gthread-2.0',
+ version: '>= 2.14.0',
+ include_type: 'system',
+ required: get_option('gui'))
+
+gtkmm_dep = dependency('gtkmm-2.4',
+ version: '>= 2.14.0',
+ include_type: 'system',
+ required: get_option('gui'))
+
+ganv_dep = dependency('ganv-1',
+ version: '>= 1.5.2',
+ fallback: ['ganv', 'ganv_dep'],
+ required: get_option('gui'))
+
+webkit_dep = dependency('webkit-1.0',
+ version: '>= 1.4.0',
+ include_type: 'system',
+ required: false)
+
+build_gui = (glibmm_dep.found() and
+ gthread_dep.found() and
+ gtkmm_dep.found() and
+ ganv_dep.found())
+
+if webkit_dep.found()
+ gui_defines += ['-DHAVE_WEBKIT=1']
+else
+ gui_defines += ['-DHAVE_WEBKIT=0']
+endif
+
+##########
+# Module #
+##########
+
+if build_gui
+ gui_sources = files(
+ 'App.cpp',
+ 'Arc.cpp',
+ 'BreadCrumbs.cpp',
+ 'ConnectWindow.cpp',
+ 'GraphBox.cpp',
+ 'GraphCanvas.cpp',
+ 'GraphPortModule.cpp',
+ 'GraphTreeWindow.cpp',
+ 'GraphView.cpp',
+ 'GraphWindow.cpp',
+ 'LoadGraphWindow.cpp',
+ 'LoadPluginWindow.cpp',
+ 'MessagesWindow.cpp',
+ 'NewSubgraphWindow.cpp',
+ 'NodeMenu.cpp',
+ 'NodeModule.cpp',
+ 'ObjectMenu.cpp',
+ 'PluginMenu.cpp',
+ 'Port.cpp',
+ 'PortMenu.cpp',
+ 'PropertiesWindow.cpp',
+ 'RDFS.cpp',
+ 'RenameWindow.cpp',
+ 'Style.cpp',
+ 'SubgraphModule.cpp',
+ 'ThreadedLoader.cpp',
+ 'URIEntry.cpp',
+ 'WidgetFactory.cpp',
+ 'WindowFactory.cpp',
+ 'ingen_gui.cpp',
+ )
+
+ gui_dependencies = [
+ boost_dep,
+ ganv_dep,
+ glibmm_dep,
+ gthread_dep,
+ gtkmm_dep,
+ ingen_client_dep,
+ ingen_dep,
+ lilv_dep,
+ raul_dep,
+ sigcpp_dep,
+ suil_dep,
+ thread_dep,
+ webkit_dep,
+ ]
+
+ gui_suppressions = []
+ if cpp.get_id() == 'clang'
+ gui_suppressions += [
+ '-Wno-reserved-identifier', # Ganv
+ ]
+ endif
+
+ gui_suppressions = cpp.get_supported_arguments(gui_suppressions)
+ gui_suppressions += cpp_suppressions
+
+ gui_args = gui_suppressions + gui_defines + ['-DINGEN_GUI_INTERNAL']
+
+ libingen_gui = shared_library(
+ 'ingen_gui',
+ gui_sources,
+ cpp_args: gui_args,
+ dependencies: gui_dependencies,
+ gnu_symbol_visibility: 'hidden',
+ implicit_include_directories: false,
+ include_directories: ingen_include_dirs,
+ install: true,
+ install_dir: ingen_module_dir,
+ )
+
+ ingen_gui_dep = declare_dependency(
+ dependencies: gui_dependencies,
+ link_with: libingen_gui,
+ )
+
+ ##########
+ # LV2 UI #
+ ##########
+
+ ingen_gui_lv2 = shared_library(
+ 'ingen_gui_lv2',
+ files('ingen_gui_lv2.cpp'),
+ cpp_args: gui_args,
+ dependencies: [ingen_gui_dep],
+ gnu_symbol_visibility: 'hidden',
+ implicit_include_directories: false,
+ include_directories: ingen_include_dirs,
+ install: true,
+ install_dir: lv2dir / 'ingen.lv2',
+ )
+
+ ###############
+ # Shared Data #
+ ###############
+
+ config = configuration_data()
+ config.set('INGEN_VERSION', meson.project_version())
+
+ configure_file(configuration: config,
+ input: files('ingen_gui.ui.in'),
+ output: 'ingen_gui.ui',
+ install: true,
+ install_dir: ingen_data_dir)
+
+ configure_file(copy: true,
+ input: files('ingen_style.rc'),
+ output: '@PLAINNAME@',
+ install: true,
+ install_dir: ingen_data_dir)
+endif
diff --git a/src/gui/rgba.hpp b/src/gui/rgba.hpp
index bd8de2d2..0d2c57aa 100644
--- a/src/gui/rgba.hpp
+++ b/src/gui/rgba.hpp
@@ -23,7 +23,7 @@
namespace ingen {
namespace gui {
-static inline uint32_t
+inline uint32_t
rgba_to_uint(uint8_t r, uint8_t g, uint8_t b, uint8_t a)
{
return ((static_cast<uint32_t>(r) << 24) |
@@ -32,10 +32,10 @@ rgba_to_uint(uint8_t r, uint8_t g, uint8_t b, uint8_t a)
(static_cast<uint32_t>(a)));
}
-static inline uint8_t
+inline uint8_t
mono_interpolate(uint8_t v1, uint8_t v2, float f)
{
- return static_cast<int>(rintf((v2) * (f) + (v1) * (1 - (f))));
+ return static_cast<uint8_t>(rintf((v2) * (f) + (v1) * (1 - (f))));
}
#define RGBA_R(x) (static_cast<uint32_t>(x) >> 24)
@@ -43,7 +43,7 @@ mono_interpolate(uint8_t v1, uint8_t v2, float f)
#define RGBA_B(x) ((static_cast<uint32_t>(x) >> 8) & 0xFF)
#define RGBA_A(x) (static_cast<uint32_t>(x) & 0xFF)
-static inline uint32_t
+inline uint32_t
rgba_interpolate(uint32_t c1, uint32_t c2, float f)
{
return rgba_to_uint(
diff --git a/src/gui/wscript b/src/gui/wscript
deleted file mode 100644
index f2471933..00000000
--- a/src/gui/wscript
+++ /dev/null
@@ -1,127 +0,0 @@
-#!/usr/bin/env python
-
-import waflib.Utils as Utils
-import waflib.Options as Options
-
-
-def options(ctx):
- opt = ctx.configuration_options()
- opt.add_option('--light-theme', action='store_true', dest='light_theme',
- help='use light coloured theme')
-
-
-def configure(conf):
- conf.check_pkg('glibmm-2.4 >= 2.14.0',
- uselib_store='GLIBMM',
- system=True,
- mandatory=False)
- conf.check_pkg('gthread-2.0 >= 2.14.0',
- uselib_store='GTHREAD',
- system=True,
- mandatory=False)
- conf.check_pkg('gtkmm-2.4 >= 2.14.0',
- uselib_store='GTKMM',
- system=True,
- mandatory=False)
- conf.check_pkg('ganv-1 >= 1.5.4',
- uselib_store='GANV',
- mandatory=False)
- if not Options.options.no_webkit:
- conf.check_pkg('webkit-1.0 >= 1.4.0',
- uselib_store='WEBKIT',
- system=True,
- mandatory=False)
-
- if conf.env.HAVE_GANV and conf.env.HAVE_GTKMM:
- conf.env.INGEN_BUILD_GUI = 1
-
- if Options.options.light_theme:
- conf.define('INGEN_USE_LIGHT_THEME', 1)
-
-
-def build(bld):
- obj = bld(features = 'cxx cxxshlib',
- cflags = ['-fvisibility=hidden'],
- export_includes = ['../../include'],
- includes = ['../../', '../../include'],
- name = 'libingen_gui',
- target = 'ingen_gui',
- install_path = '${LIBDIR}',
- use = 'libingen libingen_client',
- uselib = '''
- GANV
- GLADEMM
- GLIBMM
- GNOMECANVAS
- GTKMM
- LILV
- LV2
- RAUL
- SIGCPP
- SERD
- SORD
- SRATOM
- SOUP
- SUIL
- WEBKIT
- ''')
-
- obj.source = '''
- App.cpp
- Arc.cpp
- BreadCrumbs.cpp
- ConnectWindow.cpp
- GraphBox.cpp
- GraphCanvas.cpp
- GraphPortModule.cpp
- GraphTreeWindow.cpp
- GraphView.cpp
- GraphWindow.cpp
- LoadGraphWindow.cpp
- LoadPluginWindow.cpp
- MessagesWindow.cpp
- NewSubgraphWindow.cpp
- NodeMenu.cpp
- NodeModule.cpp
- ObjectMenu.cpp
- PluginMenu.cpp
- Port.cpp
- PortMenu.cpp
- PropertiesWindow.cpp
- RDFS.cpp
- RenameWindow.cpp
- Style.cpp
- SubgraphModule.cpp
- ThreadedLoader.cpp
- URIEntry.cpp
- WidgetFactory.cpp
- WindowFactory.cpp
- ingen_gui.cpp
- '''
-
- # XML UI definition
- bld(features = 'subst',
- source = 'ingen_gui.ui',
- target = '../../ingen_gui.ui',
- install_path = '${DATADIR}/ingen',
- chmod = Utils.O755,
- INGEN_VERSION = bld.env.INGEN_VERSION)
-
- # Gtk style
- bld(features = 'subst',
- is_copy = True,
- source = 'ingen_style.rc',
- target = '../../ingen_style.rc',
- install_path = '${DATADIR}/ingen',
- chmod = Utils.O755)
-
- # LV2 UI
- obj = bld(features = 'cxx cxxshlib',
- cflags = ['-fvisibility=hidden'],
- source = 'ingen_gui_lv2.cpp',
- includes = ['.', '../../', '../../include'],
- name = 'ingen_gui_lv2',
- target = 'ingen_gui_lv2',
- install_path = '${LV2DIR}/ingen.lv2/',
- use = 'libingen libingen_gui',
- uselib = 'LV2 SERD SORD SRATOM LILV RAUL GLIBMM GTKMM')
diff --git a/src/include/ingen_config.h b/src/include/ingen_config.h
new file mode 100644
index 00000000..6d5f36e0
--- /dev/null
+++ b/src/include/ingen_config.h
@@ -0,0 +1,216 @@
+// Copyright 2021-2022 David Robillard <d@drobilla.net>
+// SPDX-License-Identifier: ISC
+
+/*
+ Configuration header that defines reasonable defaults at compile time.
+
+ This allows compile-time configuration from the command line, while still
+ allowing the source to be built "as-is" without any configuration. The idea
+ is to support an advanced build system with configuration checks, while still
+ allowing the code to be simply "thrown at a compiler" with features
+ determined from the compiler or system headers. Everything can be
+ overridden, so it should never be necessary to edit this file to build
+ successfully.
+
+ To ensure that all configure checks are performed, the build system can
+ define INGEN_NO_DEFAULT_CONFIG to disable defaults. In this case, it must
+ define all HAVE_FEATURE symbols below to 1 or 0 to enable or disable
+ features. Any missing definitions will generate a compiler warning.
+
+ To ensure that this header is always included properly, all code that uses
+ configuration variables includes this header and checks their value with #if
+ (not #ifdef). Variables like USE_FEATURE are internal and should never be
+ defined on the command line.
+*/
+
+#ifndef INGEN_CONFIG_H
+#define INGEN_CONFIG_H
+
+// Define version unconditionally so a warning will catch a mismatch
+#define INGEN_VERSION "0.5.1"
+
+#if !defined(INGEN_NO_DEFAULT_CONFIG)
+
+// We need unistd.h to check _POSIX_VERSION
+# ifndef INGEN_NO_POSIX
+# ifdef __has_include
+# if __has_include(<unistd.h>)
+# include <unistd.h>
+# endif
+# elif defined(__unix__)
+# include <unistd.h>
+# endif
+# endif
+
+// POSIX.1-2001: fileno()
+# ifndef HAVE_FILENO
+# if defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L
+# define HAVE_FILENO 1
+# else
+# define HAVE_FILENO 0
+# endif
+# endif
+
+// POSIX.1-2001: isatty()
+# ifndef HAVE_ISATTY
+# if defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L
+# define HAVE_ISATTY 1
+# else
+# define HAVE_ISATTY 0
+# endif
+# endif
+
+// POSIX.1-2001: posix_memalign()
+# ifndef HAVE_POSIX_MEMALIGN
+# if defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L
+# define HAVE_POSIX_MEMALIGN 1
+# else
+# define HAVE_POSIX_MEMALIGN 0
+# endif
+# endif
+
+// BSD and GNU: vasprintf()
+# ifndef HAVE_VASPRINTF
+# if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
+# define HAVE_VASPRINTF 1
+# else
+# define HAVE_VASPRINTF 0
+# endif
+# endif
+
+// JACK
+# ifndef HAVE_JACK
+# ifdef __has_include
+# if __has_include("jack/jack.h")
+# define HAVE_JACK 1
+# else
+# define HAVE_JACK 0
+# endif
+# else
+# define HAVE_JACK 0
+# endif
+# endif
+
+// JACK metadata API
+# ifndef HAVE_JACK_METADATA
+# ifdef __has_include
+# if __has_include("jack/metadata.h")
+# define HAVE_JACK_METADATA 1
+# else
+# define HAVE_JACK_METADATA 0
+# endif
+# else
+# define HAVE_JACK_METADATA 0
+# endif
+# endif
+
+// JACK jack_port_rename() function
+# ifndef HAVE_JACK_PORT_RENAME
+# define HAVE_JACK_PORT_RENAME HAVE_JACK
+# endif
+
+// BSD sockets
+# ifndef HAVE_SOCKET
+# ifdef __has_include
+# if __has_include("sys/socket.h")
+# define HAVE_SOCKET 1
+# else
+# define HAVE_SOCKET 0
+# endif
+# else
+# define HAVE_SOCKET 0
+# endif
+# endif
+
+// Webkit
+# ifndef HAVE_WEBKIT
+# ifdef __has_include
+# if __has_include(<webkit/webkit.h>)
+# define HAVE_WEBKIT 1
+# else
+# define HAVE_WEBKIT 0
+# endif
+# else
+# define HAVE_WEBKIT 0
+# endif
+# endif
+
+// Installation directories
+# ifndef INGEN_DATA_DIR
+# define INGEN_DATA_DIR "/usr/local/share/ingen"
+# endif
+# ifndef INGEN_MODULE_DIR
+# define INGEN_MODULE_DIR "/usr/local/lib/ingen"
+# endif
+# ifndef INGEN_BUNDLE_DIR
+# define INGEN_BUNDLE_DIR "/usr/local/lib/lv2/ingen.lv2"
+# endif
+
+#endif // !defined(INGEN_NO_DEFAULT_CONFIG)
+
+/*
+ Make corresponding USE_FEATURE defines based on the HAVE_FEATURE defines from
+ above or the command line. The code checks for these using #if (not #ifdef),
+ so there will be an undefined warning if it checks for an unknown feature,
+ and this header is always required by any code that checks for features, even
+ if the build system defines them all.
+*/
+
+#if defined(HAVE_FILENO)
+# define USE_FILENO HAVE_FILENO
+#else
+# define USE_FILENO 0
+#endif
+
+#if defined(HAVE_ISATTY)
+# define USE_ISATTY HAVE_ISATTY
+#else
+# define USE_ISATTY 0
+#endif
+
+#if defined(HAVE_POSIX_MEMALIGN)
+# define USE_POSIX_MEMALIGN HAVE_POSIX_MEMALIGN
+#else
+# define USE_POSIX_MEMALIGN 0
+#endif
+
+#if defined(HAVE_SOCKET)
+# define USE_SOCKET HAVE_SOCKET
+#else
+# define USE_SOCKET 0
+#endif
+
+#if defined(HAVE_VASPRINTF)
+# define USE_VASPRINTF HAVE_VASPRINTF
+#else
+# define USE_VASPRINTF 0
+#endif
+
+#if defined(HAVE_WEBKIT)
+# define USE_WEBKIT HAVE_WEBKIT
+#else
+# define USE_WEBKIT 0
+#endif
+
+#if defined(HAVE_JACK_METADATA)
+# define USE_JACK_METADATA HAVE_JACK_METADATA
+#else
+# define USE_JACK_METADATA 0
+#endif
+
+#if defined(HAVE_JACK_PORT_TYPE_GET_BUFFER_SIZE)
+# define USE_JACK_PORT_TYPE_GET_BUFFER_SIZE \
+ HAVE_JACK_PORT_TYPE_GET_BUFFER_SIZE
+#else
+# define USE_JACK_PORT_TYPE_GET_BUFFER_SIZE 0
+#endif
+
+#if defined(HAVE_JACK_PORT_RENAME)
+# define USE_JACK_PORT_RENAME HAVE_JACK_PORT_RENAME
+#else
+# define USE_JACK_PORT_RENAME 0
+#endif
+
+#define INGEN_BUNDLED 0
+
+#endif // INGEN_CONFIG_H
diff --git a/src/ingen/.clang-tidy b/src/ingen/.clang-tidy
new file mode 100644
index 00000000..e7bf0b6a
--- /dev/null
+++ b/src/ingen/.clang-tidy
@@ -0,0 +1,3 @@
+Checks: >
+ -bugprone-exception-escape,
+InheritParentConfig: true
diff --git a/src/ingen/ingen.cpp b/src/ingen/ingen.cpp
index c7c3ef74..06d990f2 100644
--- a/src/ingen/ingen.cpp
+++ b/src/ingen/ingen.cpp
@@ -31,7 +31,7 @@
#include "raul/Symbol.hpp"
#include "serd/serd.h"
-#ifdef HAVE_SOCKET
+#if USE_SOCKET
#include "ingen/client/SocketClient.hpp"
#endif
@@ -99,16 +99,19 @@ run(int argc, char** argv)
{
// Create world
try {
- world = std::unique_ptr<ingen::World>(
- new ingen::World(nullptr, nullptr, nullptr));
+ world = std::make_unique<ingen::World>(nullptr, nullptr, nullptr);
world->load_configuration(argc, argv);
if (argc <= 1) {
world->conf().print_usage("ingen", std::cout);
return EXIT_FAILURE;
- } else if (world->conf().option("help").get<int32_t>()) {
+ }
+
+ if (world->conf().option("help").get<int32_t>()) {
world->conf().print_usage("ingen", std::cout);
return EXIT_SUCCESS;
- } else if (world->conf().option("version").get<int32_t>()) {
+ }
+
+ if (world->conf().option("version").get<int32_t>()) {
return print_version();
}
} catch (std::exception& e) {
@@ -134,7 +137,7 @@ run(int argc, char** argv)
world->engine()->listen();
}
-#ifdef HAVE_SOCKET
+#if USE_SOCKET
client::SocketClient::register_factories(*world);
#endif
diff --git a/src/meson.build b/src/meson.build
new file mode 100644
index 00000000..6c83ae95
--- /dev/null
+++ b/src/meson.build
@@ -0,0 +1,65 @@
+# Copyright 2022 David Robillard <d@drobilla.net>
+# SPDX-License-Identifier: 0BSD OR GPL-3.0-or-later
+
+sources = files(
+ 'AtomReader.cpp',
+ 'AtomWriter.cpp',
+ 'ClashAvoider.cpp',
+ 'ColorContext.cpp',
+ 'Configuration.cpp',
+ 'FilePath.cpp',
+ 'Forge.cpp',
+ 'LV2Features.cpp',
+ 'Library.cpp',
+ 'Log.cpp',
+ 'Parser.cpp',
+ 'Resource.cpp',
+ 'Serialiser.cpp',
+ 'Store.cpp',
+ 'StreamWriter.cpp',
+ 'TurtleWriter.cpp',
+ 'URI.cpp',
+ 'URIMap.cpp',
+ 'URIs.cpp',
+ 'World.cpp',
+ 'runtime_paths.cpp'
+)
+
+if have_socket
+ sources += files('SocketReader.cpp', 'SocketWriter.cpp')
+endif
+
+ingen_deps = [
+ boost_dep,
+ lilv_dep,
+ lv2_dep,
+ raul_dep,
+ serd_dep,
+ sord_dep,
+ sratom_dep,
+ thread_dep,
+]
+
+ingen_include_dirs = include_directories('../include', 'include')
+
+libingen = shared_library(
+ 'ingen' + library_suffix,
+ sources,
+ cpp_args: cpp_suppressions + platform_defines,
+ dependencies: ingen_deps,
+ gnu_symbol_visibility: 'hidden',
+ implicit_include_directories: false,
+ include_directories: ingen_include_dirs,
+ install: true,
+ version: meson.project_version(),
+)
+
+ingen_dep = declare_dependency(
+ dependencies: ingen_deps,
+ include_directories: include_directories('../include'),
+ link_with: libingen,
+)
+
+subdir('server')
+subdir('client')
+subdir('gui')
diff --git a/src/runtime_paths.cpp b/src/runtime_paths.cpp
index 38eb681f..86315be8 100644
--- a/src/runtime_paths.cpp
+++ b/src/runtime_paths.cpp
@@ -70,7 +70,7 @@ set_bundle_path_from_code(void (*function)())
Dl_info dli;
dladdr(reinterpret_cast<void*>(function), &dli);
-#ifdef BUNDLE
+#if INGEN_BUNDLED
char bin_loc[PATH_MAX];
realpath(dli.dli_fname, bin_loc);
#else
@@ -117,7 +117,7 @@ data_file_path(const std::string& name)
std::vector<FilePath>
ingen_module_dirs()
{
-#ifdef BUNDLE
+#if INGEN_BUNDLED
const FilePath default_dir = FilePath(bundle_path) / INGEN_MODULE_DIR;
#else
const FilePath default_dir = INGEN_MODULE_DIR;
@@ -138,22 +138,28 @@ FilePath
user_config_dir()
{
if (const char* xdg_config_home = getenv("XDG_CONFIG_HOME")) {
- return FilePath(xdg_config_home);
- } else if (const char* home = getenv("HOME")) {
+ return {xdg_config_home};
+ }
+
+ if (const char* home = getenv("HOME")) {
return FilePath(home) / ".config";
}
- return FilePath();
+
+ return {};
}
FilePath
user_data_dir()
{
if (const char* xdg_data_home = getenv("XDG_DATA_HOME")) {
- return FilePath(xdg_data_home);
- } else if (const char* home = getenv("HOME")) {
+ return {xdg_data_home};
+ }
+
+ if (const char* home = getenv("HOME")) {
return FilePath(home) / ".local/share";
}
- return FilePath();
+
+ return {};
}
std::vector<FilePath>
@@ -186,7 +192,7 @@ data_dirs()
std::vector<FilePath> paths = system_data_dirs();
const FilePath user_dir = user_data_dir();
-#ifdef BUNDLE
+#if INGEN_BUNDLED
paths.insert(paths.begin(), bundle_path / INGEN_DATA_DIR);
#endif
diff --git a/src/server/.clang-tidy b/src/server/.clang-tidy
index fc51d942..51c9b102 100644
--- a/src/server/.clang-tidy
+++ b/src/server/.clang-tidy
@@ -1,62 +1,22 @@
Checks: >
- *,
-*-avoid-c-arrays,
- -*-else-after-return,
- -*-magic-numbers,
- -*-named-parameter,
- -*-narrowing-conversions,
-*-non-private-member-variables-in-classes,
- -*-special-member-functions,
-*-uppercase-literal-suffix,
-*-vararg,
- -abseil-string-find-str-contains,
- -android-cloexec-*,
-bugprone-branch-clone,
-bugprone-parent-virtual-call,
-bugprone-reserved-identifier,
- -bugprone-signed-char-misuse,
-bugprone-suspicious-string-compare,
- -cert-str34-c,
- -clang-analyzer-optin.cplusplus.VirtualCall,
- -cppcoreguidelines-avoid-non-const-global-variables,
- -cppcoreguidelines-macro-usage,
- -cppcoreguidelines-no-malloc,
- -cppcoreguidelines-owning-memory,
- -cppcoreguidelines-pro-bounds-array-to-pointer-decay,
+ -cert-dcl37-c,
+ -cert-dcl51-cpp,
-cppcoreguidelines-pro-bounds-constant-array-index,
- -cppcoreguidelines-pro-bounds-pointer-arithmetic,
- -cppcoreguidelines-pro-type-const-cast,
-cppcoreguidelines-pro-type-cstyle-cast,
- -cppcoreguidelines-pro-type-reinterpret-cast,
-cppcoreguidelines-pro-type-static-cast-downcast,
- -cppcoreguidelines-pro-type-union-access,
- -fuchsia-*,
- -google-default-arguments,
- -google-explicit-constructor,
-google-readability-todo,
-google-runtime-int,
-google-runtime-references,
- -hicpp-explicit-conversions,
-hicpp-multiway-paths-covered,
- -hicpp-no-array-decay,
- -hicpp-no-malloc,
- -hicpp-signed-bitwise,
-llvm-header-guard,
- -llvmlibc-*,
- -misc-no-recursion,
- -misc-unused-parameters,
- -modernize-use-default-member-init,
- -modernize-use-trailing-return-type,
+ -misc-redundant-expression,
-portability-simd-intrinsics,
- -readability-implicit-bool-conversion,
- -readability-redundant-member-init,
- -readability-use-anyofallof,
-CheckOptions:
- - key: modernize-use-override.AllowOverrideAndFinal
- value: 'true'
-CheckOptions:
- - key: cppcoreguidelines-explicit-virtual-functions.AllowOverrideAndFinal
- value: 'true'
-WarningsAsErrors: '*'
-HeaderFilterRegex: 'include/ingen/.*|tests/.*|src/.*'
-FormatStyle: file
+InheritParentConfig: true
diff --git a/src/server/ArcImpl.hpp b/src/server/ArcImpl.hpp
index 09c59c8f..5e7e4357 100644
--- a/src/server/ArcImpl.hpp
+++ b/src/server/ArcImpl.hpp
@@ -60,8 +60,8 @@ public:
ArcImpl(PortImpl* tail, PortImpl* head);
~ArcImpl() override;
- inline PortImpl* tail() const { return _tail; }
- inline PortImpl* head() const { return _head; }
+ PortImpl* tail() const { return _tail; }
+ PortImpl* head() const { return _head; }
const raul::Path& tail_path() const override;
const raul::Path& head_path() const override;
diff --git a/src/server/BlockFactory.cpp b/src/server/BlockFactory.cpp
index 14a50098..2b80f037 100644
--- a/src/server/BlockFactory.cpp
+++ b/src/server/BlockFactory.cpp
@@ -33,7 +33,9 @@
#include "internals/Trigger.hpp"
#include "lilv/lilv.h"
+#include <algorithm>
#include <cstdint>
+#include <iterator>
#include <memory>
#include <utility>
#include <vector>
@@ -43,7 +45,6 @@ namespace server {
BlockFactory::BlockFactory(ingen::World& world)
: _world(world)
- , _has_loaded(false)
{
load_internal_plugins();
}
@@ -84,11 +85,10 @@ BlockFactory::refresh()
}
// Add any resurrected plugins to response
- for (const auto& z : zombies) {
- if (!z->is_zombie()) {
- new_plugins.insert(z);
- }
- }
+ std::copy_if(zombies.begin(),
+ zombies.end(),
+ std::inserter(new_plugins, new_plugins.end()),
+ [](const auto& z) { return !z->is_zombie(); });
return new_plugins;
}
@@ -97,7 +97,7 @@ PluginImpl*
BlockFactory::plugin(const URI& uri)
{
load_plugin(uri);
- const Plugins::const_iterator i = _plugins.find(uri);
+ const auto i = _plugins.find(uri);
return ((i != _plugins.end()) ? i->second.get() : nullptr);
}
@@ -156,14 +156,14 @@ BlockFactory::load_lv2_plugins()
}
const LilvPlugins* plugins = lilv_world_get_all_plugins(_world.lilv_world());
- LILV_FOREACH(plugins, i, plugins) {
+ LILV_FOREACH (plugins, i, plugins) {
const LilvPlugin* lv2_plug = lilv_plugins_get(plugins, i);
const URI uri(lilv_node_as_uri(lilv_plugin_get_uri(lv2_plug)));
// Ignore plugins that require features Ingen doesn't support
LilvNodes* features = lilv_plugin_get_required_features(lv2_plug);
bool supported = true;
- LILV_FOREACH(nodes, f, features) {
+ LILV_FOREACH (nodes, f, features) {
const char* feature = lilv_node_as_uri(lilv_nodes_get(features, f));
if (!_world.lv2_features().is_supported(feature)) {
supported = false;
diff --git a/src/server/BlockFactory.hpp b/src/server/BlockFactory.hpp
index 7cf28325..17c11bb4 100644
--- a/src/server/BlockFactory.hpp
+++ b/src/server/BlockFactory.hpp
@@ -62,7 +62,7 @@ private:
Plugins _plugins;
ingen::World& _world;
- bool _has_loaded;
+ bool _has_loaded{false};
};
} // namespace server
diff --git a/src/server/BlockImpl.cpp b/src/server/BlockImpl.cpp
index 26e83eb8..81474126 100644
--- a/src/server/BlockImpl.cpp
+++ b/src/server/BlockImpl.cpp
@@ -43,10 +43,7 @@ BlockImpl::BlockImpl(PluginImpl* plugin,
: NodeImpl(plugin->uris(), parent, symbol)
, _plugin(plugin)
, _polyphony((polyphonic && parent) ? parent->internal_poly() : 1)
- , _mark(Mark::UNVISITED)
, _polyphonic(polyphonic)
- , _activated(false)
- , _enabled(true)
{
assert(_plugin);
assert(_polyphony > 0);
@@ -209,8 +206,10 @@ BlockImpl::bypass(RunContext& ctx)
PortImpl* in = nth_port_by_type(i, true, t);
PortImpl* out = nth_port_by_type(i, false, t);
if (!out) {
- break; // Finished writing all outputs
- } else if (in) {
+ break; // Finished writing all outputs
+ }
+
+ if (in) {
// Copy corresponding input to output
for (uint32_t v = 0; v < _polyphony; ++v) {
out->buffer(v)->copy(ctx, in->buffer(v).get());
diff --git a/src/server/BlockImpl.hpp b/src/server/BlockImpl.hpp
index c285bdac..9d63f78e 100644
--- a/src/server/BlockImpl.hpp
+++ b/src/server/BlockImpl.hpp
@@ -62,7 +62,7 @@ class Worker;
* \ingroup engine
*/
class BlockImpl : public NodeImpl
- , public boost::intrusive::slist_base_hook<> // In GraphImpl
+ , public boost::intrusive::slist_base_hook<> // In GraphImpl
{
public:
using Ports = raul::Array<PortImpl*>;
@@ -117,7 +117,7 @@ public:
/** Save current state as preset. */
virtual boost::optional<Resource>
save_preset(const URI& bundle,
- const Properties& props) { return boost::optional<Resource>(); }
+ const Properties& props) { return {}; }
/** Learn the next incoming MIDI event (for internals) */
virtual void learn() {}
@@ -208,10 +208,10 @@ protected:
uint32_t _polyphony;
std::set<BlockImpl*> _providers; ///< Blocks connected to this one's input ports
std::set<BlockImpl*> _dependants; ///< Blocks this one's output ports are connected to
- Mark _mark; ///< Mark for graph compilation algorithm
+ Mark _mark{Mark::UNVISITED}; ///< Mark for graph walks
bool _polyphonic;
- bool _activated;
- bool _enabled;
+ bool _activated{false};
+ bool _enabled{true};
};
} // namespace server
diff --git a/src/server/Broadcaster.cpp b/src/server/Broadcaster.cpp
index 6d32db84..04fbdba0 100644
--- a/src/server/Broadcaster.cpp
+++ b/src/server/Broadcaster.cpp
@@ -22,7 +22,6 @@
#include "ingen/Interface.hpp"
#include <cstddef>
-#include <map>
#include <memory>
#include <utility>
diff --git a/src/server/Broadcaster.hpp b/src/server/Broadcaster.hpp
index 8e9848f4..39acca04 100644
--- a/src/server/Broadcaster.hpp
+++ b/src/server/Broadcaster.hpp
@@ -76,7 +76,8 @@ public:
* This makes doing the right thing in recursive functions that send
* updates simple (e.g. Event::post_process()).
*/
- class Transfer : public raul::Noncopyable {
+ class Transfer : public raul::Noncopyable
+ {
public:
explicit Transfer(Broadcaster& b) : broadcaster(b) {
if (++broadcaster._bundle_depth == 1) {
diff --git a/src/server/Buffer.cpp b/src/server/Buffer.cpp
index 36dfaf19..f561871f 100644
--- a/src/server/Buffer.cpp
+++ b/src/server/Buffer.cpp
@@ -19,11 +19,11 @@
#include "BufferFactory.hpp"
#include "Engine.hpp"
#include "RunContext.hpp"
+#include "ingen_config.h"
#include "ingen/Atom.hpp"
#include "ingen/Log.hpp"
#include "ingen/URIs.hpp"
-#include "ingen_config.h"
#include "lv2/atom/atom.h"
#include "lv2/atom/util.h"
#include "lv2/urid/urid.h"
@@ -48,13 +48,10 @@ Buffer::Buffer(BufferFactory& bufs,
bool external,
void*)
: _factory(bufs)
- , _next(nullptr)
, _buf(external ? nullptr : aligned_alloc(capacity))
- , _latest_event(0)
, _type(type)
, _value_type(value_type)
, _capacity(capacity)
- , _refs(0)
, _external(external)
{
if (!external && !_buf) {
@@ -135,7 +132,7 @@ Buffer::render_sequence(const RunContext& ctx, const Buffer* src, bool add)
float value = init ? init->body : 0.0f;
SampleCount offset = ctx.offset();
- LV2_ATOM_SEQUENCE_FOREACH(seq, ev) {
+ LV2_ATOM_SEQUENCE_FOREACH (seq, ev) {
if (ev->time.frames >= offset && ev->body.type == atom_Float) {
write_block(value, offset, ev->time.frames, add);
value = reinterpret_cast<const LV2_Atom_Float*>(&ev->body)->body;
@@ -150,7 +147,9 @@ Buffer::copy(const RunContext& ctx, const Buffer* src)
{
if (!_buf) {
return;
- } else if (_type == src->type()) {
+ }
+
+ if (_type == src->type()) {
const uint32_t src_size = src->size();
if (src_size <= _capacity) {
memcpy(_buf, src->_buf, src_size);
@@ -218,7 +217,7 @@ Buffer::port_data(PortType port_type, SampleCount offset) const
static inline __m128
mm_abs_ps(__m128 x)
{
- const __m128 sign_mask = _mm_set1_ps(-0.0f); // -0.0f = 1 << 31
+ const __m128 sign_mask = _mm_set1_ps(-0.0f); // -0.0f = 1 << 31
return _mm_andnot_ps(sign_mask, x);
}
#endif
@@ -259,7 +258,7 @@ Buffer::peak(const RunContext& ctx) const
#else
const Sample* const buf = samples();
float peak = 0.0f;
- for (SampleCount i = 0; i < context.nframes(); ++i) {
+ for (SampleCount i = 0; i < ctx.nframes(); ++i) {
peak = fmaxf(peak, fabsf(buf[i]));
}
return peak;
@@ -300,7 +299,7 @@ Buffer::append_event(int64_t frames,
auto* atom = get<LV2_Atom>();
if (atom->type == _factory.uris().atom_Chunk) {
- clear(); // Chunk initialized with prepare_output_write(), clear
+ clear(); // Chunk initialized with prepare_output_write(), clear
}
if (sizeof(LV2_Atom) + atom->size + lv2_atom_pad_size(size) > _capacity) {
@@ -340,14 +339,14 @@ Buffer::append_event_buffer(const Buffer* buf)
reinterpret_cast<const LV2_Atom_Sequence*>(buf->get<LV2_Atom>());
if (seq->atom.type == _factory.uris().atom_Chunk) {
- clear(); // Chunk initialized with prepare_output_write(), clear
+ clear(); // Chunk initialized with prepare_output_write(), clear
}
const uint32_t total_size = lv2_atom_total_size(&seq->atom);
uint8_t* const end = reinterpret_cast<uint8_t*>(seq) + total_size;
const uint32_t n_bytes = bseq->atom.size - sizeof(bseq->body);
if (sizeof(LV2_Atom) + total_size + n_bytes >= _capacity) {
- return false; // Not enough space
+ return false; // Not enough space
}
memcpy(end, bseq + 1, n_bytes);
@@ -363,7 +362,7 @@ Buffer::next_value_offset(SampleCount offset, SampleCount end) const
{
if (_type == _factory.uris().atom_Sequence && _value_type) {
const auto* seq = get<const LV2_Atom_Sequence>();
- LV2_ATOM_SEQUENCE_FOREACH(seq, ev) {
+ LV2_ATOM_SEQUENCE_FOREACH (seq, ev) {
if (ev->time.frames > offset &&
ev->time.frames < end &&
ev->body.type == _value_type) {
@@ -416,10 +415,12 @@ Buffer::update_value_buffer(SampleCount offset)
auto* seq = get<LV2_Atom_Sequence>();
LV2_Atom_Event* latest = nullptr;
- LV2_ATOM_SEQUENCE_FOREACH(seq, ev) {
+ LV2_ATOM_SEQUENCE_FOREACH (seq, ev) {
if (ev->time.frames > offset) {
break;
- } else if (ev->body.type == _value_type) {
+ }
+
+ if (ev->body.type == _value_type) {
latest = ev;
}
}
@@ -433,7 +434,7 @@ Buffer::update_value_buffer(SampleCount offset)
void* Buffer::aligned_alloc(size_t size)
{
-#ifdef HAVE_POSIX_MEMALIGN
+#if USE_POSIX_MEMALIGN
void* buf = nullptr;
if (!posix_memalign(static_cast<void**>(&buf), 16, size)) {
memset(buf, 0, size);
diff --git a/src/server/Buffer.hpp b/src/server/Buffer.hpp
index 21364fd9..8a64e621 100644
--- a/src/server/Buffer.hpp
+++ b/src/server/Buffer.hpp
@@ -20,10 +20,10 @@
#include "BufferFactory.hpp"
#include "BufferRef.hpp"
#include "PortType.hpp"
+#include "server.h"
#include "types.hpp"
#include "ingen/URIs.hpp"
-#include "ingen/ingen.h"
#include "lv2/atom/atom.h"
#include "lv2/urid/urid.h"
@@ -40,7 +40,7 @@ namespace server {
class RunContext;
-class INGEN_API Buffer
+class INGEN_SERVER_API Buffer
{
public:
Buffer(BufferFactory& bufs,
@@ -61,10 +61,10 @@ public:
void* port_data(PortType port_type, SampleCount offset);
const void* port_data(PortType port_type, SampleCount offset) const;
- inline LV2_URID type() const { return _type; }
- inline LV2_URID value_type() const { return _value_type; }
- inline uint32_t capacity() const { return _capacity; }
- inline uint32_t size() const {
+ LV2_URID type() const { return _type; }
+ LV2_URID value_type() const { return _value_type; }
+ uint32_t capacity() const { return _capacity; }
+ uint32_t size() const {
return is_audio() ? _capacity : sizeof(LV2_Atom) + get<LV2_Atom>()->size;
}
@@ -78,52 +78,60 @@ public:
*/
void set_type(GetFn get_func, LV2_URID type, LV2_URID value_type);
- inline bool is_audio() const {
+ bool is_audio() const {
return _type == _factory.uris().atom_Sound;
}
- inline bool is_control() const {
+ bool is_control() const {
return _type == _factory.uris().atom_Float;
}
- inline bool is_sequence() const {
+ bool is_sequence() const {
return _type == _factory.uris().atom_Sequence;
}
/// Audio or float buffers only
- inline const Sample* samples() const {
+ const Sample* samples() const {
if (is_control()) {
return static_cast<const Sample*>(
LV2_ATOM_BODY_CONST(get<LV2_Atom_Float>()));
- } else if (is_audio()) {
+ }
+
+ if (is_audio()) {
return static_cast<const Sample*>(_buf);
}
+
return nullptr;
}
/// Audio buffers only
- inline Sample* samples() {
+ Sample* samples() {
if (is_control()) {
return static_cast<Sample*>(LV2_ATOM_BODY(get<LV2_Atom_Float>()));
- } else if (is_audio()) {
+ }
+
+ if (is_audio()) {
return static_cast<Sample*>(_buf);
}
+
return nullptr;
}
/// Numeric buffers only
- inline Sample value_at(SampleCount offset) const {
+ Sample value_at(SampleCount offset) const {
if (is_audio() || is_control()) {
return samples()[offset];
- } else if (_value_buffer) {
+ }
+
+ if (_value_buffer) {
return reinterpret_cast<const LV2_Atom_Float*>(value())->body;
}
+
return 0.0f;
}
- inline void set_block(const Sample val,
- const SampleCount start,
- const SampleCount end)
+ void
+ set_block(const Sample val, const SampleCount start, const SampleCount end)
{
if (is_sequence()) {
append_event(start, sizeof(val), _factory.uris().atom_Float,
@@ -142,9 +150,8 @@ public:
}
}
- inline void add_block(const Sample val,
- const SampleCount start,
- const SampleCount end)
+ void
+ add_block(const Sample val, const SampleCount start, const SampleCount end)
{
assert(is_audio() || is_control());
assert(end <= _capacity / sizeof(Sample));
@@ -155,10 +162,10 @@ public:
}
}
- inline void write_block(const Sample val,
- const SampleCount start,
- const SampleCount end,
- const bool add)
+ void write_block(const Sample val,
+ const SampleCount start,
+ const SampleCount end,
+ const bool add)
{
if (add) {
add_block(val, start, end);
@@ -212,9 +219,9 @@ public:
template<typename T> const T* get() const { return reinterpret_cast<const T*>(_buf); }
template<typename T> T* get() { return reinterpret_cast<T*>(_buf); }
- inline void ref() { ++_refs; }
+ void ref() { ++_refs; }
- inline void deref() {
+ void deref() {
if ((--_refs) == 0) {
recycle();
}
@@ -229,15 +236,15 @@ private:
BufferFactory& _factory;
// NOLINTNEXTLINE(clang-analyzer-webkit.NoUncountedMemberChecker)
- Buffer* _next; ///< Intrusive linked list for BufferFactory
+ Buffer* _next{nullptr}; ///< Intrusive linked list for BufferFactory
void* _buf; ///< Actual buffer memory
BufferRef _value_buffer; ///< Value buffer for numeric sequences
- int64_t _latest_event;
+ int64_t _latest_event{0};
LV2_URID _type;
LV2_URID _value_type;
uint32_t _capacity;
- std::atomic<unsigned> _refs; ///< Intrusive reference count
+ std::atomic<unsigned> _refs{0}; ///< Intrusive reference count
bool _external; ///< Buffer is externally allocated
};
diff --git a/src/server/BufferFactory.cpp b/src/server/BufferFactory.cpp
index 4ecdfc3b..8ed4eaae 100644
--- a/src/server/BufferFactory.cpp
+++ b/src/server/BufferFactory.cpp
@@ -38,10 +38,8 @@ BufferFactory::BufferFactory(Engine& engine, URIs& uris)
, _free_object(nullptr)
, _engine(engine)
, _uris(uris)
- , _seq_size(0)
, _silent_buffer(nullptr)
-{
-}
+{}
BufferFactory::~BufferFactory()
{
@@ -101,19 +99,25 @@ BufferFactory::default_size(LV2_URID type) const
{
if (type == _uris.atom_Float) {
return sizeof(LV2_Atom_Float);
- } else if (type == _uris.atom_Sound) {
+ }
+
+ if (type == _uris.atom_Sound) {
return audio_buffer_size(_engine.block_length());
- } else if (type == _uris.atom_URID) {
+ }
+
+ if (type == _uris.atom_URID) {
return sizeof(LV2_Atom_URID);
- } else if (type == _uris.atom_Sequence) {
+ }
+
+ if (type == _uris.atom_Sequence) {
if (_seq_size == 0) {
return _engine.sequence_size();
- } else {
- return _seq_size;
}
- } else {
- return 0;
+
+ return _seq_size;
}
+
+ return 0;
}
Buffer*
@@ -146,7 +150,7 @@ BufferFactory::get_buffer(LV2_URID type,
try_head->_next = nullptr;
try_head->set_type(&BufferFactory::get_buffer, type, value_type);
try_head->clear();
- return BufferRef(try_head);
+ return {try_head};
}
BufferRef
@@ -155,12 +159,12 @@ BufferFactory::claim_buffer(LV2_URID type, LV2_URID value_type, uint32_t)
Buffer* try_head = try_get_buffer(type);
if (!try_head) {
_engine.world().log().rt_error("Failed to obtain buffer");
- return BufferRef();
+ return {};
}
try_head->_next = nullptr;
try_head->set_type(&BufferFactory::claim_buffer, type, value_type);
- return BufferRef(try_head);
+ return {try_head};
}
BufferRef
@@ -181,7 +185,7 @@ BufferFactory::create(LV2_URID type, LV2_URID value_type, uint32_t capacity)
capacity = std::max(capacity, default_size(_uris.atom_Sound));
}
- return BufferRef(new Buffer(*this, type, value_type, capacity));
+ return {new Buffer(*this, type, value_type, capacity)};
}
void
diff --git a/src/server/BufferFactory.hpp b/src/server/BufferFactory.hpp
index 19a61bed..657ce7d2 100644
--- a/src/server/BufferFactory.hpp
+++ b/src/server/BufferFactory.hpp
@@ -18,8 +18,8 @@
#define INGEN_ENGINE_BUFFERFACTORY_HPP
#include "ingen/URIs.hpp"
-#include "ingen/ingen.h"
#include "lv2/urid/urid.h"
+#include "server.h"
#include "BufferRef.hpp"
#include "types.hpp"
@@ -28,7 +28,9 @@
#include <cstdint>
#include <mutex>
-namespace raul { class Maid; }
+namespace raul {
+class Maid;
+} // namespace raul
namespace ingen {
@@ -39,7 +41,8 @@ namespace server {
class Buffer;
class Engine;
-class INGEN_API BufferFactory {
+class INGEN_SERVER_API BufferFactory
+{
public:
BufferFactory(Engine& engine, URIs& uris);
~BufferFactory();
@@ -82,29 +85,33 @@ private:
Buffer* try_get_buffer(LV2_URID type);
- inline std::atomic<Buffer*>& free_list(LV2_URID type) {
+ std::atomic<Buffer*>& free_list(LV2_URID type) {
if (type == _uris.atom_Float) {
return _free_control;
- } else if (type == _uris.atom_Sound) {
+ }
+
+ if (type == _uris.atom_Sound) {
return _free_audio;
- } else if (type == _uris.atom_Sequence) {
+ }
+
+ if (type == _uris.atom_Sequence) {
return _free_sequence;
- } else {
- return _free_object;
}
+
+ return _free_object;
}
static void free_list(Buffer* head);
- std::atomic<Buffer*> _free_audio;
- std::atomic<Buffer*> _free_control;
- std::atomic<Buffer*> _free_sequence;
- std::atomic<Buffer*> _free_object;
+ std::atomic<Buffer*> _free_audio{nullptr};
+ std::atomic<Buffer*> _free_control{nullptr};
+ std::atomic<Buffer*> _free_sequence{nullptr};
+ std::atomic<Buffer*> _free_object{nullptr};
std::mutex _mutex;
Engine& _engine;
URIs& _uris;
- uint32_t _seq_size;
+ uint32_t _seq_size{0};
BufferRef _silent_buffer;
};
diff --git a/src/server/BufferRef.hpp b/src/server/BufferRef.hpp
index 958fcb06..bb692001 100644
--- a/src/server/BufferRef.hpp
+++ b/src/server/BufferRef.hpp
@@ -17,7 +17,7 @@
#ifndef INGEN_ENGINE_BUFFER_REF_HPP
#define INGEN_ENGINE_BUFFER_REF_HPP
-#include "ingen/ingen.h"
+#include "server.h"
#include <boost/smart_ptr/intrusive_ptr.hpp> // IWYU pragma: export
@@ -29,8 +29,8 @@ class Buffer;
using BufferRef = boost::intrusive_ptr<Buffer>;
// Defined in Buffer.cpp
-INGEN_API void intrusive_ptr_add_ref(Buffer* b);
-INGEN_API void intrusive_ptr_release(Buffer* b);
+INGEN_SERVER_API void intrusive_ptr_add_ref(Buffer* b);
+INGEN_SERVER_API void intrusive_ptr_release(Buffer* b);
} // namespace server
} // namespace ingen
diff --git a/src/server/CompiledGraph.cpp b/src/server/CompiledGraph.cpp
index e644d982..f03187ae 100644
--- a/src/server/CompiledGraph.cpp
+++ b/src/server/CompiledGraph.cpp
@@ -37,13 +37,15 @@
#include <cstdio>
#include <exception>
#include <limits>
+#include <memory>
#include <utility>
namespace ingen {
namespace server {
/** Graph contains ambiguous feedback with no delay nodes. */
-class FeedbackException : public std::exception {
+class FeedbackException : public std::exception
+{
public:
explicit FeedbackException(const BlockImpl* n)
: node(n)
@@ -70,7 +72,7 @@ has_provider_with_many_dependants(const BlockImpl* n)
}
CompiledGraph::CompiledGraph(GraphImpl* graph)
- : _master(std::unique_ptr<Task>(new Task(Task::Mode::SEQUENTIAL)))
+ : _master{std::make_unique<Task>(Task::Mode::SEQUENTIAL)}
{
compile_graph(graph);
}
diff --git a/src/server/CompiledGraph.hpp b/src/server/CompiledGraph.hpp
index 8c2bb815..f33941aa 100644
--- a/src/server/CompiledGraph.hpp
+++ b/src/server/CompiledGraph.hpp
@@ -49,7 +49,7 @@ public:
void run(RunContext& ctx);
private:
- friend class raul::Maid; ///< Allow make_managed to construct
+ friend class raul::Maid; ///< Allow make_managed to construct
CompiledGraph(GraphImpl* graph);
diff --git a/src/server/ControlBindings.cpp b/src/server/ControlBindings.cpp
index 8bf52dfd..9b6b67bd 100644
--- a/src/server/ControlBindings.cpp
+++ b/src/server/ControlBindings.cpp
@@ -74,6 +74,12 @@ ControlBindings::port_binding(PortImpl* port) const
return binding_key(binding);
}
+static int16_t
+get_atom_num(const LV2_Atom* const atom)
+{
+ return static_cast<int16_t>(reinterpret_cast<const LV2_Atom_Int*>(atom)->body);
+}
+
ControlBindings::Key
ControlBindings::binding_key(const Atom& binding) const
{
@@ -83,9 +89,31 @@ ControlBindings::binding_key(const Atom& binding) const
if (binding.type() == uris.atom_Object) {
const auto* obj = static_cast<const LV2_Atom_Object_Body*>(binding.get_body());
if (obj->otype == uris.midi_Bender) {
- key = Key(Type::MIDI_BENDER);
+ lv2_atom_object_body_get(binding.size(),
+ obj,
+ uris.midi_channel.urid(),
+ &num,
+ nullptr);
+ if (!num) {
+ _engine.log().rt_error("Bender binding missing channel\n");
+ } else if (num->type != uris.atom_Int) {
+ _engine.log().rt_error("Bender channel not an integer\n");
+ } else {
+ key = Key(Type::MIDI_BENDER, get_atom_num(num));
+ }
} else if (obj->otype == uris.midi_ChannelPressure) {
- key = Key(Type::MIDI_CHANNEL_PRESSURE);
+ lv2_atom_object_body_get(binding.size(),
+ obj,
+ uris.midi_channel.urid(),
+ &num,
+ nullptr);
+ if (!num) {
+ _engine.log().rt_error("Pressure binding missing channel\n");
+ } else if (num->type != uris.atom_Int) {
+ _engine.log().rt_error("Pressure channel not an integer\n");
+ } else {
+ key = Key(Type::MIDI_CHANNEL_PRESSURE, get_atom_num(num));
+ }
} else if (obj->otype == uris.midi_Controller) {
lv2_atom_object_body_get(binding.size(),
obj,
@@ -97,7 +125,7 @@ ControlBindings::binding_key(const Atom& binding) const
} else if (num->type != uris.atom_Int) {
_engine.log().rt_error("Controller number not an integer\n");
} else {
- key = Key(Type::MIDI_CC, reinterpret_cast<LV2_Atom_Int*>(num)->body);
+ key = Key(Type::MIDI_CC, get_atom_num(num));
}
} else if (obj->otype == uris.midi_NoteOn) {
lv2_atom_object_body_get(binding.size(),
@@ -110,7 +138,7 @@ ControlBindings::binding_key(const Atom& binding) const
} else if (num->type != uris.atom_Int) {
_engine.log().rt_error("Note number not an integer\n");
} else {
- key = Key(Type::MIDI_NOTE, reinterpret_cast<LV2_Atom_Int*>(num)->body);
+ key = Key(Type::MIDI_NOTE, get_atom_num(num));
}
}
} else if (binding.type()) {
@@ -120,21 +148,28 @@ ControlBindings::binding_key(const Atom& binding) const
}
ControlBindings::Key
-ControlBindings::midi_event_key(uint16_t, const uint8_t* buf, uint16_t& value)
+ControlBindings::midi_event_key(const uint8_t* buf, uint16_t& value)
{
switch (lv2_midi_message_type(buf)) {
case LV2_MIDI_MSG_CONTROLLER:
- value = static_cast<int8_t>(buf[2]);
- return {Type::MIDI_CC, static_cast<int8_t>(buf[1])};
+ value = buf[2];
+ return {Type::MIDI_CC,
+ static_cast<int16_t>(((buf[0] & 0x0FU) << 8U) | buf[1])};
case LV2_MIDI_MSG_BENDER:
- value = (static_cast<int8_t>(buf[2]) << 7) + static_cast<int8_t>(buf[1]);
- return {Type::MIDI_BENDER};
+ value = static_cast<uint16_t>((buf[2] << 7U) + buf[1]);
+ return {Type::MIDI_BENDER, static_cast<int16_t>((buf[0] & 0x0FU))};
case LV2_MIDI_MSG_CHANNEL_PRESSURE:
- value = static_cast<int8_t>(buf[1]);
- return {Type::MIDI_CHANNEL_PRESSURE};
+ value = buf[1];
+ return {Type::MIDI_CHANNEL_PRESSURE,
+ static_cast<int16_t>((buf[0] & 0x0FU))};
case LV2_MIDI_MSG_NOTE_ON:
- value = 1.0f;
- return {Type::MIDI_NOTE, static_cast<int8_t>(buf[1])};
+ value = 1;
+ return {Type::MIDI_NOTE,
+ static_cast<int16_t>(((buf[0] & 0x0FU) << 8U) | buf[1])};
+ case LV2_MIDI_MSG_NOTE_OFF:
+ value = 0;
+ return {Type::MIDI_NOTE,
+ static_cast<int16_t>(((buf[0] & 0x0FU) << 8U) | buf[1])};
default:
return {};
}
@@ -152,9 +187,9 @@ ControlBindings::set_port_binding(RunContext&,
binding->port = port;
_bindings->insert(*binding);
return true;
- } else {
- return false;
}
+
+ return false;
}
void
@@ -173,7 +208,7 @@ ControlBindings::port_value_changed(RunContext& ctx,
case Type::MIDI_CC:
size = 3;
buf[0] = LV2_MIDI_MSG_CONTROLLER;
- buf[1] = key.num;
+ buf[1] = static_cast<uint8_t>(key.num);
buf[2] = static_cast<int8_t>(value);
break;
case Type::MIDI_CHANNEL_PRESSURE:
@@ -194,7 +229,7 @@ ControlBindings::port_value_changed(RunContext& ctx,
} else if (value == 0) {
buf[0] = LV2_MIDI_MSG_NOTE_OFF;
}
- buf[1] = key.num;
+ buf[1] = static_cast<uint8_t>(key.num);
buf[2] = 0x64; // MIDI spec default
break;
default:
@@ -297,9 +332,9 @@ ControlBindings::port_value_to_control(RunContext& ctx,
switch (type) {
case Type::MIDI_CC:
case Type::MIDI_CHANNEL_PRESSURE:
- return lrintf(normal * 127.0f);
+ return static_cast<int16_t>(lrintf(normal * 127.0f));
case Type::MIDI_BENDER:
- return lrintf(normal * 16383.0f);
+ return static_cast<int16_t>(lrintf(normal * 16383.0f));
case Type::MIDI_NOTE:
return (value > 0.0f) ? 1 : 0;
default:
@@ -322,9 +357,13 @@ forge_binding(const URIs& uris,
break;
case ControlBindings::Type::MIDI_BENDER:
lv2_atom_forge_object(forge, &frame, 0, uris.midi_Bender);
+ lv2_atom_forge_key(forge, uris.midi_channel);
+ lv2_atom_forge_int(forge, value);
break;
case ControlBindings::Type::MIDI_CHANNEL_PRESSURE:
lv2_atom_forge_object(forge, &frame, 0, uris.midi_ChannelPressure);
+ lv2_atom_forge_key(forge, uris.midi_channel);
+ lv2_atom_forge_int(forge, value);
break;
case ControlBindings::Type::MIDI_NOTE:
lv2_atom_forge_object(forge, &frame, 0, uris.midi_NoteOn);
@@ -411,22 +450,22 @@ ControlBindings::pre_process(RunContext& ctx, Buffer* buffer)
_feedback->clear();
if ((!_learn_binding && _bindings->empty()) || !buffer->get<LV2_Atom>()) {
- return; // Don't bother reading input
+ return; // Don't bother reading input
}
auto* seq = buffer->get<LV2_Atom_Sequence>();
- LV2_ATOM_SEQUENCE_FOREACH(seq, ev) {
+ LV2_ATOM_SEQUENCE_FOREACH (seq, ev) {
if (ev->body.type == uris.midi_MidiEvent) {
const auto* buf = static_cast<const uint8_t*>(LV2_ATOM_BODY(&ev->body));
- const Key key = midi_event_key(ev->body.size, buf, value);
+ const Key key = midi_event_key(buf, value);
if (_learn_binding && !!key) {
- finish_learn(ctx, key); // Learn new binding
+ finish_learn(ctx, key); // Learn new binding
}
// Set all controls bound to this key
const Binding k = {key, nullptr};
- for (Bindings::const_iterator i = _bindings->lower_bound(k);
+ for (auto i = _bindings->lower_bound(k);
i != _bindings->end() && i->key == key;
++i) {
set_port_value(ctx, i->port, key.type, value);
diff --git a/src/server/ControlBindings.hpp b/src/server/ControlBindings.hpp
index 1c231e22..d72fd2fd 100644
--- a/src/server/ControlBindings.hpp
+++ b/src/server/ControlBindings.hpp
@@ -30,7 +30,9 @@
#include <memory>
#include <vector>
-namespace raul { class Path; }
+namespace raul {
+class Path;
+} // namespace raul
namespace boost {
namespace intrusive {
@@ -51,7 +53,8 @@ class Engine;
class RunContext;
class PortImpl;
-class ControlBindings {
+class ControlBindings
+{
public:
enum class Type : uint16_t {
NULL_CONTROL,
@@ -64,15 +67,21 @@ public:
};
struct Key {
- Key(Type t=Type::NULL_CONTROL, int16_t n=0) : type(t), num(n) {}
- inline bool operator<(const Key& other) const {
+ Key(Type t = Type::NULL_CONTROL, int16_t n = 0) noexcept
+ : type(t), num(n)
+ {}
+
+ bool operator<(const Key& other) const {
return ((type < other.type) ||
(type == other.type && num < other.num));
}
- inline bool operator==(const Key& other) const {
+
+ bool operator==(const Key& other) const {
return type == other.type && num == other.num;
}
- inline bool operator!() const { return type == Type::NULL_CONTROL; }
+
+ bool operator!() const { return type == Type::NULL_CONTROL; }
+
Type type;
int16_t num;
};
@@ -82,7 +91,7 @@ public:
public raul::Maid::Disposable {
Binding(Key k=Key(), PortImpl* p=nullptr) : key(k), port(p) {}
- inline bool operator<(const Binding& rhs) const { return key < rhs.key; }
+ bool operator<(const Binding& rhs) const { return key < rhs.key; }
Key key;
PortImpl* port;
@@ -129,7 +138,7 @@ private:
boost::intrusive::compare<BindingLess>>;
static Key
- midi_event_key(uint16_t size, const uint8_t* buf, uint16_t& value);
+ midi_event_key(const uint8_t* buf, uint16_t& value);
void set_port_value(RunContext& ctx,
PortImpl* port,
diff --git a/src/server/DirectDriver.hpp b/src/server/DirectDriver.hpp
index 7c683493..48de44f9 100644
--- a/src/server/DirectDriver.hpp
+++ b/src/server/DirectDriver.hpp
@@ -51,7 +51,8 @@ class Buffer;
/** Driver for running Ingen directly as a library.
* \ingroup engine
*/
-class DirectDriver : public Driver {
+class DirectDriver : public Driver
+{
public:
DirectDriver(Engine& engine,
double sample_rate,
diff --git a/src/server/Driver.hpp b/src/server/Driver.hpp
index 1bc6213d..83436389 100644
--- a/src/server/Driver.hpp
+++ b/src/server/Driver.hpp
@@ -24,7 +24,9 @@
#include <cstddef>
-namespace raul { class Path; }
+namespace raul {
+class Path;
+} // namespace raul
namespace ingen {
@@ -44,7 +46,8 @@ class RunContext;
*
* \ingroup engine
*/
-class Driver : public raul::Noncopyable {
+class Driver : public raul::Noncopyable
+{
public:
virtual ~Driver() = default;
diff --git a/src/server/DuplexPort.cpp b/src/server/DuplexPort.cpp
index ce516b46..0c4c83e6 100644
--- a/src/server/DuplexPort.cpp
+++ b/src/server/DuplexPort.cpp
@@ -154,9 +154,12 @@ DuplexPort::get_buffers(BufferFactory& bufs,
{
if (!_is_driver_port && is_output()) {
return InputPort::get_buffers(bufs, get, voices, poly, num_in_arcs);
- } else if (!_is_driver_port && is_input()) {
+ }
+
+ if (!_is_driver_port && is_input()) {
return PortImpl::get_buffers(bufs, get, voices, poly, num_in_arcs);
}
+
return false;
}
@@ -165,9 +168,12 @@ DuplexPort::setup_buffers(RunContext& ctx, BufferFactory& bufs, uint32_t poly)
{
if (!_is_driver_port && is_output()) {
return InputPort::setup_buffers(ctx, bufs, poly);
- } else if (!_is_driver_port && is_input()) {
+ }
+
+ if (!_is_driver_port && is_input()) {
return PortImpl::setup_buffers(ctx, bufs, poly);
}
+
return false;
}
diff --git a/src/server/DuplexPort.hpp b/src/server/DuplexPort.hpp
index cdd764a0..3cc0efba 100644
--- a/src/server/DuplexPort.hpp
+++ b/src/server/DuplexPort.hpp
@@ -20,10 +20,10 @@
#include "InputPort.hpp"
#include "PortImpl.hpp"
#include "PortType.hpp"
+#include "server.h"
#include "types.hpp"
#include "ingen/URI.hpp"
-#include "ingen/ingen.h"
#include "lv2/urid/urid.h"
#include "raul/Maid.hpp"
@@ -32,7 +32,9 @@
#include <cstddef>
#include <cstdint>
-namespace raul { class Symbol; }
+namespace raul {
+class Symbol;
+} // namespace raul
namespace ingen {
@@ -55,7 +57,7 @@ class RunContext;
*
* \ingroup engine
*/
-class INGEN_API DuplexPort final
+class INGEN_SERVER_API DuplexPort final
: public InputPort
, public boost::intrusive::slist_base_hook<> // In GraphImpl
{
diff --git a/src/server/Engine.cpp b/src/server/Engine.cpp
index b48b291f..613def62 100644
--- a/src/server/Engine.cpp
+++ b/src/server/Engine.cpp
@@ -39,7 +39,7 @@
#include "events/CreateGraph.hpp"
#include "ingen_config.h"
-#ifdef HAVE_SOCKET
+#if USE_SOCKET
#include "SocketListener.hpp"
#endif
@@ -98,14 +98,8 @@ Engine::Engine(ingen::World& world)
, _interface(_event_writer)
, _atom_interface(
new AtomReader(world.uri_map(), world.uris(), world.log(), *_interface))
- , _root_graph(nullptr)
- , _cycle_start_time(0)
, _rand_engine(reinterpret_cast<uintptr_t>(this))
- , _uniform_dist(0.0f, 1.0f)
- , _quit_flag(false)
- , _reset_load_flag(false)
, _atomic_bundles(world.conf().option("atomic-bundles").get<int32_t>())
- , _activated(false)
{
if (!world.store()) {
world.set_store(std::make_shared<ingen::Store>());
@@ -187,7 +181,7 @@ Engine::~Engine()
void
Engine::listen()
{
-#ifdef HAVE_SOCKET
+#if USE_SOCKET
_listener = std::make_unique<SocketListener>(*this);
#endif
}
diff --git a/src/server/Engine.hpp b/src/server/Engine.hpp
index b5b6a311..d224d5b5 100644
--- a/src/server/Engine.hpp
+++ b/src/server/Engine.hpp
@@ -19,12 +19,12 @@
#include "Event.hpp"
#include "Load.hpp"
+#include "server.h"
#include "types.hpp"
#include "ingen/Clock.hpp"
#include "ingen/EngineBase.hpp"
#include "ingen/Properties.hpp"
-#include "ingen/ingen.h"
#include <chrono>
#include <condition_variable>
@@ -75,7 +75,7 @@ class Worker;
@ingroup engine
*/
-class INGEN_API Engine final : public EngineBase
+class INGEN_SERVER_API Engine final : public EngineBase
{
public:
explicit Engine(ingen::World& world);
@@ -114,7 +114,7 @@ public:
*
* This value is comparable to the value returned by current_time().
*/
- inline uint64_t cycle_start_time(const RunContext&) const {
+ uint64_t cycle_start_time(const RunContext&) const {
return _cycle_start_time;
}
@@ -199,24 +199,24 @@ private:
std::shared_ptr<EventWriter> _event_writer;
std::shared_ptr<Interface> _interface;
std::unique_ptr<AtomReader> _atom_interface;
- GraphImpl* _root_graph;
+ GraphImpl* _root_graph{nullptr};
std::vector<std::unique_ptr<raul::RingBuffer>> _notifications;
std::vector<std::unique_ptr<RunContext>> _run_contexts;
- uint64_t _cycle_start_time;
+ uint64_t _cycle_start_time{0};
Load _run_load;
Clock _clock;
std::mt19937 _rand_engine;
- std::uniform_real_distribution<float> _uniform_dist;
+ std::uniform_real_distribution<float> _uniform_dist{0.0f, 1.0f};
std::condition_variable _tasks_available;
std::mutex _tasks_mutex;
- bool _quit_flag;
- bool _reset_load_flag;
+ bool _quit_flag{false};
+ bool _reset_load_flag{false};
bool _atomic_bundles;
- bool _activated;
+ bool _activated{false};
};
} // namespace server
diff --git a/src/server/EnginePort.hpp b/src/server/EnginePort.hpp
index ecfe59b3..d6e67f1e 100644
--- a/src/server/EnginePort.hpp
+++ b/src/server/EnginePort.hpp
@@ -40,9 +40,6 @@ class EnginePort : public raul::Noncopyable
public:
explicit EnginePort(DuplexPort* port)
: _graph_port(port)
- , _buffer(nullptr)
- , _handle(nullptr)
- , _driver_index(0)
{}
void set_buffer(void* buf) { _buffer = buf; }
@@ -57,9 +54,9 @@ public:
protected:
DuplexPort* _graph_port;
- void* _buffer;
- void* _handle;
- uint32_t _driver_index;
+ void* _buffer{nullptr};
+ void* _handle{nullptr};
+ uint32_t _driver_index{0};
};
} // namespace server
diff --git a/src/server/Event.hpp b/src/server/Event.hpp
index e00aa0d1..68b66c86 100644
--- a/src/server/Event.hpp
+++ b/src/server/Event.hpp
@@ -63,10 +63,10 @@ public:
/** Execution mode for events that block and unblock preprocessing. */
enum class Execution {
- NORMAL, ///< Normal pipelined execution
- ATOMIC, ///< Block pre-processing until this event is executed
- BLOCK, ///< Begin atomic block of events
- UNBLOCK ///< Finish atomic executed block of events
+ NORMAL, ///< Normal pipelined execution
+ ATOMIC, ///< Block pre-processing until this event is executed
+ BLOCK, ///< Begin atomic block of events
+ UNBLOCK ///< Finish atomic executed block of events
};
/** Claim position in undo stack before pre-processing (non-realtime). */
@@ -85,13 +85,13 @@ public:
virtual void undo(Interface& target) {}
/** Return true iff this event has been pre-processed. */
- inline bool is_prepared() const { return _status != Status::NOT_PREPARED; }
+ bool is_prepared() const { return _status != Status::NOT_PREPARED; }
/** Return the time stamp of this event. */
- inline SampleCount time() const { return _time; }
+ SampleCount time() const { return _time; }
/** Set the time stamp of this event. */
- inline void set_time(SampleCount time) { _time = time; }
+ void set_time(SampleCount time) { _time = time; }
/** Get the next event to be processed after this one. */
Event* next() const { return _next.load(); }
@@ -111,10 +111,13 @@ public:
/** Set the undo mode of this event. */
void set_mode(Mode mode) { _mode = mode; }
- inline Engine& engine() { return _engine; }
+ Engine& engine() { return _engine; }
protected:
- Event(Engine& engine, std::shared_ptr<Interface> client, int32_t id, FrameTime time)
+ Event(Engine& engine,
+ std::shared_ptr<Interface> client,
+ int32_t id,
+ FrameTime time) noexcept
: _engine(engine)
, _next(nullptr)
, _request_client(std::move(client))
@@ -134,22 +137,22 @@ protected:
, _mode(Mode::NORMAL)
{}
- inline bool pre_process_done(Status st) {
+ bool pre_process_done(Status st) {
_status = st;
return st == Status::SUCCESS;
}
- inline bool pre_process_done(Status st, const URI& subject) {
+ bool pre_process_done(Status st, const URI& subject) {
_err_subject = subject;
return pre_process_done(st);
}
- inline bool pre_process_done(Status st, const raul::Path& subject) {
+ bool pre_process_done(Status st, const raul::Path& subject) {
return pre_process_done(st, path_to_uri(subject));
}
/** Respond to the originating client. */
- inline Status respond() {
+ Status respond() {
if (_request_client && _request_id) {
_request_client->response(_request_id, _status, _err_subject);
}
diff --git a/src/server/EventWriter.cpp b/src/server/EventWriter.cpp
index 9001b01a..e9fb56a6 100644
--- a/src/server/EventWriter.cpp
+++ b/src/server/EventWriter.cpp
@@ -36,9 +36,7 @@ namespace server {
EventWriter::EventWriter(Engine& engine)
: _engine(engine)
- , _event_mode(Event::Mode::NORMAL)
-{
-}
+{}
SampleCount
EventWriter::now() const
diff --git a/src/server/EventWriter.hpp b/src/server/EventWriter.hpp
index 184cefb7..a71242c1 100644
--- a/src/server/EventWriter.hpp
+++ b/src/server/EventWriter.hpp
@@ -62,19 +62,19 @@ public:
void operator()(const Delta&);
void operator()(const Disconnect&);
void operator()(const DisconnectAll&);
- void operator()(const Error&) {}
+ void operator()(const Error&) noexcept {}
void operator()(const Get&);
void operator()(const Move&);
void operator()(const Put&);
void operator()(const Redo&);
- void operator()(const Response&) {}
+ void operator()(const Response&) noexcept {}
void operator()(const SetProperty&);
void operator()(const Undo&);
protected:
Engine& _engine;
std::shared_ptr<Interface> _respondee;
- Event::Mode _event_mode;
+ Event::Mode _event_mode{Event::Mode::NORMAL};
private:
SampleCount now() const;
diff --git a/src/server/FrameTimer.hpp b/src/server/FrameTimer.hpp
index 8a155777..dfa5c46b 100644
--- a/src/server/FrameTimer.hpp
+++ b/src/server/FrameTimer.hpp
@@ -43,8 +43,7 @@ public:
, b(sqrt(2) * omega)
, c(omega * omega)
, nper(period_size)
- {
- }
+ {}
/** Update the timer for current real time `usec` and frame `frame`. */
void update(uint64_t usec, uint64_t frame) {
diff --git a/src/server/GraphImpl.cpp b/src/server/GraphImpl.cpp
index a668312d..1ed6c37f 100644
--- a/src/server/GraphImpl.cpp
+++ b/src/server/GraphImpl.cpp
@@ -61,7 +61,6 @@ GraphImpl::GraphImpl(Engine& engine,
, _engine(engine)
, _poly_pre(internal_poly)
, _poly_process(internal_poly)
- , _process(false)
{
assert(internal_poly >= 1);
assert(internal_poly <= 128);
@@ -123,7 +122,7 @@ GraphImpl::duplicate(Engine& engine,
}
// Add duplicates of all arcs
- for (const auto& a : _arcs) {
+ for (const auto& a : _graph_arcs) {
auto arc = std::dynamic_pointer_cast<ArcImpl>(a.second);
if (arc) {
auto t = port_map.find(arc->tail());
@@ -286,29 +285,29 @@ void
GraphImpl::add_arc(const std::shared_ptr<ArcImpl>& a)
{
ThreadManager::assert_thread(THREAD_PRE_PROCESS);
- _arcs.emplace(std::make_pair(a->tail(), a->head()), a);
+ _graph_arcs.emplace(std::make_pair(a->tail(), a->head()), a);
}
std::shared_ptr<ArcImpl>
GraphImpl::remove_arc(const PortImpl* tail, const PortImpl* dst_port)
{
ThreadManager::assert_thread(THREAD_PRE_PROCESS);
- auto i = _arcs.find(std::make_pair(tail, dst_port));
- if (i != _arcs.end()) {
+ auto i = _graph_arcs.find(std::make_pair(tail, dst_port));
+ if (i != _graph_arcs.end()) {
auto arc = std::dynamic_pointer_cast<ArcImpl>(i->second);
- _arcs.erase(i);
+ _graph_arcs.erase(i);
return arc;
- } else {
- return nullptr;
}
+
+ return nullptr;
}
bool
GraphImpl::has_arc(const PortImpl* tail, const PortImpl* dst_port) const
{
ThreadManager::assert_thread(THREAD_PRE_PROCESS);
- auto i = _arcs.find(std::make_pair(tail, dst_port));
- return (i != _arcs.end());
+ auto i = _graph_arcs.find(std::make_pair(tail, dst_port));
+ return (i != _graph_arcs.end());
}
void
diff --git a/src/server/GraphImpl.hpp b/src/server/GraphImpl.hpp
index cbbd57de..3746961a 100644
--- a/src/server/GraphImpl.hpp
+++ b/src/server/GraphImpl.hpp
@@ -20,6 +20,7 @@
#include "BlockImpl.hpp"
#include "DuplexPort.hpp"
#include "ThreadManager.hpp"
+#include "server.h"
#include "types.hpp"
#include "ingen/Node.hpp"
@@ -63,7 +64,7 @@ class RunContext;
*
* \ingroup engine
*/
-class GraphImpl final : public BlockImpl
+class INGEN_SERVER_API GraphImpl final : public BlockImpl
{
public:
GraphImpl(Engine& engine,
@@ -203,14 +204,16 @@ public:
Engine& engine() { return _engine; }
private:
- Engine& _engine;
- uint32_t _poly_pre; ///< Pre-process thread only
- uint32_t _poly_process; ///< Process thread only
- raul::managed_ptr<CompiledGraph> _compiled_graph; ///< Process thread only
- PortList _inputs; ///< Pre-process thread only
- PortList _outputs; ///< Pre-process thread only
- Blocks _blocks; ///< Pre-process thread only
- bool _process; ///< True iff graph is enabled
+ using CompiledGraphPtr = raul::managed_ptr<CompiledGraph>;
+
+ Engine& _engine;
+ uint32_t _poly_pre; ///< Pre-process thread only
+ uint32_t _poly_process; ///< Process thread only
+ CompiledGraphPtr _compiled_graph; ///< Process thread only
+ PortList _inputs; ///< Pre-process thread only
+ PortList _outputs; ///< Pre-process thread only
+ Blocks _blocks; ///< Pre-process thread only
+ bool _process{false}; ///< True iff graph is enabled
};
} // namespace server
diff --git a/src/server/InputPort.cpp b/src/server/InputPort.cpp
index 10a525cc..8547dc35 100644
--- a/src/server/InputPort.cpp
+++ b/src/server/InputPort.cpp
@@ -50,7 +50,6 @@ InputPort::InputPort(BufferFactory& bufs,
const Atom& value,
size_t buffer_size)
: PortImpl(bufs, parent, symbol, index, poly, type, buffer_type, value, buffer_size, false)
- , _num_arcs(0)
{
const ingen::URIs& uris = bufs.uris();
diff --git a/src/server/InputPort.hpp b/src/server/InputPort.hpp
index 9357c3ff..72040a49 100644
--- a/src/server/InputPort.hpp
+++ b/src/server/InputPort.hpp
@@ -30,7 +30,9 @@
#include <cstdint>
#include <cstdlib>
-namespace raul { class Symbol; }
+namespace raul {
+class Symbol;
+} // namespace raul
namespace boost {
namespace intrusive {
@@ -136,8 +138,8 @@ protected:
uint32_t poly,
size_t num_in_arcs) const override;
- size_t _num_arcs; ///< Pre-process thread
- Arcs _arcs; ///< Audio thread
+ size_t _num_arcs{0}; ///< Pre-process thread
+ Arcs _arcs; ///< Audio thread
};
} // namespace server
diff --git a/src/server/InternalPlugin.cpp b/src/server/InternalPlugin.cpp
index 0355ff1e..6c188c5e 100644
--- a/src/server/InternalPlugin.cpp
+++ b/src/server/InternalPlugin.cpp
@@ -51,21 +51,29 @@ InternalPlugin::instantiate(BufferFactory& bufs,
if (uri() == NS_INTERNALS "BlockDelay") {
return new internals::BlockDelayNode(
this, bufs, symbol, polyphonic, parent, srate);
- } else if (uri() == NS_INTERNALS "Controller") {
+ }
+
+ if (uri() == NS_INTERNALS "Controller") {
return new internals::ControllerNode(
this, bufs, symbol, polyphonic, parent, srate);
- } else if (uri() == NS_INTERNALS "Note") {
+ }
+
+ if (uri() == NS_INTERNALS "Note") {
return new internals::NoteNode(
this, bufs, symbol, polyphonic, parent, srate);
- } else if (uri() == NS_INTERNALS "Time") {
+ }
+
+ if (uri() == NS_INTERNALS "Time") {
return new internals::TimeNode(
this, bufs, symbol, polyphonic, parent, srate);
- } else if (uri() == NS_INTERNALS "Trigger") {
+ }
+
+ if (uri() == NS_INTERNALS "Trigger") {
return new internals::TriggerNode(
this, bufs, symbol, polyphonic, parent, srate);
- } else {
- return nullptr;
}
+
+ return nullptr;
}
} // namespace server
diff --git a/src/server/JackDriver.cpp b/src/server/JackDriver.cpp
index f03689cb..32029c6e 100644
--- a/src/server/JackDriver.cpp
+++ b/src/server/JackDriver.cpp
@@ -44,7 +44,7 @@
#include <jack/midiport.h>
#include <jack/transport.h>
-#ifdef HAVE_JACK_METADATA
+#if USE_JACK_METADATA
#include "jackey.h"
#include <jack/metadata.h>
#endif
@@ -61,22 +61,10 @@ namespace ingen {
namespace server {
JackDriver::JackDriver(Engine& engine)
- : _engine(engine)
- , _forge()
- , _sem(0)
- , _flag(false)
- , _client(nullptr)
- , _block_length(0)
- , _seq_size(0)
- , _sample_rate(0)
- , _is_activated(false)
- , _position()
- , _transport_state()
- , _old_bpm(120.0)
- , _old_frame(0)
- , _old_rolling(false)
+ : _engine(engine)
+ , _forge()
+ , _midi_event_type(_engine.world().uris().midi_MidiEvent)
{
- _midi_event_type = _engine.world().uris().midi_MidiEvent;
lv2_atom_forge_init(&_forge, &engine.world().uri_map().urid_map());
}
@@ -102,7 +90,7 @@ JackDriver::attach(const std::string& server_name,
}
}
- // Either server name not specified, or supplied server name does not exist
+ // Server name not specified, or that server doesn't exist
// Connect to default server
if (!_client) {
if ((_client = jack_client_open(client_name.c_str(), JackNullOption, nullptr))) {
@@ -165,10 +153,10 @@ JackDriver::activate()
if (jack_activate(_client)) {
_engine.log().error("Could not activate Jack client, aborting\n");
return false;
- } else {
- _engine.log().info("Activated Jack client `%1%'\n",
- world.conf().option("jack-name").ptr<char>());
}
+
+ _engine.log().info("Activated Jack client `%1%'\n",
+ world.conf().option("jack-name").ptr<char>());
return true;
}
@@ -271,7 +259,7 @@ JackDriver::rename_port(const raul::Path& old_path,
{
EnginePort* eport = get_port(old_path);
if (eport) {
-#ifdef HAVE_JACK_PORT_RENAME
+#if USE_JACK_PORT_RENAME
jack_port_rename(_client,
static_cast<jack_port_t*>(eport->handle()),
new_path.substr(1).c_str());
@@ -287,7 +275,7 @@ JackDriver::port_property(const raul::Path& path,
const URI& uri,
const Atom& value)
{
-#ifdef HAVE_JACK_METADATA
+#if USE_JACK_METADATA
EnginePort* eport = get_port(path);
if (eport) {
const auto* const jport =
@@ -303,7 +291,7 @@ JackDriver::port_property_internal(const jack_port_t* jport,
const URI& uri,
const Atom& value)
{
-#ifdef HAVE_JACK_METADATA
+#if USE_JACK_METADATA
if (uri == _engine.world().uris().lv2_name) {
jack_set_property(_client, jack_port_uuid(jport),
JACK_METADATA_PRETTY_NAME, value.ptr<char>(), "text/plain");
@@ -398,7 +386,7 @@ JackDriver::post_process_port(RunContext& ctx, EnginePort* port) const
auto* seq = graph_buf->get<LV2_Atom_Sequence>();
jack_midi_clear_buffer(jack_buf);
- LV2_ATOM_SEQUENCE_FOREACH(seq, ev) {
+ LV2_ATOM_SEQUENCE_FOREACH (seq, ev) {
const auto* buf =
static_cast<const uint8_t*>(LV2_ATOM_BODY(&ev->body));
diff --git a/src/server/JackDriver.hpp b/src/server/JackDriver.hpp
index d4ea03d0..7a1dd2e0 100644
--- a/src/server/JackDriver.hpp
+++ b/src/server/JackDriver.hpp
@@ -96,8 +96,8 @@ public:
/** Transport state for this frame.
* Intended to only be called from the audio thread. */
- inline const jack_position_t* position() { return &_position; }
- inline jack_transport_state_t transport_state() { return _transport_state; }
+ const jack_position_t* position() { return &_position; }
+ jack_transport_state_t transport_state() { return _transport_state; }
void append_time_events(RunContext& ctx, Buffer& buffer) override;
@@ -114,7 +114,8 @@ public:
return _client ? jack_frame_time(_client) : 0;
}
- class PortRegistrationFailedException : public std::exception {};
+ class PortRegistrationFailedException : public std::exception
+ {};
private:
friend class JackPort;
@@ -122,16 +123,21 @@ private:
static void thread_init_cb(void* jack_driver);
// Static JACK callbacks which call the non-static callbacks (methods)
- inline static void shutdown_cb(void* const jack_driver) {
+
+ static void shutdown_cb(void* const jack_driver) {
return static_cast<JackDriver*>(jack_driver)->_shutdown_cb();
}
- inline static int process_cb(jack_nframes_t nframes, void* const jack_driver) {
+
+ static int process_cb(jack_nframes_t nframes, void* const jack_driver) {
return static_cast<JackDriver*>(jack_driver)->_process_cb(nframes);
}
- inline static int block_length_cb(jack_nframes_t nframes, void* const jack_driver) {
+
+ static int block_length_cb(jack_nframes_t nframes, void* const jack_driver) {
return static_cast<JackDriver*>(jack_driver)->_block_length_cb(nframes);
}
+ // Internal methods for processing
+
void pre_process_port(RunContext& ctx, EnginePort* port);
void post_process_port(RunContext& ctx, EnginePort* port) const;
@@ -154,19 +160,19 @@ protected:
Ports _ports;
AudioBufPtr _fallback_buffer;
LV2_Atom_Forge _forge;
- raul::Semaphore _sem;
- std::atomic<bool> _flag;
- jack_client_t* _client;
- jack_nframes_t _block_length;
- size_t _seq_size;
- jack_nframes_t _sample_rate;
+ raul::Semaphore _sem{0};
+ std::atomic<bool> _flag{false};
+ jack_client_t* _client{nullptr};
+ jack_nframes_t _block_length{0};
+ size_t _seq_size{0};
+ jack_nframes_t _sample_rate{0};
uint32_t _midi_event_type;
- bool _is_activated;
- jack_position_t _position;
- jack_transport_state_t _transport_state;
- double _old_bpm;
- jack_nframes_t _old_frame;
- bool _old_rolling;
+ bool _is_activated{false};
+ jack_position_t _position{};
+ jack_transport_state_t _transport_state{};
+ double _old_bpm{120.0};
+ jack_nframes_t _old_frame{0};
+ bool _old_rolling{false};
};
} // namespace server
diff --git a/src/server/LV2Block.cpp b/src/server/LV2Block.cpp
index 026b7d06..4cdcecd7 100644
--- a/src/server/LV2Block.cpp
+++ b/src/server/LV2Block.cpp
@@ -14,12 +14,13 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "LV2Block.hpp"
+
#include "Buffer.hpp"
#include "BufferFactory.hpp"
#include "Engine.hpp"
#include "GraphImpl.hpp"
#include "InputPort.hpp"
-#include "LV2Block.hpp"
#include "LV2Plugin.hpp"
#include "OutputPort.hpp"
#include "PortImpl.hpp"
@@ -70,7 +71,6 @@ LV2Block::LV2Block(LV2Plugin* plugin,
SampleRate srate)
: BlockImpl(plugin, symbol, polyphonic, parent, srate)
, _lv2_plugin(plugin)
- , _worker_iface(nullptr)
{
assert(_lv2_plugin);
}
@@ -271,7 +271,7 @@ LV2Block::instantiate(BufferFactory& bufs, const LilvState* state)
is_morph = true;
LilvNodes* types = lilv_port_get_value(
plug, id, uris.morph_supportsType);
- LILV_FOREACH(nodes, i, types) {
+ LILV_FOREACH (nodes, i, types) {
const LilvNode* type = lilv_nodes_get(types, i);
if (lilv_node_equals(type, uris.lv2_CVPort)) {
port_type = PortType::CV;
@@ -302,7 +302,7 @@ LV2Block::instantiate(BufferFactory& bufs, const LilvState* state)
if (!buffer_type) {
LilvNodes* types = lilv_port_get_value(
plug, id, uris.atom_bufferType);
- LILV_FOREACH(nodes, i, types) {
+ LILV_FOREACH (nodes, i, types) {
const LilvNode* type = lilv_nodes_get(types, i);
if (lilv_node_is_uri(type)) {
buffer_type = world.uri_map().map_uri(
@@ -327,7 +327,7 @@ LV2Block::instantiate(BufferFactory& bufs, const LilvState* state)
if (port_type == PortType::ATOM) {
// Get default value, and its length
LilvNodes* defaults = lilv_port_get_value(plug, id, uris.lv2_default);
- LILV_FOREACH(nodes, i, defaults) {
+ LILV_FOREACH (nodes, i, defaults) {
const LilvNode* d = lilv_nodes_get(defaults, i);
if (lilv_node_is_string(d)) {
const char* str_val = lilv_node_as_string(d);
@@ -347,7 +347,7 @@ LV2Block::instantiate(BufferFactory& bufs, const LilvState* state)
// Get minimum size, if set in data
LilvNodes* sizes = lilv_port_get_value(plug, id, uris.rsz_minimumSize);
- LILV_FOREACH(nodes, i, sizes) {
+ LILV_FOREACH (nodes, i, sizes) {
const LilvNode* d = lilv_nodes_get(sizes, i);
if (lilv_node_is_int(d)) {
uint32_t size_val = lilv_node_as_int(d);
@@ -415,7 +415,7 @@ LV2Block::instantiate(BufferFactory& bufs, const LilvState* state)
nullptr };
for (int p = 0; preds[p]; ++p) {
LilvNodes* values = lilv_port_get_value(plug, id, preds[p]);
- LILV_FOREACH(nodes, v, values) {
+ LILV_FOREACH (nodes, v, values) {
const LilvNode* value = lilv_nodes_get(values, v);
if (lilv_node_is_uri(value)) {
port->add_property(URI(lilv_node_as_uri(preds[p])),
@@ -497,7 +497,9 @@ LV2Block::save_state(const FilePath& dir) const
if (!state) {
return false;
- } else if (lilv_state_get_num_properties(state.get()) == 0) {
+ }
+
+ if (lilv_state_get_num_properties(state.get()) == 0) {
return false;
}
@@ -729,7 +731,7 @@ LV2Block::save_preset(const URI& uri,
nullptr)};
if (state) {
- const Properties::const_iterator l = props.find(_uris.rdfs_label);
+ const auto l = props.find(_uris.rdfs_label);
if (l != props.end() && l->second.type() == _uris.atom_String) {
lilv_state_set_label(state.get(), l->second.ptr<char>());
}
@@ -756,7 +758,7 @@ LV2Block::save_preset(const URI& uri,
return {preset};
}
- return boost::optional<Resource>();
+ return {};
}
void
diff --git a/src/server/LV2Block.hpp b/src/server/LV2Block.hpp
index c8f9e59a..9e907ffa 100644
--- a/src/server/LV2Block.hpp
+++ b/src/server/LV2Block.hpp
@@ -125,7 +125,7 @@ public:
protected:
struct Instance : public raul::Noncopyable {
- explicit Instance(LilvInstance* i) : instance(i) {}
+ explicit Instance(LilvInstance* i) noexcept : instance(i) {}
~Instance() { lilv_instance_free(instance); }
@@ -151,9 +151,8 @@ protected:
struct Response : public raul::Maid::Disposable
, public raul::Noncopyable
- , public boost::intrusive::slist_base_hook<>
- {
- inline Response(uint32_t s, const void* d)
+ , public boost::intrusive::slist_base_hook<> {
+ Response(uint32_t s, const void* d)
: size(s)
, data(malloc(s))
{
@@ -179,7 +178,7 @@ protected:
LV2Plugin* _lv2_plugin;
raul::managed_ptr<Instances> _instances;
raul::managed_ptr<Instances> _prepared_instances;
- const LV2_Worker_Interface* _worker_iface;
+ const LV2_Worker_Interface* _worker_iface{nullptr};
std::mutex _work_mutex;
Responses _responses;
std::shared_ptr<LV2Features::FeatureArray> _features;
diff --git a/src/server/LV2Options.hpp b/src/server/LV2Options.hpp
index 2ae1c6d7..02824be6 100644
--- a/src/server/LV2Options.hpp
+++ b/src/server/LV2Options.hpp
@@ -34,7 +34,8 @@ class World;
namespace server {
-class LV2Options : public ingen::LV2Features::Feature {
+class LV2Options : public ingen::LV2Features::Feature
+{
public:
explicit LV2Options(const URIs& uris)
: _uris(uris)
@@ -65,7 +66,7 @@ public:
f->URI = LV2_OPTIONS__options;
f->data = malloc(sizeof(options));
memcpy(f->data, options, sizeof(options));
- return std::shared_ptr<LV2_Feature>(f, &free_feature);
+ return {f, &free_feature};
}
private:
diff --git a/src/server/LV2Plugin.cpp b/src/server/LV2Plugin.cpp
index 7a43ba67..98234746 100644
--- a/src/server/LV2Plugin.cpp
+++ b/src/server/LV2Plugin.cpp
@@ -79,9 +79,9 @@ LV2Plugin::symbol() const
if ( (symbol[0] >= 'a' && symbol[0] <= 'z')
|| (symbol[0] >= 'A' && symbol[0] <= 'Z') ) {
return raul::Symbol::symbolify(symbol);
- } else {
- working = working.substr(0, last_slash);
}
+
+ working = working.substr(0, last_slash);
}
return raul::Symbol("lv2_symbol");
@@ -101,9 +101,9 @@ LV2Plugin::instantiate(BufferFactory& bufs,
if (!b->instantiate(bufs, state)) {
delete b;
return nullptr;
- } else {
- return b;
}
+
+ return b;
}
void
@@ -114,7 +114,7 @@ LV2Plugin::load_presets()
LilvNodes* presets = lilv_plugin_get_related(_lilv_plugin, uris.pset_Preset);
if (presets) {
- LILV_FOREACH(nodes, i, presets) {
+ LILV_FOREACH (nodes, i, presets) {
const LilvNode* preset = lilv_nodes_get(presets, i);
lilv_world_load_resource(lworld, preset);
diff --git a/src/server/Load.hpp b/src/server/Load.hpp
index f69d0659..4a30dd58 100644
--- a/src/server/Load.hpp
+++ b/src/server/Load.hpp
@@ -24,8 +24,7 @@
namespace ingen {
namespace server {
-struct Load
-{
+struct Load {
void update(uint64_t time, uint64_t available) {
const uint64_t load = time * 100 / available;
if (load < min) {
diff --git a/src/server/NodeImpl.cpp b/src/server/NodeImpl.cpp
index d914ae1c..499300a2 100644
--- a/src/server/NodeImpl.cpp
+++ b/src/server/NodeImpl.cpp
@@ -37,8 +37,7 @@ NodeImpl::NodeImpl(const ingen::URIs& uris,
, _parent(parent)
, _path(parent ? parent->path().child(symbol) : raul::Path("/"))
, _symbol(symbol)
-{
-}
+{}
const Atom&
NodeImpl::get_property(const URI& key) const
diff --git a/src/server/PluginImpl.hpp b/src/server/PluginImpl.hpp
index 3d7d596f..3184be11 100644
--- a/src/server/PluginImpl.hpp
+++ b/src/server/PluginImpl.hpp
@@ -48,10 +48,7 @@ public:
PluginImpl(ingen::URIs& uris, const Atom& type, const URI& uri)
: Resource(uris, uri)
, _type(type)
- , _presets_loaded(false)
- , _is_zombie(false)
- {
- }
+ {}
PluginImpl(const PluginImpl&) = delete;
PluginImpl& operator=(const PluginImpl&) = delete;
@@ -90,8 +87,8 @@ public:
protected:
Atom _type;
Presets _presets;
- bool _presets_loaded;
- bool _is_zombie;
+ bool _presets_loaded{false};
+ bool _is_zombie{false};
};
} // namespace server
diff --git a/src/server/PortAudioDriver.cpp b/src/server/PortAudioDriver.cpp
index fcb9cf67..c80b25f3 100644
--- a/src/server/PortAudioDriver.cpp
+++ b/src/server/PortAudioDriver.cpp
@@ -14,10 +14,11 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "PortAudioDriver.hpp"
+
#include "DuplexPort.hpp"
#include "Engine.hpp"
#include "FrameTimer.hpp"
-#include "PortAudioDriver.hpp"
#include "PortType.hpp"
#include "RunContext.hpp"
#include "ingen/Atom.hpp"
@@ -47,17 +48,8 @@ PortAudioDriver::PortAudioDriver(Engine& engine)
: _engine(engine)
, _inputParameters()
, _outputParameters()
- , _sem(0)
- , _stream(nullptr)
- , _seq_size(4096)
, _block_length(engine.world().conf().option("buffer-size").get<int32_t>())
- , _sample_rate(48000)
- , _n_inputs(0)
- , _n_outputs(0)
- , _flag(false)
- , _is_activated(false)
-{
-}
+{}
PortAudioDriver::~PortAudioDriver()
{
@@ -78,7 +70,9 @@ PortAudioDriver::attach()
_outputParameters.device = Pa_GetDefaultOutputDevice();
if (_inputParameters.device == paNoDevice) {
return pa_error("No default input device", paDeviceUnavailable);
- } else if (_outputParameters.device == paNoDevice) {
+ }
+
+ if (_outputParameters.device == paNoDevice) {
return pa_error("No default output device", paDeviceUnavailable);
}
@@ -91,8 +85,7 @@ PortAudioDriver::attach()
_sample_rate = in_dev->defaultSampleRate;
- _timer = std::unique_ptr<FrameTimer>(
- new FrameTimer(_block_length, _sample_rate));
+ _timer = std::make_unique<FrameTimer>(_block_length, _sample_rate);
return true;
}
@@ -184,26 +177,22 @@ PortAudioDriver::remove_port(RunContext&, EnginePort* port)
void
PortAudioDriver::register_port(EnginePort& port)
-{
-}
+{}
void
PortAudioDriver::unregister_port(EnginePort& port)
-{
-}
+{}
void
PortAudioDriver::rename_port(const raul::Path& old_path,
const raul::Path& new_path)
-{
-}
+{}
void
PortAudioDriver::port_property(const raul::Path& path,
const URI& uri,
const Atom& value)
-{
-}
+{}
EnginePort*
PortAudioDriver::create_port(DuplexPort* graph_port)
@@ -265,8 +254,7 @@ PortAudioDriver::post_process_port(RunContext&,
EnginePort* port,
const void* inputs,
void* outputs)
-{
-}
+{}
int
PortAudioDriver::process_cb(const void* inputs,
diff --git a/src/server/PortAudioDriver.hpp b/src/server/PortAudioDriver.hpp
index 5f2bf7a1..a624ee6e 100644
--- a/src/server/PortAudioDriver.hpp
+++ b/src/server/PortAudioDriver.hpp
@@ -32,7 +32,9 @@
#include <cstdint>
#include <memory>
-namespace raul { class Path; }
+namespace raul {
+class Path;
+} // namespace raul
namespace boost {
namespace intrusive {
@@ -89,15 +91,15 @@ public:
private:
friend class PortAudioPort;
- inline static int
- pa_process_cb(const void* inputs,
- void* outputs,
- unsigned long nframes,
- const PaStreamCallbackTimeInfo* time,
- PaStreamCallbackFlags flags,
- void* handle) {
+ static int pa_process_cb(const void* inputs,
+ void* outputs,
+ unsigned long nframes,
+ const PaStreamCallbackTimeInfo* time,
+ PaStreamCallbackFlags flags,
+ void* handle)
+ {
return static_cast<PortAudioDriver*>(handle)->process_cb(
- inputs, outputs, nframes, time, flags);
+ inputs, outputs, nframes, time, flags);
}
int process_cb(const void* inputs,
@@ -124,16 +126,16 @@ protected:
Ports _ports;
PaStreamParameters _inputParameters;
PaStreamParameters _outputParameters;
- raul::Semaphore _sem;
+ raul::Semaphore _sem{0};
std::unique_ptr<FrameTimer> _timer;
- PaStream* _stream;
- size_t _seq_size;
+ PaStream* _stream{nullptr};
+ size_t _seq_size{4096};
uint32_t _block_length;
- uint32_t _sample_rate;
- uint32_t _n_inputs;
- uint32_t _n_outputs;
- std::atomic<bool> _flag;
- bool _is_activated;
+ uint32_t _sample_rate{48000};
+ uint32_t _n_inputs{0};
+ uint32_t _n_outputs{0};
+ std::atomic<bool> _flag{false};
+ bool _is_activated{false};
};
} // namespace server
diff --git a/src/server/PortImpl.cpp b/src/server/PortImpl.cpp
index 68392707..68613e65 100644
--- a/src/server/PortImpl.cpp
+++ b/src/server/PortImpl.cpp
@@ -42,7 +42,7 @@
namespace ingen {
namespace server {
-static const uint32_t monitor_rate = 25.0; // Hz
+static const uint32_t monitor_rate = 25.0; // Hz
/** The length of time between monitor updates in frames */
static inline uint32_t
@@ -67,24 +67,12 @@ PortImpl::PortImpl(BufferFactory& bufs,
, _index(index)
, _poly(poly)
, _buffer_size(buffer_size)
- , _frames_since_monitor(0)
- , _monitor_value(0.0f)
- , _peak(0.0f)
, _type(type)
, _buffer_type(buffer_type)
, _value(value)
, _min(bufs.forge().make(0.0f))
, _max(bufs.forge().make(1.0f))
, _voices(bufs.maid().make_managed<Voices>(poly))
- , _connected_flag(false)
- , _monitored(false)
- , _force_monitor_update(false)
- , _is_morph(false)
- , _is_auto_morph(false)
- , _is_logarithmic(false)
- , _is_sample_rate(false)
- , _is_toggled(false)
- , _is_driver_port(false)
, _is_output(is_output)
{
assert(block != nullptr);
@@ -342,9 +330,13 @@ PortImpl::prepare_poly(BufferFactory& bufs, uint32_t poly)
if (_is_driver_port || _parent->is_main() ||
(_type == PortType::ATOM && !_value.is_valid())) {
return false;
- } else if (_poly == poly) {
+ }
+
+ if (_poly == poly) {
return true;
- } else if (_prepared_voices && _prepared_voices->size() != poly) {
+ }
+
+ if (_prepared_voices && _prepared_voices->size() != poly) {
_prepared_voices.reset();
}
@@ -365,7 +357,9 @@ PortImpl::apply_poly(RunContext& ctx, uint32_t poly)
if (_parent->is_main() ||
(_type == PortType::ATOM && !_value.is_valid())) {
return false;
- } else if (!_prepared_voices) {
+ }
+
+ if (!_prepared_voices) {
return true;
}
@@ -491,7 +485,7 @@ PortImpl::monitor(RunContext& ctx, bool send_now)
} else if (_monitored) {
/* Sequence explicitly monitored, send everything. */
const auto* seq = reinterpret_cast<const LV2_Atom_Sequence*>(atom);
- LV2_ATOM_SEQUENCE_FOREACH(seq, ev) {
+ LV2_ATOM_SEQUENCE_FOREACH (seq, ev) {
ctx.notify(uris.ingen_activity,
ctx.start() + ev->time.frames,
this,
@@ -570,8 +564,7 @@ PortImpl::pre_process(RunContext& ctx)
void
PortImpl::pre_run(RunContext&)
-{
-}
+{}
void
PortImpl::post_process(RunContext& ctx)
diff --git a/src/server/PortImpl.hpp b/src/server/PortImpl.hpp
index d79bb6cd..07904cff 100644
--- a/src/server/PortImpl.hpp
+++ b/src/server/PortImpl.hpp
@@ -22,12 +22,12 @@
#include "NodeImpl.hpp"
#include "PortType.hpp"
#include "RunContext.hpp"
+#include "server.h"
#include "types.hpp"
#include "ingen/Atom.hpp"
#include "ingen/Node.hpp"
#include "ingen/URIs.hpp"
-#include "ingen/ingen.h"
#include "lv2/urid/urid.h"
#include "raul/Array.hpp"
#include "raul/Maid.hpp"
@@ -57,7 +57,7 @@ class BlockImpl;
*
* \ingroup engine
*/
-class INGEN_API PortImpl : public NodeImpl
+class INGEN_SERVER_API PortImpl : public NodeImpl
{
public:
struct SetState {
@@ -91,10 +91,8 @@ public:
};
struct Voice {
- Voice() : buffer(nullptr) {}
-
SetState set_state;
- BufferRef buffer;
+ BufferRef buffer{nullptr};
};
using Voices = raul::Array<Voice>;
@@ -147,10 +145,11 @@ public:
void set_minimum(const Atom& min) { _min.set_rt(min); }
void set_maximum(const Atom& max) { _max.set_rt(max); }
- inline BufferRef buffer(uint32_t voice) const {
+ BufferRef buffer(uint32_t voice) const {
return _voices->at((_poly == 1) ? 0 : voice).buffer;
}
- inline BufferRef prepared_buffer(uint32_t voice) const {
+
+ BufferRef prepared_buffer(uint32_t voice) const {
return _prepared_voices->at(voice).buffer;
}
@@ -207,7 +206,7 @@ public:
uint32_t index() const { return _index; }
void set_index(RunContext&, uint32_t index) { _index = index; }
- inline bool is_a(PortType type) const { return _type == type; }
+ bool is_a(PortType type) const { return _type == type; }
bool has_value() const;
@@ -299,9 +298,9 @@ protected:
uint32_t _index;
uint32_t _poly;
uint32_t _buffer_size;
- uint32_t _frames_since_monitor;
- float _monitor_value;
- float _peak;
+ uint32_t _frames_since_monitor{0};
+ float _monitor_value{0.0f};
+ float _peak{0.0f};
PortType _type;
LV2_URID _buffer_type;
Atom _value;
@@ -310,15 +309,15 @@ protected:
raul::managed_ptr<Voices> _voices;
raul::managed_ptr<Voices> _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;
+ std::atomic_flag _connected_flag{false};
+ bool _monitored{false};
+ bool _force_monitor_update{false};
+ bool _is_morph{false};
+ bool _is_auto_morph{false};
+ bool _is_logarithmic{false};
+ bool _is_sample_rate{false};
+ bool _is_toggled{false};
+ bool _is_driver_port{false};
bool _is_output;
};
diff --git a/src/server/PortType.hpp b/src/server/PortType.hpp
index f84c271f..65f87d02 100644
--- a/src/server/PortType.hpp
+++ b/src/server/PortType.hpp
@@ -32,7 +32,8 @@ namespace ingen {
* of its contents). Ports with different types can contain the same type of
* data, but may e.g. have different access semantics.
*/
-class PortType {
+class PortType
+{
public:
enum ID {
UNKNOWN = 0,
@@ -56,24 +57,24 @@ public:
}
}
- PortType(ID id) : _id(id) {}
+ PortType(ID id) noexcept : _id(id) {}
- inline const URI& uri() const { return type_uri(_id); }
- inline ID id() const { return _id; }
+ const URI& uri() const { return type_uri(_id); }
+ ID id() const { return _id; }
- inline bool operator==(const ID& id) const { return (_id == id); }
- inline bool operator!=(const ID& id) const { return (_id != id); }
- inline bool operator==(const PortType& type) const { return (_id == type._id); }
- inline bool operator!=(const PortType& type) const { return (_id != type._id); }
- inline bool operator<(const PortType& type) const { return (_id < type._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); }
- inline bool is_audio() { return _id == AUDIO; }
- inline bool is_control() { return _id == CONTROL; }
- inline bool is_cv() { return _id == CV; }
- inline bool is_atom() { return _id == ATOM; }
+ 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 inline const URI& type_uri(unsigned id_num) {
+ 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"),
diff --git a/src/server/PostProcessor.cpp b/src/server/PostProcessor.cpp
index 5a0a8f3e..0e94efea 100644
--- a/src/server/PostProcessor.cpp
+++ b/src/server/PostProcessor.cpp
@@ -26,9 +26,10 @@ namespace server {
class PreProcessContext;
-class Sentinel : public Event {
+class Sentinel : public Event
+{
public:
- explicit Sentinel(Engine& engine) : Event(engine) {}
+ explicit Sentinel(Engine& engine) noexcept : Event(engine) {}
bool pre_process(PreProcessContext&) override { return false; }
void execute(RunContext&) override {}
@@ -40,8 +41,7 @@ PostProcessor::PostProcessor(Engine& engine)
, _head(new Sentinel(engine))
, _tail(_head.load())
, _max_time(0)
-{
-}
+{}
PostProcessor::~PostProcessor()
{
@@ -99,7 +99,7 @@ PostProcessor::process()
// Post-process event
ev->post_process();
- next = ev->next(); // [1] (see below)
+ next = ev->next(); // [1] (see below)
} while (next && next->time() < end_time);
/* Reached the tail (as far as we're concerned). There may be successors
diff --git a/src/server/PostProcessor.hpp b/src/server/PostProcessor.hpp
index ab8ba6bc..a29d60da 100644
--- a/src/server/PostProcessor.hpp
+++ b/src/server/PostProcessor.hpp
@@ -17,10 +17,9 @@
#ifndef INGEN_ENGINE_POSTPROCESSOR_HPP
#define INGEN_ENGINE_POSTPROCESSOR_HPP
+#include "server.h"
#include "types.hpp"
-#include "ingen/ingen.h"
-
#include <atomic>
namespace ingen {
@@ -41,7 +40,7 @@ class RunContext;
*
* \ingroup engine
*/
-class INGEN_API PostProcessor
+class INGEN_SERVER_API PostProcessor
{
public:
explicit PostProcessor(Engine& engine);
diff --git a/src/server/PreProcessContext.hpp b/src/server/PreProcessContext.hpp
index fa7d07c5..72dc64c3 100644
--- a/src/server/PreProcessContext.hpp
+++ b/src/server/PreProcessContext.hpp
@@ -50,12 +50,14 @@ public:
bool must_compile(GraphImpl& graph) {
if (!graph.enabled()) {
return false;
- } else if (_in_bundle) {
+ }
+
+ if (_in_bundle) {
_dirty_graphs.insert(&graph);
return false;
- } else {
- return true;
}
+
+ return true;
}
/** Compile graph and return the result if necessary.
diff --git a/src/server/PreProcessor.cpp b/src/server/PreProcessor.cpp
index b2f0fd46..7746d1db 100644
--- a/src/server/PreProcessor.cpp
+++ b/src/server/PreProcessor.cpp
@@ -39,11 +39,6 @@ namespace server {
PreProcessor::PreProcessor(Engine& engine)
: _engine(engine)
- , _sem(0)
- , _head(nullptr)
- , _tail(nullptr)
- , _block_state(BlockState::UNBLOCKED)
- , _exit_flag(false)
, _thread(&PreProcessor::run, this)
{}
@@ -114,12 +109,14 @@ PreProcessor::process(RunContext& ctx, PostProcessor& dest, size_t limit)
}
if (_block_state == BlockState::BLOCKED) {
- break; // Waiting for PRE_UNBLOCKED
- } else if (ev->time() < ctx.start()) {
- ev->set_time(ctx.start()); // Too late, nudge to context start
+ break; // Waiting for PRE_UNBLOCKED
+ }
+
+ if (ev->time() < ctx.start()) {
+ ev->set_time(ctx.start()); // Too late, nudge to context start
} else if (_block_state != BlockState::PROCESSING &&
ev->time() >= ctx.end()) {
- break; // Event is for a future cycle
+ break; // Event is for a future cycle
}
// Execute event
diff --git a/src/server/PreProcessor.hpp b/src/server/PreProcessor.hpp
index 05027638..c17e4d87 100644
--- a/src/server/PreProcessor.hpp
+++ b/src/server/PreProcessor.hpp
@@ -42,7 +42,7 @@ public:
~PreProcessor();
/** Return true iff no events are enqueued. */
- inline bool empty() const { return !_head.load(); }
+ bool empty() const { return !_head.load(); }
/** Enqueue an event.
* This is safe to call from any non-realtime thread (it locks).
@@ -61,11 +61,11 @@ protected:
private:
enum class BlockState {
- UNBLOCKED, ///< Normal, unblocked execution
- PRE_BLOCKED, ///< Preprocess thread has enqueued blocking event
- BLOCKED, ///< Process thread has reached blocking event
- PRE_UNBLOCKED, ///< Preprocess thread has enqueued unblocking event
- PROCESSING ///< Process thread is executing all events in-between
+ UNBLOCKED, ///< Normal, unblocked execution
+ PRE_BLOCKED, ///< Preprocess thread has enqueued blocking event
+ BLOCKED, ///< Process thread has reached blocking event
+ PRE_UNBLOCKED, ///< Preprocess thread has enqueued unblocking event
+ PROCESSING ///< Process thread is executing all events in-between
};
void wait_for_block_state(const BlockState state) {
@@ -76,11 +76,11 @@ private:
Engine& _engine;
std::mutex _mutex;
- raul::Semaphore _sem;
- std::atomic<Event*> _head;
- std::atomic<Event*> _tail;
- std::atomic<BlockState> _block_state;
- bool _exit_flag;
+ raul::Semaphore _sem{0};
+ std::atomic<Event*> _head{nullptr};
+ std::atomic<Event*> _tail{nullptr};
+ std::atomic<BlockState> _block_state{BlockState::UNBLOCKED};
+ bool _exit_flag{false};
std::thread _thread;
};
diff --git a/src/server/RunContext.cpp b/src/server/RunContext.cpp
index a61e4afb..f4e9219c 100644
--- a/src/server/RunContext.cpp
+++ b/src/server/RunContext.cpp
@@ -40,14 +40,13 @@
namespace ingen {
namespace server {
-struct Notification
-{
- explicit inline Notification(PortImpl* p = nullptr,
- FrameTime f = 0,
- LV2_URID k = 0,
- uint32_t s = 0,
- LV2_URID t = 0)
- : port(p), time(f), key(k), size(s), type(t)
+struct Notification {
+ explicit Notification(PortImpl* p = nullptr,
+ FrameTime f = 0,
+ LV2_URID k = 0,
+ uint32_t s = 0,
+ LV2_URID t = 0)
+ : port(p), time(f), key(k), size(s), type(t)
{}
PortImpl* port;
@@ -63,22 +62,13 @@ RunContext::RunContext(Engine& engine,
bool threaded)
: _engine(engine)
, _event_sink(event_sink)
- , _task(nullptr)
, _thread(threaded ? new std::thread(&RunContext::run, this) : nullptr)
, _id(id)
- , _start(0)
- , _end(0)
- , _offset(0)
- , _nframes(0)
- , _rate(0)
- , _realtime(true)
{}
RunContext::RunContext(const RunContext& copy)
: _engine(copy._engine)
, _event_sink(copy._event_sink)
- , _task(nullptr)
- , _thread(nullptr)
, _id(copy._id)
, _start(copy._start)
, _end(copy._end)
diff --git a/src/server/RunContext.hpp b/src/server/RunContext.hpp
index 92aa1cf8..30f87efd 100644
--- a/src/server/RunContext.hpp
+++ b/src/server/RunContext.hpp
@@ -103,17 +103,17 @@ public:
* cycle (other than the fact that it must be processed in significantly
* less time to avoid a dropout when running in real time).
*/
- inline uint64_t duration() const {
+ uint64_t duration() const {
return static_cast<uint64_t>(_nframes) * 1e6 / _rate;
}
- inline void locate(FrameTime s, SampleCount nframes) {
+ void locate(FrameTime s, SampleCount nframes) {
_start = s;
_end = s + nframes;
_nframes = nframes;
}
- inline void slice(SampleCount offset, SampleCount nframes) {
+ void slice(SampleCount offset, SampleCount nframes) {
_offset = offset;
_nframes = nframes;
}
@@ -129,32 +129,32 @@ public:
void join();
- inline Engine& engine() const { return _engine; }
- inline Task* task() const { return _task; }
- inline unsigned id() const { return _id; }
- inline FrameTime start() const { return _start; }
- inline FrameTime time() const { return _start + _offset; }
- inline FrameTime end() const { return _end; }
- inline SampleCount offset() const { return _offset; }
- inline SampleCount nframes() const { return _nframes; }
- inline SampleCount rate() const { return _rate; }
- inline bool realtime() const { return _realtime; }
+ Engine& engine() const { return _engine; }
+ Task* task() const { return _task; }
+ unsigned id() const { return _id; }
+ FrameTime start() const { return _start; }
+ FrameTime time() const { return _start + _offset; }
+ FrameTime end() const { return _end; }
+ SampleCount offset() const { return _offset; }
+ SampleCount nframes() const { return _nframes; }
+ SampleCount rate() const { return _rate; }
+ bool realtime() const { return _realtime; }
protected:
void run();
- Engine& _engine; ///< Engine we're running in
- raul::RingBuffer* _event_sink; ///< Updates from process context
- Task* _task; ///< Currently executing task
- std::unique_ptr<std::thread> _thread; ///< Thread (or null for main)
- unsigned _id; ///< Context ID
-
- FrameTime _start; ///< Start frame of this cycle, timeline relative
- FrameTime _end; ///< End frame of this cycle, timeline relative
- SampleCount _offset; ///< Offset into data buffers
- SampleCount _nframes; ///< Number of frames past offset to process
- SampleCount _rate; ///< Sample rate in Hz
- bool _realtime; ///< True iff context is hard realtime
+ Engine& _engine; ///< Engine we're running in
+ raul::RingBuffer* _event_sink; ///< Updates from notify()
+ Task* _task{nullptr}; ///< Currently executing task
+ std::unique_ptr<std::thread> _thread; ///< Thread (or null for main)
+ unsigned _id; ///< Context ID
+
+ FrameTime _start{0}; ///< Start frame of this cycle (timeline)
+ FrameTime _end{0}; ///< End frame of this cycle (timeline)
+ SampleCount _offset{0}; ///< Offset into data buffers
+ SampleCount _nframes{0}; ///< Number of frames past offset to process
+ SampleCount _rate{0}; ///< Sample rate in Hz
+ bool _realtime{true}; ///< True iff context is hard realtime
};
} // namespace server
diff --git a/src/server/SocketListener.cpp b/src/server/SocketListener.cpp
index 445374c4..ed874634 100644
--- a/src/server/SocketListener.cpp
+++ b/src/server/SocketListener.cpp
@@ -51,7 +51,7 @@ get_link_target(const char* link_path)
// Stat the link to get the required size for the target path
struct stat link_stat{};
if (lstat(link_path, &link_stat)) {
- return std::string();
+ return {};
}
// Allocate buffer and read link target
@@ -63,7 +63,7 @@ get_link_target(const char* link_path)
}
free(target);
- return std::string();
+ return {};
}
static void ingen_listen(Engine* engine,
@@ -141,7 +141,7 @@ ingen_listen(Engine* engine, raul::Socket* unix_sock, raul::Socket* net_sock)
}
if (unix_sock->fd() == -1 && net_sock->fd() == -1) {
- return; // No sockets to listen to, exit thread
+ return; // No sockets to listen to, exit thread
}
struct pollfd pfds[2];
@@ -165,10 +165,14 @@ ingen_listen(Engine* engine, raul::Socket* unix_sock, raul::Socket* net_sock)
if (ret == -1) {
world.log().error("Poll error: %1%\n", strerror(errno));
break;
- } else if (ret == 0) {
+ }
+
+ if (ret == 0) {
world.log().warn("Poll returned with no data\n");
continue;
- } else if ((pfds[0].revents & POLLHUP) || pfds[1].revents & POLLHUP) {
+ }
+
+ if ((pfds[0].revents & POLLHUP) || pfds[1].revents & POLLHUP) {
break;
}
diff --git a/src/server/SocketServer.hpp b/src/server/SocketServer.hpp
index ac8aa611..0531c44c 100644
--- a/src/server/SocketServer.hpp
+++ b/src/server/SocketServer.hpp
@@ -89,4 +89,4 @@ private:
} // namespace server
} // namespace ingen
-#endif // INGEN_SERVER_SOCKET_SERVER_HPP
+#endif // INGEN_SERVER_SOCKET_SERVER_HPP
diff --git a/src/server/State.hpp b/src/server/State.hpp
index b5a3f7c0..201c6b86 100644
--- a/src/server/State.hpp
+++ b/src/server/State.hpp
@@ -24,8 +24,7 @@
namespace ingen {
namespace server {
-struct StateDeleter
-{
+struct StateDeleter {
void operator()(LilvState* state) { lilv_state_free(state); }
};
diff --git a/src/server/Task.cpp b/src/server/Task.cpp
index ec9568b3..089a2f46 100644
--- a/src/server/Task.cpp
+++ b/src/server/Task.cpp
@@ -22,6 +22,7 @@
#include "raul/Path.hpp"
#include <cstddef>
+#include <memory>
namespace ingen {
namespace server {
@@ -93,7 +94,7 @@ Task::get_task(RunContext& ctx)
}
if (_done_end >= _children.size()) {
- return nullptr; // All child tasks are finished
+ return nullptr; // All child tasks are finished
}
// All child tasks claimed, but some are unfinished, steal a task
@@ -116,7 +117,7 @@ Task::simplify(std::unique_ptr<Task>&& task)
return std::move(task);
}
- std::unique_ptr<Task> ret = std::unique_ptr<Task>(new Task(task->mode()));
+ std::unique_ptr<Task> ret = std::make_unique<Task>(task->mode());
for (auto&& c : task->_children) {
auto child = simplify(std::move(c));
if (!child->empty()) {
diff --git a/src/server/Task.hpp b/src/server/Task.hpp
index a7657499..0a545655 100644
--- a/src/server/Task.hpp
+++ b/src/server/Task.hpp
@@ -32,20 +32,18 @@ namespace server {
class BlockImpl;
class RunContext;
-class Task {
+class Task
+{
public:
enum class Mode {
- SINGLE, ///< Single block to run
- SEQUENTIAL, ///< Elements must be run sequentially in order
- PARALLEL ///< Elements may be run in any order in parallel
+ SINGLE, ///< Single block to run
+ SEQUENTIAL, ///< Elements must be run sequentially in order
+ PARALLEL ///< Elements may be run in any order in parallel
};
Task(Mode mode, BlockImpl* block = nullptr)
: _block(block)
, _mode(mode)
- , _done_end(0)
- , _next(0)
- , _done(false)
{
assert(!(mode == Mode::SINGLE && !block));
}
@@ -92,7 +90,7 @@ public:
/** Prepend a child to this task. */
void push_front(Task&& task) {
- _children.emplace_front(std::unique_ptr<Task>(new Task(std::move(task))));
+ _children.emplace_front(std::make_unique<Task>(std::move(task)));
}
Mode mode() const { return _mode; }
@@ -110,12 +108,12 @@ private:
_children.emplace_back(std::move(t));
}
- Children _children; ///< Vector of child tasks
- BlockImpl* _block; ///< Used for SINGLE only
- Mode _mode; ///< Execution mode
- unsigned _done_end; ///< Index of rightmost done sub-task
- std::atomic<unsigned> _next; ///< Index of next sub-task
- std::atomic<bool> _done; ///< Completion phase
+ Children _children; ///< Vector of child tasks
+ BlockImpl* _block; ///< Used for SINGLE only
+ Mode _mode; ///< Execution mode
+ unsigned _done_end{0}; ///< Index of rightmost done sub-task
+ std::atomic<unsigned> _next{0}; ///< Index of next sub-task
+ std::atomic<bool> _done{false}; ///< Completion phase
};
} // namespace server
diff --git a/src/server/ThreadManager.hpp b/src/server/ThreadManager.hpp
index 81fb15cb..b25c6eed 100644
--- a/src/server/ThreadManager.hpp
+++ b/src/server/ThreadManager.hpp
@@ -17,7 +17,7 @@
#ifndef INGEN_ENGINE_THREADMANAGER_HPP
#define INGEN_ENGINE_THREADMANAGER_HPP
-#include "ingen/ingen.h"
+#include "server.h"
#include <cassert>
@@ -31,25 +31,26 @@ enum ThreadFlag {
THREAD_MESSAGE = 1 << 3,
};
-class INGEN_API ThreadManager {
+class INGEN_SERVER_API ThreadManager
+{
public:
- static inline void set_flag(ThreadFlag f) {
+ static void set_flag(ThreadFlag f) {
#ifndef NDEBUG
flags = (static_cast<unsigned>(flags) | f);
#endif
}
- static inline void unset_flag(ThreadFlag f) {
+ static void unset_flag(ThreadFlag f) {
#ifndef NDEBUG
flags = (static_cast<unsigned>(flags) & (~f));
#endif
}
- static inline void assert_thread(ThreadFlag f) {
+ static void assert_thread(ThreadFlag f) {
assert(single_threaded || (flags & f));
}
- static inline void assert_not_thread(ThreadFlag f) {
+ static void assert_not_thread(ThreadFlag f) {
assert(single_threaded || !(flags & f));
}
diff --git a/src/server/UndoStack.cpp b/src/server/UndoStack.cpp
index 97539823..a88cc778 100644
--- a/src/server/UndoStack.cpp
+++ b/src/server/UndoStack.cpp
@@ -18,6 +18,7 @@
#include "ingen/URIMap.hpp"
#include "ingen/URIs.hpp"
+#include "ingen/ingen.h"
#include "lv2/atom/atom.h"
#include "lv2/atom/util.h"
#include "lv2/patch/patch.h"
@@ -86,18 +87,18 @@ UndoStack::ignore_later_event(const LV2_Atom* first,
int
UndoStack::finish_entry()
{
- if (--_depth > 0) {
- return _depth;
- } else if (_stack.back().events.empty()) {
- // Disregard empty entry
- _stack.pop_back();
- } else if (_stack.size() > 1 && _stack.back().events.size() == 1) {
- // This entry and the previous one have one event, attempt to merge
- auto i = _stack.rbegin();
- ++i;
- if (i->events.size() == 1) {
- if (ignore_later_event(i->events[0], _stack.back().events[0])) {
- _stack.pop_back();
+ if (--_depth == 0) {
+ if (_stack.back().events.empty()) {
+ // Disregard empty entry
+ _stack.pop_back();
+ } else if (_stack.size() > 1 && _stack.back().events.size() == 1) {
+ // This entry and the previous one have one event, attempt to merge
+ auto i = _stack.rbegin();
+ ++i;
+ if (i->events.size() == 1) {
+ if (ignore_later_event(i->events[0], _stack.back().events[0])) {
+ _stack.pop_back();
+ }
}
}
}
@@ -117,7 +118,7 @@ UndoStack::pop()
}
struct BlankIDs {
- explicit BlankIDs(char prefix='b') : c(prefix) {}
+ explicit BlankIDs(const char prefix = 'b') noexcept : c{prefix} {}
SerdNode get() {
snprintf(buf, sizeof(buf), "%c%u", c, n++);
@@ -126,7 +127,7 @@ struct BlankIDs {
char buf[16]{};
unsigned n{0};
- const char c{'b'};
+ const char c;
};
struct ListContext {
@@ -138,8 +139,7 @@ struct ListContext {
, s(*subject)
, p(*predicate)
, flags(statement_flags | SERD_LIST_O_BEGIN)
- {
- }
+ {}
SerdNode start_node(SerdWriter* writer) {
const SerdNode node = ids.get();
@@ -226,7 +226,7 @@ UndoStack::save(FILE* stream, const char* name)
const SerdNode base = serd_node_from_string(SERD_URI, USTR("ingen:/"));
SerdURI base_uri;
- serd_uri_parse(base.buf, &base_uri);
+ serd_uri_parse(USTR("ingen:/"), &base_uri);
SerdWriter* writer =
serd_writer_new(SERD_TURTLE,
diff --git a/src/server/UndoStack.hpp b/src/server/UndoStack.hpp
index 7749b8fb..8195920a 100644
--- a/src/server/UndoStack.hpp
+++ b/src/server/UndoStack.hpp
@@ -18,10 +18,10 @@
#define INGEN_ENGINE_UNDOSTACK_HPP
#include "ingen/AtomSink.hpp"
-#include "ingen/ingen.h"
#include "lv2/atom/atom.h"
#include "lv2/atom/util.h"
#include "serd/serd.h"
+#include "server.h"
#include "sratom/sratom.h"
#include <algorithm>
@@ -39,10 +39,11 @@ class URIs;
namespace server {
-class INGEN_API UndoStack : public AtomSink {
+class INGEN_SERVER_API UndoStack : public AtomSink
+{
public:
struct Entry {
- Entry(time_t t=0) : time(t) {}
+ Entry(time_t t = 0) noexcept : time(t) {}
Entry(const Entry& copy)
: time(copy.time)
@@ -83,7 +84,7 @@ public:
std::deque<LV2_Atom*> events;
};
- UndoStack(URIs& uris, URIMap& map) : _uris(uris), _map(map), _depth(0) {}
+ UndoStack(URIs& uris, URIMap& map) noexcept : _uris(uris), _map(map) {}
int start_entry();
bool write(const LV2_Atom* msg, int32_t default_id=0) override;
@@ -106,7 +107,7 @@ private:
URIs& _uris;
URIMap& _map;
std::deque<Entry> _stack;
- int _depth;
+ int _depth{0};
};
} // namespace server
diff --git a/src/server/Worker.cpp b/src/server/Worker.cpp
index 77d98612..5b4da498 100644
--- a/src/server/Worker.cpp
+++ b/src/server/Worker.cpp
@@ -36,9 +36,9 @@ namespace server {
/// A message in the Worker::_requests ring
struct MessageHeader {
- LV2Block* block; ///< Node this message is from
+ LV2Block* block; ///< Node this message is from
uint32_t size; ///< Size of following data
- // `size' bytes of data follow here
+ // `size' bytes of data follow here
};
static LV2_Worker_Status
@@ -110,19 +110,17 @@ Worker::Schedule::feature(World&, Node* n)
f->URI = LV2_WORKER__schedule;
f->data = data;
- return std::shared_ptr<LV2_Feature>(f, &free_feature);
+ return {f, &free_feature};
}
Worker::Worker(Log& log, uint32_t buffer_size, bool synchronous)
: _schedule(new Schedule(synchronous))
, _log(log)
- , _sem(0)
, _requests(buffer_size)
, _responses(buffer_size)
, _buffer(static_cast<uint8_t*>(malloc(buffer_size)))
, _buffer_size(buffer_size)
, _thread(nullptr)
- , _exit_flag(false)
, _synchronous(synchronous)
{
if (!synchronous) {
diff --git a/src/server/Worker.hpp b/src/server/Worker.hpp
index dd799174..540347df 100644
--- a/src/server/Worker.hpp
+++ b/src/server/Worker.hpp
@@ -44,7 +44,7 @@ public:
~Worker();
struct Schedule : public LV2Features::Feature {
- Schedule(bool sync) : synchronous(sync) {}
+ Schedule(bool sync) noexcept : synchronous(sync) {}
const char* uri() const override { return LV2_WORKER__schedule; }
@@ -63,13 +63,13 @@ private:
std::shared_ptr<Schedule> _schedule;
Log& _log;
- raul::Semaphore _sem;
+ raul::Semaphore _sem{0};
raul::RingBuffer _requests;
raul::RingBuffer _responses;
uint8_t* const _buffer;
const uint32_t _buffer_size;
std::unique_ptr<std::thread> _thread;
- bool _exit_flag;
+ bool _exit_flag{false};
bool _synchronous;
void run();
diff --git a/src/server/events/Connect.cpp b/src/server/events/Connect.cpp
index 234bc550..386ed74d 100644
--- a/src/server/events/Connect.cpp
+++ b/src/server/events/Connect.cpp
@@ -52,10 +52,7 @@ Connect::Connect(Engine& engine,
const ingen::Connect& msg)
: Event(engine, client, msg.seq, timestamp)
, _msg(msg)
- , _graph(nullptr)
- , _head(nullptr)
-{
-}
+{}
Connect::~Connect() = default;
diff --git a/src/server/events/Connect.hpp b/src/server/events/Connect.hpp
index 941c0a25..a735b68c 100644
--- a/src/server/events/Connect.hpp
+++ b/src/server/events/Connect.hpp
@@ -64,8 +64,8 @@ public:
private:
const ingen::Connect _msg;
- GraphImpl* _graph;
- InputPort* _head;
+ GraphImpl* _graph{nullptr};
+ InputPort* _head{nullptr};
raul::managed_ptr<CompiledGraph> _compiled_graph;
std::shared_ptr<ArcImpl> _arc;
raul::managed_ptr<PortImpl::Voices> _voices;
diff --git a/src/server/events/Copy.cpp b/src/server/events/Copy.cpp
index 9ce7ead6..beb5224c 100644
--- a/src/server/events/Copy.cpp
+++ b/src/server/events/Copy.cpp
@@ -52,9 +52,6 @@ Copy::Copy(Engine& engine,
const ingen::Copy& msg)
: Event(engine, client, msg.seq, timestamp)
, _msg(msg)
- , _old_block(nullptr)
- , _parent(nullptr)
- , _block(nullptr)
{}
Copy::~Copy() = default;
@@ -69,7 +66,7 @@ Copy::pre_process(PreProcessContext& ctx)
const raul::Path old_path = uri_to_path(_msg.old_uri);
// Find the old node
- const Store::iterator i = _engine.store()->find(old_path);
+ const auto i = _engine.store()->find(old_path);
if (i == _engine.store()->end()) {
return Event::pre_process_done(Status::NOT_FOUND, old_path);
}
@@ -82,19 +79,23 @@ Copy::pre_process(PreProcessContext& ctx)
if (uri_is_path(_msg.new_uri)) {
// Copy to path within the engine
return engine_to_engine(ctx);
- } else if (_msg.new_uri.scheme() == "file") {
+ }
+
+ if (_msg.new_uri.scheme() == "file") {
// Copy to filesystem path (i.e. save)
return engine_to_filesystem(ctx);
- } else {
- return Event::pre_process_done(Status::BAD_REQUEST);
}
- } else if (_msg.old_uri.scheme() == "file") {
+
+ return Event::pre_process_done(Status::BAD_REQUEST);
+ }
+
+ if (_msg.old_uri.scheme() == "file") {
if (uri_is_path(_msg.new_uri)) {
return filesystem_to_engine(ctx);
- } else {
- // Ingen is not your file manager
- return Event::pre_process_done(Status::BAD_REQUEST);
}
+
+ // Ingen is not your file manager
+ return Event::pre_process_done(Status::BAD_REQUEST);
}
return Event::pre_process_done(Status::BAD_URI);
@@ -115,8 +116,8 @@ Copy::engine_to_engine(PreProcessContext& ctx)
}
// Find new parent graph
- const raul::Path parent_path = new_path.parent();
- const Store::iterator p = _engine.store()->find(parent_path);
+ const raul::Path parent_path = new_path.parent();
+ const auto p = _engine.store()->find(parent_path);
if (p == _engine.store()->end()) {
return Event::pre_process_done(Status::NOT_FOUND, parent_path);
}
diff --git a/src/server/events/Copy.hpp b/src/server/events/Copy.hpp
index f9c507f0..8460140a 100644
--- a/src/server/events/Copy.hpp
+++ b/src/server/events/Copy.hpp
@@ -64,9 +64,9 @@ private:
bool filesystem_to_engine(PreProcessContext& ctx);
const ingen::Copy _msg;
- std::shared_ptr<BlockImpl> _old_block;
- GraphImpl* _parent;
- BlockImpl* _block;
+ std::shared_ptr<BlockImpl> _old_block{nullptr};
+ GraphImpl* _parent{nullptr};
+ BlockImpl* _block{nullptr};
raul::managed_ptr<CompiledGraph> _compiled_graph;
};
diff --git a/src/server/events/CreateBlock.cpp b/src/server/events/CreateBlock.cpp
index 0898a6a0..23a0d35e 100644
--- a/src/server/events/CreateBlock.cpp
+++ b/src/server/events/CreateBlock.cpp
@@ -64,8 +64,6 @@ CreateBlock::CreateBlock(Engine& engine,
: Event(engine, client, id, timestamp)
, _path(std::move(path))
, _properties(properties)
- , _graph(nullptr)
- , _block(nullptr)
{}
CreateBlock::~CreateBlock() = default;
@@ -73,22 +71,24 @@ CreateBlock::~CreateBlock() = default;
bool
CreateBlock::pre_process(PreProcessContext& ctx)
{
- using iterator = Properties::const_iterator;
-
const ingen::URIs& uris = _engine.world().uris();
const std::shared_ptr<Store> store = _engine.store();
// Check sanity of target path
if (_path.is_root()) {
return Event::pre_process_done(Status::BAD_URI, _path);
- } else if (store->get(_path)) {
+ }
+
+ if (store->get(_path)) {
return Event::pre_process_done(Status::EXISTS, _path);
- } else if (!(_graph = dynamic_cast<GraphImpl*>(store->get(_path.parent())))) {
+ }
+
+ if (!(_graph = dynamic_cast<GraphImpl*>(store->get(_path.parent())))) {
return Event::pre_process_done(Status::PARENT_NOT_FOUND, _path.parent());
}
// Map old ingen:prototype to new lv2:prototype
- auto range = _properties.equal_range(uris.ingen_prototype);
+ const auto range = _properties.equal_range(uris.ingen_prototype);
for (auto i = range.first; i != range.second;) {
const auto value = i->second;
auto next = i;
@@ -98,7 +98,7 @@ CreateBlock::pre_process(PreProcessContext& ctx)
}
// Get prototype
- iterator t = _properties.find(uris.lv2_prototype);
+ const auto t = _properties.find(uris.lv2_prototype);
if (t == _properties.end() || !uris.forge.is_uri(t->second)) {
// Missing/invalid prototype
return Event::pre_process_done(Status::BAD_REQUEST);
@@ -107,10 +107,10 @@ CreateBlock::pre_process(PreProcessContext& ctx)
const URI prototype(uris.forge.str(t->second, false));
// Find polyphony
- const iterator p = _properties.find(uris.ingen_polyphonic);
- const bool polyphonic = (p != _properties.end() &&
- p->second.type() == uris.forge.Bool &&
- p->second.get<int32_t>());
+ const auto p = _properties.find(uris.ingen_polyphonic);
+ const bool polyphonic = (p != _properties.end() &&
+ p->second.type() == uris.forge.Bool &&
+ p->second.get<int32_t>());
// Find and instantiate/duplicate prototype (plugin/existing node)
if (uri_is_path(prototype)) {
@@ -119,8 +119,11 @@ CreateBlock::pre_process(PreProcessContext& ctx)
store->get(uri_to_path(prototype)));
if (!ancestor) {
return Event::pre_process_done(Status::PROTOTYPE_NOT_FOUND, prototype);
- } else if (!(_block = ancestor->duplicate(
- _engine, raul::Symbol(_path.symbol()), _graph))) {
+ }
+
+ if (!(_block = ancestor->duplicate(_engine,
+ raul::Symbol(_path.symbol()),
+ _graph))) {
return Event::pre_process_done(Status::CREATION_FAILED, _path);
}
diff --git a/src/server/events/CreateBlock.hpp b/src/server/events/CreateBlock.hpp
index 97a54b3f..2a7a60ab 100644
--- a/src/server/events/CreateBlock.hpp
+++ b/src/server/events/CreateBlock.hpp
@@ -68,8 +68,8 @@ private:
raul::Path _path;
Properties& _properties;
ClientUpdate _update;
- GraphImpl* _graph;
- BlockImpl* _block;
+ GraphImpl* _graph{nullptr};
+ BlockImpl* _block{nullptr};
raul::managed_ptr<CompiledGraph> _compiled_graph;
};
diff --git a/src/server/events/CreateGraph.cpp b/src/server/events/CreateGraph.cpp
index 2a74ddf0..54a1788e 100644
--- a/src/server/events/CreateGraph.cpp
+++ b/src/server/events/CreateGraph.cpp
@@ -54,14 +54,11 @@ CreateGraph::CreateGraph(Engine& engine,
int32_t id,
SampleCount timestamp,
raul::Path path,
- const Properties& properties)
+ Properties properties)
: Event(engine, client, id, timestamp)
, _path(std::move(path))
- , _properties(properties)
- , _graph(nullptr)
- , _parent(nullptr)
-{
-}
+ , _properties(std::move(properties))
+{}
CreateGraph::~CreateGraph() = default;
@@ -136,11 +133,9 @@ CreateGraph::pre_process(PreProcessContext& ctx)
const ingen::URIs& uris = _engine.world().uris();
- using iterator = Properties::const_iterator;
-
- uint32_t ext_poly = 1;
- uint32_t int_poly = 1;
- iterator p = _properties.find(uris.ingen_polyphony);
+ uint32_t ext_poly = 1;
+ uint32_t int_poly = 1;
+ const auto p = _properties.find(uris.ingen_polyphony);
if (p != _properties.end() && p->second.type() == uris.forge.Int) {
int_poly = p->second.get<int32_t>();
}
@@ -156,7 +151,7 @@ CreateGraph::pre_process(PreProcessContext& ctx)
const raul::Symbol symbol(_path.is_root() ? "graph" : _path.symbol());
// Get graph prototype
- iterator t = _properties.find(uris.lv2_prototype);
+ auto t = _properties.find(uris.lv2_prototype);
if (t == _properties.end()) {
t = _properties.find(uris.lv2_prototype);
}
@@ -171,8 +166,10 @@ CreateGraph::pre_process(PreProcessContext& ctx)
if (!ancestor) {
return Event::pre_process_done(Status::PROTOTYPE_NOT_FOUND,
prototype);
- } else if (!(_graph = dynamic_cast<GraphImpl*>(
- ancestor->duplicate(_engine, symbol, _parent)))) {
+ }
+
+ if (!(_graph = dynamic_cast<GraphImpl*>(
+ ancestor->duplicate(_engine, symbol, _parent)))) {
return Event::pre_process_done(Status::CREATION_FAILED, _path);
}
} else {
diff --git a/src/server/events/CreateGraph.hpp b/src/server/events/CreateGraph.hpp
index d9e994c0..7fc005ad 100644
--- a/src/server/events/CreateGraph.hpp
+++ b/src/server/events/CreateGraph.hpp
@@ -55,7 +55,7 @@ public:
int32_t id,
SampleCount timestamp,
raul::Path path,
- const Properties& properties);
+ Properties properties);
~CreateGraph() override;
@@ -72,8 +72,8 @@ private:
const raul::Path _path;
Properties _properties;
ClientUpdate _update;
- GraphImpl* _graph;
- GraphImpl* _parent;
+ GraphImpl* _graph{nullptr};
+ GraphImpl* _parent{nullptr};
raul::managed_ptr<CompiledGraph> _compiled_graph;
std::list<std::unique_ptr<Event>> _child_events;
};
diff --git a/src/server/events/CreatePort.cpp b/src/server/events/CreatePort.cpp
index 1fa2a528..6eee6ed7 100644
--- a/src/server/events/CreatePort.cpp
+++ b/src/server/events/CreatePort.cpp
@@ -58,19 +58,12 @@ CreatePort::CreatePort(Engine& engine,
: Event(engine, client, id, timestamp)
, _path(std::move(path))
, _port_type(PortType::UNKNOWN)
- , _buf_type(0)
- , _graph(nullptr)
- , _graph_port(nullptr)
- , _engine_port(nullptr)
, _properties(properties)
{
const ingen::URIs& uris = _engine.world().uris();
- using Iterator = Properties::const_iterator;
- using Range = std::pair<Iterator, Iterator>;
-
- const Range types = properties.equal_range(uris.rdf_type);
- for (Iterator i = types.first; i != types.second; ++i) {
+ const auto types = properties.equal_range(uris.rdf_type);
+ for (auto i = types.first; i != types.second; ++i) {
const Atom& type = i->second;
if (type == uris.lv2_AudioPort) {
_port_type = PortType::AUDIO;
@@ -87,8 +80,8 @@ 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) {
+ const auto buffer_types = properties.equal_range(uris.atom_bufferType);
+ for (auto i = buffer_types.first; i != buffer_types.second; ++i) {
if (uris.forge.is_uri(i->second)) {
_buf_type = _engine.world().uri_map().map_uri(
uris.forge.str(i->second, false));
@@ -101,9 +94,13 @@ CreatePort::pre_process(PreProcessContext&)
{
if (_port_type == PortType::UNKNOWN || !_flow) {
return Event::pre_process_done(Status::UNKNOWN_TYPE, _path);
- } else if (_path.is_root()) {
+ }
+
+ if (_path.is_root()) {
return Event::pre_process_done(Status::BAD_URI, _path);
- } else if (_engine.store()->get(_path)) {
+ }
+
+ if (_engine.store()->get(_path)) {
return Event::pre_process_done(Status::EXISTS, _path);
}
@@ -111,10 +108,14 @@ CreatePort::pre_process(PreProcessContext&)
Node* const parent = _engine.store()->get(parent_path);
if (!parent) {
return Event::pre_process_done(Status::PARENT_NOT_FOUND, parent_path);
- } else if (!(_graph = dynamic_cast<GraphImpl*>(parent))) {
+ }
+
+ if (!(_graph = dynamic_cast<GraphImpl*>(parent))) {
return Event::pre_process_done(Status::INVALID_PARENT, parent_path);
- } else if (!_graph->parent() && _engine.activated() &&
- !_engine.driver()->dynamic_ports()) {
+ }
+
+ if (!_graph->parent() && _engine.activated() &&
+ !_engine.driver()->dynamic_ports()) {
return Event::pre_process_done(Status::CREATION_FAILED, _path);
}
@@ -123,10 +124,8 @@ CreatePort::pre_process(PreProcessContext&)
const uint32_t buf_size = bufs.default_size(_buf_type);
const int32_t old_n_ports = _graph->num_ports_non_rt();
- using PropIter = Properties::const_iterator;
-
- PropIter index_i = _properties.find(uris.lv2_index);
- int32_t index = 0;
+ auto index_i = _properties.find(uris.lv2_index);
+ int32_t index = 0;
if (index_i != _properties.end()) {
// Ensure given index is sane and not taken
if (index_i->second.type() != uris.forge.Int) {
@@ -144,7 +143,7 @@ CreatePort::pre_process(PreProcessContext&)
_engine.world().forge().make(index));
}
- const PropIter poly_i = _properties.find(uris.ingen_polyphonic);
+ const auto poly_i = _properties.find(uris.ingen_polyphonic);
const bool polyphonic = (poly_i != _properties.end() &&
poly_i->second.type() == uris.forge.Bool &&
poly_i->second.get<int32_t>());
diff --git a/src/server/events/CreatePort.hpp b/src/server/events/CreatePort.hpp
index 73746434..3351adc9 100644
--- a/src/server/events/CreatePort.hpp
+++ b/src/server/events/CreatePort.hpp
@@ -74,11 +74,11 @@ private:
raul::Path _path;
PortType _port_type;
- LV2_URID _buf_type;
- GraphImpl* _graph;
- DuplexPort* _graph_port;
+ LV2_URID _buf_type{0};
+ GraphImpl* _graph{nullptr};
+ DuplexPort* _graph_port{nullptr};
raul::managed_ptr<BlockImpl::Ports> _ports_array; ///< New external port array for Graph
- EnginePort* _engine_port; ///< Driver port if on the root
+ EnginePort* _engine_port{nullptr}; ///< Driver port if on the root
Properties _properties;
Properties _update;
boost::optional<Flow> _flow;
diff --git a/src/server/events/Delete.cpp b/src/server/events/Delete.cpp
index 3347b549..aba49adb 100644
--- a/src/server/events/Delete.cpp
+++ b/src/server/events/Delete.cpp
@@ -62,8 +62,6 @@ Delete::Delete(Engine& engine,
const ingen::Del& msg)
: Event(engine, client, msg.seq, timestamp)
, _msg(msg)
- , _engine_port(nullptr)
- , _disconnect_event(nullptr)
{
if (uri_is_path(msg.uri)) {
_path = uri_to_path(msg.uri);
@@ -72,7 +70,7 @@ Delete::Delete(Engine& engine,
Delete::~Delete()
{
- for (ControlBindings::Binding* b : _removed_bindings) {
+ for (auto* b : _removed_bindings) {
delete b;
}
}
diff --git a/src/server/events/Delete.hpp b/src/server/events/Delete.hpp
index 50a925b5..7dfb5681 100644
--- a/src/server/events/Delete.hpp
+++ b/src/server/events/Delete.hpp
@@ -77,7 +77,7 @@ private:
raul::Path _path;
std::shared_ptr<BlockImpl> _block; ///< Non-null iff a block
std::shared_ptr<DuplexPort> _port; ///< Non-null iff a port
- EnginePort* _engine_port;
+ EnginePort* _engine_port{nullptr};
raul::managed_ptr<GraphImpl::Ports> _ports_array; ///< New (external) ports for Graph
raul::managed_ptr<CompiledGraph> _compiled_graph; ///< Graph's new process order
std::unique_ptr<DisconnectAll> _disconnect_event;
diff --git a/src/server/events/Delta.cpp b/src/server/events/Delta.cpp
index b4d46fb9..71d4b48f 100644
--- a/src/server/events/Delta.cpp
+++ b/src/server/events/Delta.cpp
@@ -49,7 +49,6 @@
#include "raul/Path.hpp"
#include <algorithm>
-#include <map>
#include <memory>
#include <mutex>
#include <set>
@@ -69,16 +68,10 @@ Delta::Delta(Engine& engine,
SampleCount timestamp,
const ingen::Put& msg)
: Event(engine, client, msg.seq, timestamp)
- , _create_event(nullptr)
, _subject(msg.uri)
, _properties(msg.properties)
- , _object(nullptr)
- , _graph(nullptr)
- , _binding(nullptr)
- , _state()
, _context(msg.ctx)
, _type(Type::PUT)
- , _block(false)
{
init();
}
@@ -92,13 +85,8 @@ Delta::Delta(Engine& engine,
, _subject(msg.uri)
, _properties(msg.add)
, _remove(msg.remove)
- , _object(nullptr)
- , _graph(nullptr)
- , _binding(nullptr)
- , _state(nullptr)
, _context(msg.ctx)
, _type(Type::PATCH)
- , _block(false)
{
init();
}
@@ -110,13 +98,8 @@ Delta::Delta(Engine& engine,
: Event(engine, client, msg.seq, timestamp)
, _subject(msg.subject)
, _properties{{msg.predicate, msg.value}}
- , _object(nullptr)
- , _graph(nullptr)
- , _binding(nullptr)
- , _state(nullptr)
, _context(msg.ctx)
, _type(Type::SET)
- , _block(false)
{
init();
}
@@ -172,12 +155,15 @@ get_file_node(LilvWorld* lworld, const URIs& uris, const Atom& value)
{
if (value.type() == uris.atom_Path) {
return lilv_new_file_uri(lworld, nullptr, value.ptr<char>());
- } else if (uris.forge.is_uri(value)) {
+ }
+
+ if (uris.forge.is_uri(value)) {
const std::string str = uris.forge.str(value, false);
if (str.substr(0, 5) == "file:") {
return lilv_new_uri(lworld, value.ptr<char>());
}
}
+
return nullptr;
}
@@ -222,9 +208,9 @@ Delta::pre_process(PreProcessContext& ctx)
if ((_preset = block->save_preset(_subject, _properties))) {
return Event::pre_process_done(Status::SUCCESS);
- } else {
- return Event::pre_process_done(Status::FAILURE);
}
+
+ return Event::pre_process_done(Status::FAILURE);
}
std::lock_guard<Store::Mutex> lock(_engine.store()->mutex());
@@ -260,7 +246,7 @@ Delta::pre_process(PreProcessContext& ctx)
}
if (_create_event) {
if (_create_event->pre_process(ctx)) {
- _object = _engine.store()->get(path); // Get object for setting
+ _object = _engine.store()->get(path); // Get object for setting
} else {
return Event::pre_process_done(Status::CREATION_FAILED, _subject);
}
@@ -372,7 +358,7 @@ Delta::pre_process(PreProcessContext& ctx)
}
} else if ((block = dynamic_cast<BlockImpl*>(_object))) {
if (key == uris.midi_binding && value == uris.patch_wildcard) {
- op = SpecialType::CONTROL_BINDING; // Internal block learn
+ op = SpecialType::CONTROL_BINDING; // Internal block learn
} else if (key == uris.ingen_enabled) {
if (value.type() == uris.forge.Bool) {
op = SpecialType::ENABLE;
@@ -409,7 +395,7 @@ Delta::pre_process(PreProcessContext& ctx)
if (key == uris.ingen_enabled) {
if (value.type() == uris.forge.Bool) {
op = SpecialType::ENABLE;
- // FIXME: defer this until all other metadata has been processed
+ // FIXME: defer until all other data has been processed
if (value.get<int32_t>() && !_graph->enabled()) {
if (!(_compiled_graph = compile(*_engine.maid(), *_graph))) {
_status = Status::COMPILATION_FAILED;
@@ -516,7 +502,7 @@ Delta::execute(RunContext& ctx)
auto* const block = dynamic_cast<BlockImpl*>(_object);
auto* const port = dynamic_cast<PortImpl*>(_object);
- std::vector<SpecialType>::const_iterator t = _types.begin();
+ auto t = _types.begin();
for (const auto& p : _properties) {
const URI& key = p.first;
const Atom& value = p.second;
@@ -613,13 +599,13 @@ Delta::post_process()
if (_create_event) {
_create_event->post_process();
if (_create_event->status() != Status::SUCCESS) {
- return; // Creation failed, nothing else to do
+ return; // Creation failed, nothing else to do
}
}
for (auto& s : _set_events) {
if (s->synthetic() || s->status() != Status::SUCCESS) {
- s->post_process(); // Set failed, report error
+ s->post_process(); // Set failed, report error
}
}
diff --git a/src/server/events/Delta.hpp b/src/server/events/Delta.hpp
index 726d8b48..7f79ae94 100644
--- a/src/server/events/Delta.hpp
+++ b/src/server/events/Delta.hpp
@@ -20,6 +20,7 @@
#include "ClientUpdate.hpp"
#include "ControlBindings.hpp"
#include "Event.hpp"
+#include "SetPortValue.hpp"
#include "State.hpp"
#include "types.hpp"
@@ -34,6 +35,8 @@
#include <memory>
#include <vector>
+// IWYU pragma: no_include <algorithm>
+
namespace ingen {
class Interface;
@@ -51,8 +54,6 @@ class RunContext;
namespace events {
-class SetPortValue;
-
/** Set properties of a graph object.
* \ingroup engine
*/
@@ -115,10 +116,10 @@ private:
Properties _properties;
Properties _remove;
ClientUpdate _update;
- ingen::Resource* _object;
- GraphImpl* _graph;
+ ingen::Resource* _object{nullptr};
+ GraphImpl* _graph{nullptr};
raul::managed_ptr<CompiledGraph> _compiled_graph;
- ControlBindings::Binding* _binding;
+ ControlBindings::Binding* _binding{nullptr};
StatePtr _state;
Resource::Graph _context;
Type _type;
@@ -130,7 +131,7 @@ private:
boost::optional<Resource> _preset;
- bool _block;
+ bool _block{false};
};
} // namespace events
diff --git a/src/server/events/Disconnect.cpp b/src/server/events/Disconnect.cpp
index ea6bb8f0..3526ac83 100644
--- a/src/server/events/Disconnect.cpp
+++ b/src/server/events/Disconnect.cpp
@@ -60,9 +60,7 @@ Disconnect::Disconnect(Engine& engine,
const ingen::Disconnect& msg)
: Event(engine, client, msg.seq, timestamp)
, _msg(msg)
- , _graph(nullptr)
-{
-}
+{}
Disconnect::~Disconnect() = default;
@@ -159,7 +157,9 @@ Disconnect::pre_process(PreProcessContext& ctx)
if (!_graph) {
return Event::pre_process_done(Status::INTERNAL_ERROR, _msg.head);
- } else if (!_graph->has_arc(tail, head)) {
+ }
+
+ if (!_graph->has_arc(tail, head)) {
return Event::pre_process_done(Status::NOT_FOUND, _msg.head);
}
diff --git a/src/server/events/Disconnect.hpp b/src/server/events/Disconnect.hpp
index a835ed27..71ad4204 100644
--- a/src/server/events/Disconnect.hpp
+++ b/src/server/events/Disconnect.hpp
@@ -61,14 +61,15 @@ public:
void post_process() override;
void undo(Interface& target) override;
- class Impl {
+ class Impl
+ {
public:
Impl(Engine& e, GraphImpl* graph, PortImpl* t, InputPort* h);
bool execute(RunContext& ctx, bool set_head_buffers);
- inline PortImpl* tail() { return _tail; }
- inline InputPort* head() { return _head; }
+ PortImpl* tail() { return _tail; }
+ InputPort* head() { return _head; }
private:
Engine& _engine;
@@ -80,7 +81,7 @@ public:
private:
const ingen::Disconnect _msg;
- GraphImpl* _graph;
+ GraphImpl* _graph{nullptr};
std::unique_ptr<Impl> _impl;
raul::managed_ptr<CompiledGraph> _compiled_graph;
};
diff --git a/src/server/events/DisconnectAll.cpp b/src/server/events/DisconnectAll.cpp
index 35254ba0..7ae17632 100644
--- a/src/server/events/DisconnectAll.cpp
+++ b/src/server/events/DisconnectAll.cpp
@@ -34,7 +34,6 @@
#include "ingen/Store.hpp"
#include "raul/Maid.hpp"
-#include <map>
#include <memory>
#include <mutex>
#include <set>
@@ -54,8 +53,7 @@ DisconnectAll::DisconnectAll(Engine& engine,
, _block(nullptr)
, _port(nullptr)
, _deleting(false)
-{
-}
+{}
/** Internal version for use by other events.
*/
@@ -68,8 +66,7 @@ DisconnectAll::DisconnectAll(Engine& engine,
, _block(dynamic_cast<BlockImpl*>(object))
, _port(dynamic_cast<PortImpl*>(object))
, _deleting(true)
-{
-}
+{}
DisconnectAll::~DisconnectAll()
{
@@ -124,7 +121,7 @@ DisconnectAll::pre_process(PreProcessContext& ctx)
// Create disconnect events to erase adjacent arcs in parent's parent
if (_port && _parent->parent()) {
- GraphImpl* parent_parent = dynamic_cast<GraphImpl*>(_parent->parent());
+ auto* const parent_parent = dynamic_cast<GraphImpl*>(_parent->parent());
for (const auto& a : adjacent_arcs(parent_parent)) {
_impls.push_back(
new Disconnect::Impl(_engine,
diff --git a/src/server/events/Get.cpp b/src/server/events/Get.cpp
index 219af6fe..389d9e48 100644
--- a/src/server/events/Get.cpp
+++ b/src/server/events/Get.cpp
@@ -47,8 +47,6 @@ Get::Get(Engine& engine,
const ingen::Get& msg)
: Event(engine, client, msg.seq, timestamp)
, _msg(msg)
- , _object(nullptr)
- , _plugin(nullptr)
{}
bool
@@ -60,9 +58,13 @@ Get::pre_process(PreProcessContext&)
if (uri == "ingen:/plugins") {
_plugins = _engine.block_factory()->plugins();
return Event::pre_process_done(Status::SUCCESS);
- } else if (uri == "ingen:/engine") {
+ }
+
+ if (uri == "ingen:/engine") {
return Event::pre_process_done(Status::SUCCESS);
- } else if (uri_is_path(uri)) {
+ }
+
+ if (uri_is_path(uri)) {
if ((_object = _engine.store()->get(uri_to_path(uri)))) {
const BlockImpl* block = nullptr;
const GraphImpl* graph = nullptr;
@@ -79,18 +81,19 @@ Get::pre_process(PreProcessContext&)
return Event::pre_process_done(Status::SUCCESS);
}
return Event::pre_process_done(Status::NOT_FOUND, uri);
- } else if ((_plugin = _engine.block_factory()->plugin(uri))) {
+ }
+
+ if ((_plugin = _engine.block_factory()->plugin(uri))) {
_response.put_plugin(_plugin);
return Event::pre_process_done(Status::SUCCESS);
- } else {
- return Event::pre_process_done(Status::NOT_FOUND, uri);
}
+
+ return Event::pre_process_done(Status::NOT_FOUND, uri);
}
void
Get::execute(RunContext&)
-{
-}
+{}
void
Get::post_process()
diff --git a/src/server/events/Get.hpp b/src/server/events/Get.hpp
index fd3f8569..1ec49bfa 100644
--- a/src/server/events/Get.hpp
+++ b/src/server/events/Get.hpp
@@ -58,8 +58,8 @@ public:
private:
const ingen::Get _msg;
- const Node* _object;
- PluginImpl* _plugin;
+ const Node* _object{nullptr};
+ PluginImpl* _plugin{nullptr};
BlockFactory::Plugins _plugins;
ClientUpdate _response;
};
diff --git a/src/server/events/Move.cpp b/src/server/events/Move.cpp
index d85451c8..8b7ee655 100644
--- a/src/server/events/Move.cpp
+++ b/src/server/events/Move.cpp
@@ -14,10 +14,11 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "events/Move.hpp"
+
#include "Broadcaster.hpp"
#include "Driver.hpp"
#include "Engine.hpp"
-#include "events/Move.hpp"
#include "ingen/Interface.hpp"
#include "ingen/Status.hpp"
@@ -41,8 +42,7 @@ Move::Move(Engine& engine,
const ingen::Move& msg)
: Event(engine, client, msg.seq, timestamp)
, _msg(msg)
-{
-}
+{}
bool
Move::pre_process(PreProcessContext&)
@@ -53,7 +53,7 @@ Move::pre_process(PreProcessContext&)
return Event::pre_process_done(Status::PARENT_DIFFERS, _msg.new_path);
}
- const Store::iterator i = _engine.store()->find(_msg.old_path);
+ const auto i = _engine.store()->find(_msg.old_path);
if (i == _engine.store()->end()) {
return Event::pre_process_done(Status::NOT_FOUND, _msg.old_path);
}
@@ -74,8 +74,7 @@ Move::pre_process(PreProcessContext&)
void
Move::execute(RunContext&)
-{
-}
+{}
void
Move::post_process()
diff --git a/src/server/events/SetPortValue.cpp b/src/server/events/SetPortValue.cpp
index a1b5bafa..8b425571 100644
--- a/src/server/events/SetPortValue.cpp
+++ b/src/server/events/SetPortValue.cpp
@@ -51,8 +51,7 @@ SetPortValue::SetPortValue(Engine& engine,
, _value(value)
, _activity(activity)
, _synthetic(synthetic)
-{
-}
+{}
bool
SetPortValue::pre_process(PreProcessContext&)
diff --git a/src/server/events/Undo.cpp b/src/server/events/Undo.cpp
index 3c91235d..9d6fcfaa 100644
--- a/src/server/events/Undo.cpp
+++ b/src/server/events/Undo.cpp
@@ -81,8 +81,7 @@ Undo::pre_process(PreProcessContext&)
void
Undo::execute(RunContext&)
-{
-}
+{}
void
Undo::post_process()
diff --git a/src/server/ingen_engine.cpp b/src/server/ingen_engine.cpp
index a5735f33..fd4a8ced 100644
--- a/src/server/ingen_engine.cpp
+++ b/src/server/ingen_engine.cpp
@@ -41,7 +41,7 @@ struct EngineModule : public Module {
extern "C" {
-ingen::Module*
+INGEN_MODULE_EXPORT ingen::Module*
ingen_module_load()
{
return new ingen::EngineModule();
diff --git a/src/server/ingen_jack.cpp b/src/server/ingen_jack.cpp
index 97d72919..0d3263be 100644
--- a/src/server/ingen_jack.cpp
+++ b/src/server/ingen_jack.cpp
@@ -58,7 +58,7 @@ struct JackModule : public Module {
extern "C" {
-ingen::Module*
+INGEN_MODULE_EXPORT ingen::Module*
ingen_module_load()
{
return new ingen::server::JackModule();
diff --git a/src/server/ingen_lv2.cpp b/src/server/ingen_lv2.cpp
index 90b9d944..851a83fb 100644
--- a/src/server/ingen_lv2.cpp
+++ b/src/server/ingen_lv2.cpp
@@ -90,7 +90,8 @@ struct LV2Graph : public Parser::ResourceRecord {
};
/** Ingen LV2 library. */
-class Lib {
+class Lib
+{
public:
explicit Lib(const char* bundle_path);
@@ -124,15 +125,9 @@ public:
*this)
, _from_ui(ui_ring_size(block_length))
, _to_ui(ui_ring_size(block_length))
- , _root_graph(nullptr)
- , _notify_capacity(0)
, _block_length(block_length)
, _seq_size(seq_size)
, _sample_rate(sample_rate)
- , _frame_time(0)
- , _to_ui_overflow_sem(0)
- , _to_ui_overflow(false)
- , _instantiated(false)
{}
bool dynamic_ports() const override { return !_instantiated; }
@@ -151,11 +146,11 @@ public:
lv2_atom_total_size(
static_cast<LV2_Atom*>(lv2_buf)));
- if (graph_port->symbol() == "control") { // TODO: Safe to use index?
+ if (graph_port->symbol() == "control") { // TODO: Safe to use index?
auto* seq = reinterpret_cast<LV2_Atom_Sequence*>(lv2_buf);
bool enqueued = false;
- LV2_ATOM_SEQUENCE_FOREACH(seq, ev)
+ LV2_ATOM_SEQUENCE_FOREACH (seq, ev)
{
if (AtomReader::is_message(uris, &ev->body)) {
enqueued = enqueue_message(&ev->body) || enqueued;
@@ -268,7 +263,7 @@ public:
const URIs& uris = _engine.world().uris();
auto* seq = static_cast<LV2_Atom_Sequence*>(_ports[0]->buffer());
- LV2_ATOM_SEQUENCE_FOREACH(seq, ev) {
+ LV2_ATOM_SEQUENCE_FOREACH (seq, ev) {
if (ev->body.type == uris.atom_Object) {
const LV2_Atom_Object* obj =
reinterpret_cast<LV2_Atom_Object*>(&ev->body);
@@ -365,14 +360,14 @@ public:
if (seq->atom.size + lv2_atom_pad_size(
sizeof(LV2_Atom_Event) + atom.size)
> _notify_capacity) {
- break; // Output port buffer full, resume next time
+ break; // Output port buffer full, resume next time
}
auto* ev = reinterpret_cast<LV2_Atom_Event*>(
reinterpret_cast<uint8_t*>(seq) +
lv2_atom_total_size(&seq->atom));
- ev->time.frames = 0; // TODO: Time?
+ ev->time.frames = 0; // TODO: Time?
ev->body = atom;
_to_ui.skip(sizeof(LV2_Atom));
@@ -413,15 +408,15 @@ private:
AtomWriter _writer;
raul::RingBuffer _from_ui;
raul::RingBuffer _to_ui;
- GraphImpl* _root_graph;
- uint32_t _notify_capacity;
+ GraphImpl* _root_graph{nullptr};
+ uint32_t _notify_capacity{0};
SampleCount _block_length;
size_t _seq_size;
SampleCount _sample_rate;
- SampleCount _frame_time;
- raul::Semaphore _to_ui_overflow_sem;
- bool _to_ui_overflow;
- bool _instantiated;
+ SampleCount _frame_time{0};
+ raul::Semaphore _to_ui_overflow_sem{0};
+ bool _to_ui_overflow{false};
+ bool _instantiated{false};
};
struct IngenPlugin {
@@ -501,7 +496,9 @@ ingen_instantiate(const LV2_Descriptor* descriptor,
if (!map) {
lv2_log_error(&logger, "host did not provide URI map feature\n");
return nullptr;
- } else if (!unmap) {
+ }
+
+ if (!unmap) {
lv2_log_error(&logger, "host did not provide URI unmap feature\n");
return nullptr;
}
diff --git a/src/server/ingen_portaudio.cpp b/src/server/ingen_portaudio.cpp
index 991470e4..86fc76d9 100644
--- a/src/server/ingen_portaudio.cpp
+++ b/src/server/ingen_portaudio.cpp
@@ -16,8 +16,8 @@
// IWYU pragma: no_include "ingen/FilePath.hpp"
-#include "PortAudioDriver.hpp"
#include "Engine.hpp"
+#include "PortAudioDriver.hpp"
#include "ingen/Log.hpp"
#include "ingen/Module.hpp"
@@ -51,7 +51,7 @@ struct PortAudioModule : public Module {
extern "C" {
-ingen::Module*
+INGEN_MODULE_EXPORT ingen::Module*
ingen_module_load()
{
return new ingen::server::PortAudioModule();
diff --git a/src/server/internals/Controller.cpp b/src/server/internals/Controller.cpp
index d0d8cd39..ccc6df01 100644
--- a/src/server/internals/Controller.cpp
+++ b/src/server/internals/Controller.cpp
@@ -60,7 +60,6 @@ ControllerNode::ControllerNode(InternalPlugin* plugin,
GraphImpl* parent,
SampleRate srate)
: InternalBlock(plugin, symbol, false, parent, srate)
- , _learning(false)
{
const ingen::URIs& uris = bufs.uris();
_ports = bufs.maid().make_managed<Ports>(7);
@@ -125,7 +124,7 @@ ControllerNode::run(RunContext& ctx)
auto* seq = midi_in->get<LV2_Atom_Sequence>();
const BufferRef midi_out = _midi_out_port->buffer(0);
- LV2_ATOM_SEQUENCE_FOREACH(seq, ev) {
+ LV2_ATOM_SEQUENCE_FOREACH (seq, ev) {
const auto* buf = static_cast<const uint8_t*>(LV2_ATOM_BODY_CONST(&ev->body));
if (ev->body.type == _midi_in_port->bufs().uris().midi_MidiEvent &&
ev->body.size >= 3 &&
diff --git a/src/server/internals/Controller.hpp b/src/server/internals/Controller.hpp
index b5cea110..2a0bc834 100644
--- a/src/server/internals/Controller.hpp
+++ b/src/server/internals/Controller.hpp
@@ -74,7 +74,7 @@ private:
InputPort* _min_port;
InputPort* _max_port;
OutputPort* _audio_port;
- bool _learning;
+ bool _learning{false};
};
} // namespace internals
diff --git a/src/server/internals/Note.cpp b/src/server/internals/Note.cpp
index 4952310b..976e43f9 100644
--- a/src/server/internals/Note.cpp
+++ b/src/server/internals/Note.cpp
@@ -64,7 +64,6 @@ NoteNode::NoteNode(InternalPlugin* plugin,
SampleRate srate)
: InternalBlock(plugin, symbol, polyphonic, parent, srate)
, _voices(bufs.maid().make_managed<Voices>(_polyphony))
- , _sustain(false)
{
const ingen::URIs& uris = bufs.uris();
_ports = bufs.maid().make_managed<Ports>(8);
@@ -179,7 +178,7 @@ NoteNode::run(RunContext& ctx)
Buffer* const midi_in = _midi_in_port->buffer(0).get();
auto* seq = midi_in->get<LV2_Atom_Sequence>();
- LV2_ATOM_SEQUENCE_FOREACH(seq, ev) {
+ LV2_ATOM_SEQUENCE_FOREACH (seq, ev) {
const auto* buf =
static_cast<const uint8_t*>(LV2_ATOM_BODY_CONST(&ev->body));
@@ -360,7 +359,7 @@ NoteNode::free_voice(RunContext& ctx, uint32_t voice, FrameTime time)
}
}
- if (replace_key != nullptr) { // Found a key to assign to freed voice
+ if (replace_key != nullptr) { // Found a key to assign to freed voice
assert(&_keys[replace_key_num] == replace_key);
assert(replace_key->state == Key::State::ON_UNASSIGNED);
diff --git a/src/server/internals/Note.hpp b/src/server/internals/Note.hpp
index 80816131..3aa3217e 100644
--- a/src/server/internals/Note.hpp
+++ b/src/server/internals/Note.hpp
@@ -105,7 +105,7 @@ private:
raul::managed_ptr<Voices> _prepared_voices;
Key _keys[128];
- bool _sustain; ///< Whether or not hold pedal is depressed
+ bool _sustain{false}; ///< Whether or not hold pedal is depressed
InputPort* _midi_in_port;
OutputPort* _freq_port;
diff --git a/src/server/internals/Trigger.cpp b/src/server/internals/Trigger.cpp
index 645ffabb..89a970fc 100644
--- a/src/server/internals/Trigger.cpp
+++ b/src/server/internals/Trigger.cpp
@@ -60,7 +60,6 @@ TriggerNode::TriggerNode(InternalPlugin* plugin,
GraphImpl* parent,
SampleRate srate)
: InternalBlock(plugin, symbol, false, parent, srate)
- , _learning(false)
{
const ingen::URIs& uris = bufs.uris();
_ports = bufs.maid().make_managed<Ports>(6);
@@ -124,7 +123,7 @@ TriggerNode::run(RunContext& ctx)
// Initialise output to the empty sequence
midi_out->prepare_write(ctx);
- LV2_ATOM_SEQUENCE_FOREACH(seq, ev) {
+ LV2_ATOM_SEQUENCE_FOREACH (seq, ev) {
const int64_t t = ev->time.frames;
const auto* buf =
static_cast<const uint8_t*>(LV2_ATOM_BODY_CONST(&ev->body));
diff --git a/src/server/internals/Trigger.hpp b/src/server/internals/Trigger.hpp
index d9553c3e..74634202 100644
--- a/src/server/internals/Trigger.hpp
+++ b/src/server/internals/Trigger.hpp
@@ -71,7 +71,7 @@ public:
static InternalPlugin* internal_plugin(URIs& uris);
private:
- bool _learning;
+ bool _learning{false};
InputPort* _midi_in_port;
OutputPort* _midi_out_port;
diff --git a/src/server/meson.build b/src/server/meson.build
new file mode 100644
index 00000000..c2e5b761
--- /dev/null
+++ b/src/server/meson.build
@@ -0,0 +1,135 @@
+# Copyright 2022 David Robillard <d@drobilla.net>
+# SPDX-License-Identifier: 0BSD OR GPL-3.0-or-later
+
+##########
+# Module #
+##########
+
+server_sources = files(
+ 'ArcImpl.cpp',
+ 'BlockFactory.cpp',
+ 'BlockImpl.cpp',
+ 'Broadcaster.cpp',
+ 'Buffer.cpp',
+ 'BufferFactory.cpp',
+ 'ClientUpdate.cpp',
+ 'CompiledGraph.cpp',
+ 'ControlBindings.cpp',
+ 'DuplexPort.cpp',
+ 'Engine.cpp',
+ 'EventWriter.cpp',
+ 'GraphImpl.cpp',
+ 'InputPort.cpp',
+ 'InternalBlock.cpp',
+ 'InternalPlugin.cpp',
+ 'LV2Block.cpp',
+ 'LV2Plugin.cpp',
+ 'NodeImpl.cpp',
+ 'PortImpl.cpp',
+ 'PostProcessor.cpp',
+ 'PreProcessor.cpp',
+ 'RunContext.cpp',
+ 'SocketListener.cpp',
+ 'Task.cpp',
+ 'UndoStack.cpp',
+ 'Worker.cpp',
+ 'events/Connect.cpp',
+ 'events/Copy.cpp',
+ 'events/CreateBlock.cpp',
+ 'events/CreateGraph.cpp',
+ 'events/CreatePort.cpp',
+ 'events/Delete.cpp',
+ 'events/Delta.cpp',
+ 'events/Disconnect.cpp',
+ 'events/DisconnectAll.cpp',
+ 'events/Get.cpp',
+ 'events/Mark.cpp',
+ 'events/Move.cpp',
+ 'events/SetPortValue.cpp',
+ 'events/Undo.cpp',
+ 'ingen_engine.cpp',
+ 'internals/BlockDelay.cpp',
+ 'internals/Controller.cpp',
+ 'internals/Note.cpp',
+ 'internals/Time.cpp',
+ 'internals/Trigger.cpp',
+ 'mix.cpp',
+)
+
+server_dependencies = [
+ boost_dep,
+ ingen_dep,
+ lilv_dep,
+ raul_dep,
+ serd_dep,
+ sord_dep,
+ sratom_dep,
+ thread_dep,
+]
+
+server_include_dirs = include_directories(
+ '.',
+ '../../include',
+ '../include',
+)
+
+libingen_server = shared_library(
+ 'ingen_server',
+ server_sources,
+ cpp_args: cpp_suppressions + platform_defines + ['-DINGEN_SERVER_INTERNAL'],
+ dependencies: server_dependencies,
+ gnu_symbol_visibility: 'hidden',
+ implicit_include_directories: false,
+ include_directories: server_include_dirs,
+ install: true,
+ install_dir: ingen_module_dir,
+)
+
+ingen_server_dep = declare_dependency(
+ dependencies: server_dependencies,
+ link_with: libingen_server,
+)
+
+###########
+# Drivers #
+###########
+
+if jack_dep.found()
+ shared_module(
+ 'ingen_jack',
+ files('JackDriver.cpp', 'ingen_jack.cpp'),
+ cpp_args: cpp_suppressions + platform_defines,
+ dependencies: [ingen_server_dep, jack_dep],
+ gnu_symbol_visibility: 'hidden',
+ implicit_include_directories: false,
+ include_directories: ingen_include_dirs,
+ install: true,
+ install_dir: ingen_module_dir,
+ )
+endif
+
+if portaudio_dep.found()
+ shared_module(
+ 'ingen_portaudio',
+ files('PortAudioDriver.cpp', 'ingen_portaudio.cpp'),
+ cpp_args: cpp_suppressions + platform_defines,
+ dependencies: [ingen_server_dep, portaudio_dep],
+ gnu_symbol_visibility: 'hidden',
+ implicit_include_directories: false,
+ include_directories: ingen_include_dirs,
+ install: true,
+ install_dir: ingen_module_dir,
+ )
+endif
+
+shared_module(
+ 'ingen_lv2',
+ files('ingen_lv2.cpp'),
+ cpp_args: cpp_suppressions + platform_defines,
+ dependencies: [ingen_server_dep, lv2_dep],
+ gnu_symbol_visibility: 'hidden',
+ implicit_include_directories: false,
+ include_directories: ingen_include_dirs,
+ install: true,
+ install_dir: lv2dir / 'ingen.lv2',
+)
diff --git a/src/server/mix.cpp b/src/server/mix.cpp
index a1e0c276..9c578d11 100644
--- a/src/server/mix.cpp
+++ b/src/server/mix.cpp
@@ -59,15 +59,15 @@ mix(const RunContext& ctx,
const SampleCount end = ctx.nframes();
for (uint32_t i = 1; i < num_srcs; ++i) {
const Sample* __restrict const in = srcs[i]->samples();
- if (srcs[i]->is_control()) { // control => audio
+ if (srcs[i]->is_control()) { // control => audio
for (SampleCount j = 0; j < end; ++j) {
out[j] += in[0];
}
- } else if (srcs[i]->is_audio()) { // audio => audio
+ } else if (srcs[i]->is_audio()) { // audio => audio
for (SampleCount j = 0; j < end; ++j) {
out[j] += in[j];
}
- } else if (srcs[i]->is_sequence()) { // sequence => audio
+ } else if (srcs[i]->is_sequence()) { // sequence => audio
dst->render_sequence(ctx, srcs[i], true);
}
}
diff --git a/src/server/server.h b/src/server/server.h
new file mode 100644
index 00000000..d4ca5155
--- /dev/null
+++ b/src/server/server.h
@@ -0,0 +1,31 @@
+/*
+ This file is part of Ingen.
+ Copyright 2014-2022 David Robillard <http://drobilla.net/>
+
+ Ingen is free software: you can redistribute it and/or modify it under the
+ terms of the GNU Affero General Public License as published by the Free
+ Software Foundation, either version 3 of the License, or any later version.
+
+ Ingen is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Affero General Public License for details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with Ingen. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef INGEN_SERVER_SERVER_H
+#define INGEN_SERVER_SERVER_H
+
+#if defined(_WIN32) && !defined(INGEN_SERVER_STATIC) && \
+ defined(INGEN_SERVER_INTERNAL)
+# define INGEN_SERVER_API __declspec(dllexport)
+#elif defined(_WIN32) && !defined(INGEN_SERVER_STATIC)
+# define INGEN_SERVER_API __declspec(dllimport)
+#elif defined(__GNUC__)
+# define INGEN_SERVER_API __attribute__((visibility("default")))
+#else
+# define INGEN_SERVER_API
+#endif
+
+#endif // INGEN_SERVER_SERVER_H
diff --git a/src/server/wscript b/src/server/wscript
deleted file mode 100644
index 5fdf4583..00000000
--- a/src/server/wscript
+++ /dev/null
@@ -1,106 +0,0 @@
-#!/usr/bin/env python
-
-
-def build(bld):
- core_source = '''
- ArcImpl.cpp
- BlockFactory.cpp
- BlockImpl.cpp
- Broadcaster.cpp
- Buffer.cpp
- BufferFactory.cpp
- CompiledGraph.cpp
- ClientUpdate.cpp
- ControlBindings.cpp
- DuplexPort.cpp
- Engine.cpp
- EventWriter.cpp
- GraphImpl.cpp
- InputPort.cpp
- InternalBlock.cpp
- InternalPlugin.cpp
- LV2Block.cpp
- LV2Plugin.cpp
- NodeImpl.cpp
- PortImpl.cpp
- PostProcessor.cpp
- PreProcessor.cpp
- RunContext.cpp
- SocketListener.cpp
- Task.cpp
- UndoStack.cpp
- Worker.cpp
- events/Connect.cpp
- events/Copy.cpp
- events/CreateBlock.cpp
- events/CreateGraph.cpp
- events/CreatePort.cpp
- events/Delete.cpp
- events/Delta.cpp
- events/Disconnect.cpp
- events/DisconnectAll.cpp
- events/Get.cpp
- events/Mark.cpp
- events/Move.cpp
- events/SetPortValue.cpp
- events/Undo.cpp
- ingen_engine.cpp
- internals/BlockDelay.cpp
- internals/Controller.cpp
- internals/Note.cpp
- internals/Time.cpp
- internals/Trigger.cpp
- mix.cpp
- '''
-
- core_libs = 'LV2 LILV RAUL SERD SORD SRATOM'
-
- bld(features = 'cxx cxxshlib',
- source = core_source,
- export_includes = ['../../include'],
- includes = ['.', '../..', '../../include'],
- name = 'libingen_server',
- target = 'ingen_server',
- install_path = '${LIBDIR}',
- use = 'libingen libingen_socket',
- uselib = core_libs,
- cxxflags = bld.env.PTHREAD_CFLAGS + bld.env.INGEN_TEST_CXXFLAGS,
- linkflags = bld.env.PTHREAD_LINKFLAGS + bld.env.INGEN_TEST_LINKFLAGS)
-
- if bld.env.HAVE_JACK:
- bld(features = 'cxx cxxshlib',
- source = 'JackDriver.cpp ingen_jack.cpp',
- includes = ['.', '../../', '../../include'],
- name = 'libingen_jack',
- target = 'ingen_jack',
- install_path = '${LIBDIR}',
- use = 'libingen_server',
- uselib = core_libs + ' JACK',
- cxxflags = ['-fvisibility=hidden'] + bld.env.PTHREAD_CFLAGS,
- linkflags = bld.env.PTHREAD_LINKFLAGS)
-
- if bld.env.HAVE_PORTAUDIO:
- bld(features = 'cxx cxxshlib',
- source = 'PortAudioDriver.cpp ingen_portaudio.cpp',
- includes = ['.', '../../', '../../include'],
- name = 'libingen_portaudio',
- target = 'ingen_portaudio',
- install_path = '${LIBDIR}',
- use = 'libingen_server',
- uselib = core_libs + ' PORTAUDIO',
- cxxflags = ['-fvisibility=hidden'] + bld.env.PTHREAD_CFLAGS,
- linkflags = bld.env.PTHREAD_LINKFLAGS)
-
- # Ingen LV2 wrapper
- if bld.env.INGEN_BUILD_LV2:
- bld(features = 'cxx cxxshlib',
- source = ' ingen_lv2.cpp ',
- cflags = ['-fvisibility=hidden'],
- includes = ['../../', '../../include'],
- name = 'libingen_lv2',
- target = 'ingen_lv2',
- install_path = '${LV2DIR}/ingen.lv2/',
- use = 'libingen libingen_server',
- uselib = core_libs,
- cxxflags = ['-fvisibility=hidden'] + bld.env.PTHREAD_CFLAGS,
- linkflags = bld.env.PTHREAD_LINKFLAGS)
diff --git a/src/wscript b/src/wscript
deleted file mode 100644
index a2f576da..00000000
--- a/src/wscript
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/usr/bin/env python
-
-
-def build(bld):
- sources = [
- 'AtomReader.cpp',
- 'AtomWriter.cpp',
- 'ClashAvoider.cpp',
- 'ColorContext.cpp',
- 'Configuration.cpp',
- 'FilePath.cpp',
- 'Forge.cpp',
- 'LV2Features.cpp',
- 'Library.cpp',
- 'Log.cpp',
- 'Parser.cpp',
- 'Resource.cpp',
- 'Serialiser.cpp',
- 'Store.cpp',
- 'StreamWriter.cpp',
- 'TurtleWriter.cpp',
- 'URI.cpp',
- 'URIMap.cpp',
- 'URIs.cpp',
- 'World.cpp',
- 'runtime_paths.cpp'
- ]
- if bld.is_defined('HAVE_SOCKET'):
- sources += ['SocketReader.cpp', 'SocketWriter.cpp']
-
- lib = []
- if bld.is_defined('HAVE_LIBDL'):
- lib += ['dl']
-
- bld(features = 'cxx cxxshlib',
- source = sources,
- export_includes = ['../include'],
- includes = ['.', '..', '../include'],
- name = 'libingen',
- target = 'ingen-%s' % bld.env.INGEN_MAJOR_VERSION,
- vnum = bld.env.INGEN_VERSION,
- install_path = '${LIBDIR}',
- lib = lib,
- uselib = 'LV2 LILV RAUL SERD SORD SRATOM',
- cxxflags = (['-fvisibility=hidden'] +
- bld.env.PTHREAD_CFLAGS + bld.env.INGEN_TEST_CXXFLAGS),
- linkflags = bld.env.PTHREAD_LINKFLAGS + bld.env.INGEN_TEST_LINKFLAGS)