summaryrefslogtreecommitdiffstats
path: root/ingen
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2016-12-06 11:03:35 -0500
committerDavid Robillard <d@drobilla.net>2016-12-13 19:15:26 -0500
commit0752556bde5659a933744658cdf63509000a5080 (patch)
tree0ab580ab247f55886515ad23e1bd89a51063acd9 /ingen
parent6502a2505fc390e3099331b5ea521efd56812aaa (diff)
downloadingen-0752556bde5659a933744658cdf63509000a5080.tar.gz
ingen-0752556bde5659a933744658cdf63509000a5080.tar.bz2
ingen-0752556bde5659a933744658cdf63509000a5080.zip
Fix some real-time safety issues
Diffstat (limited to 'ingen')
-rw-r--r--ingen/Atom.hpp18
-rw-r--r--ingen/Log.hpp2
2 files changed, 18 insertions, 2 deletions
diff --git a/ingen/Atom.hpp b/ingen/Atom.hpp
index e26462a5..4015e59e 100644
--- a/ingen/Atom.hpp
+++ b/ingen/Atom.hpp
@@ -72,7 +72,7 @@ public:
_body.ptr = (LV2_Atom*)malloc(sizeof(LV2_Atom) + _atom.size);
memcpy(_body.ptr, copy._body.ptr, sizeof(LV2_Atom) + _atom.size);
} else {
- memcpy(&_body.val, &copy._body.val, sizeof(_body.val));
+ _body.val = copy._body.val;
}
}
@@ -86,7 +86,7 @@ public:
_body.ptr = (LV2_Atom*)malloc(sizeof(LV2_Atom) + _atom.size);
memcpy(_body.ptr, other._body.ptr, sizeof(LV2_Atom) + _atom.size);
} else {
- memcpy(&_body.val, &other._body.val, sizeof(_body.val));
+ _body.val = other._body.val;
}
return *this;
}
@@ -116,6 +116,20 @@ public:
return type() < other.type();
}
+ /** Like assignment, but only works for value atoms (not references).
+ * Always real-time safe.
+ * @return true iff set succeeded.
+ */
+ inline bool set_rt(const Atom& other) {
+ if (is_reference()) {
+ return false;
+ } else {
+ _atom = other._atom;
+ _body.val = other._body.val;
+ return true;
+ }
+ }
+
inline uint32_t size() const { return _atom.size; }
inline LV2_URID type() const { return _atom.type; }
inline bool is_valid() const { return _atom.type; }
diff --git a/ingen/Log.hpp b/ingen/Log.hpp
index 189754e2..8063d4e5 100644
--- a/ingen/Log.hpp
+++ b/ingen/Log.hpp
@@ -50,6 +50,8 @@ public:
};
};
+ void rt_error(const char* msg);
+
void error(const std::string& msg);
void info(const std::string& msg);
void warn(const std::string& msg);