summaryrefslogtreecommitdiffstats
path: root/src/server/ControlBindings.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/ControlBindings.hpp')
-rw-r--r--src/server/ControlBindings.hpp65
1 files changed, 38 insertions, 27 deletions
diff --git a/src/server/ControlBindings.hpp b/src/server/ControlBindings.hpp
index bb113666..9a7f66a2 100644
--- a/src/server/ControlBindings.hpp
+++ b/src/server/ControlBindings.hpp
@@ -19,20 +19,24 @@
#include "BufferRef.hpp"
-#include "ingen/types.hpp"
#include "lv2/atom/forge.h"
#include "raul/Maid.hpp"
-#include <boost/intrusive/options.hpp>
#include <boost/intrusive/set.hpp>
#include <boost/intrusive/set_hook.hpp>
#include <atomic>
#include <cstdint>
-#include <utility>
+#include <memory>
#include <vector>
-namespace Raul { class Path; }
+namespace raul {
+class Path;
+} // namespace raul
+
+namespace boost::intrusive {
+template <class Compare> struct compare;
+} // namespace boost::intrusive
namespace ingen {
@@ -45,7 +49,8 @@ class Engine;
class RunContext;
class PortImpl;
-class ControlBindings {
+class ControlBindings
+{
public:
enum class Type : uint16_t {
NULL_CONTROL,
@@ -58,25 +63,31 @@ 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;
};
/** One binding of a controller to a port. */
struct Binding : public boost::intrusive::set_base_hook<>,
- public Raul::Maid::Disposable {
- Binding(Key k=Key(), PortImpl* p=nullptr) : key(std::move(k)), port(p) {}
+ 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;
@@ -112,7 +123,7 @@ public:
void post_process(RunContext& ctx, Buffer* buffer);
/** Get all bindings for `path` or children of `path`. */
- void get_all(const Raul::Path& path, std::vector<Binding*>& bindings);
+ void get_all(const raul::Path& path, std::vector<Binding*>& bindings);
/** Remove a set of bindings from an earlier call to get_all(). */
void remove(RunContext& ctx, const std::vector<Binding*>& bindings);
@@ -123,30 +134,30 @@ 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& context,
+ void set_port_value(RunContext& ctx,
PortImpl* port,
Type type,
- int16_t value);
+ int16_t value) const;
- bool finish_learn(RunContext& context, Key key);
+ bool finish_learn(RunContext& ctx, Key key);
- static float control_to_port_value(RunContext& context,
- const PortImpl* port,
- Type type,
- int16_t value);
+ static float control_to_port_value(RunContext& ctx,
+ const PortImpl* port,
+ Type type,
+ int16_t value);
- static int16_t port_value_to_control(RunContext& context,
+ static int16_t port_value_to_control(RunContext& ctx,
PortImpl* port,
Type type,
const Atom& value_atom);
- Engine& _engine;
- std::atomic<Binding*> _learn_binding;
- SPtr<Bindings> _bindings;
- BufferRef _feedback;
- LV2_Atom_Forge _forge;
+ Engine& _engine;
+ std::atomic<Binding*> _learn_binding;
+ std::shared_ptr<Bindings> _bindings;
+ BufferRef _feedback;
+ LV2_Atom_Forge _forge;
};
} // namespace server