summaryrefslogtreecommitdiffstats
path: root/src/server/PortImpl.hpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2016-12-13 20:53:58 -0500
committerDavid Robillard <d@drobilla.net>2016-12-14 14:47:13 -0500
commite7b2f7ee286350bc3bb56b44ed98e4d8bf49af82 (patch)
tree8e5a4e42b36bb5c321f24cdd492cd3dc0a941222 /src/server/PortImpl.hpp
parent05c55a5be68318d2b7ca861a3012bf4893bcb82d (diff)
downloadingen-e7b2f7ee286350bc3bb56b44ed98e4d8bf49af82.tar.gz
ingen-e7b2f7ee286350bc3bb56b44ed98e4d8bf49af82.tar.bz2
ingen-e7b2f7ee286350bc3bb56b44ed98e4d8bf49af82.zip
Fix real-time issues with buffer allocation
Diffstat (limited to 'src/server/PortImpl.hpp')
-rw-r--r--src/server/PortImpl.hpp31
1 files changed, 22 insertions, 9 deletions
diff --git a/src/server/PortImpl.hpp b/src/server/PortImpl.hpp
index 05ca3ff4..fd35b52d 100644
--- a/src/server/PortImpl.hpp
+++ b/src/server/PortImpl.hpp
@@ -124,6 +124,9 @@ public:
virtual bool apply_poly(
RunContext& context, Raul::Maid& maid, uint32_t poly);
+ /** Return the number of arcs (pre-process thraed). */
+ virtual size_t num_arcs() const { return 0; }
+
const Atom& value() const { return _value; }
void set_value(const Atom& v) { _value = v; }
@@ -175,15 +178,8 @@ public:
/** Empty buffer contents completely (ie silence) */
virtual void clear_buffers();
-public:
- virtual bool get_buffers(BufferFactory& bufs,
- Raul::Array<Voice>* voices,
- uint32_t poly,
- bool real_time) const;
-
- void setup_buffers(BufferFactory& bufs, uint32_t poly, bool real_time) {
- get_buffers(bufs, _voices, poly, real_time);
- }
+ /** Claim and apply buffers in the real-time thread. */
+ virtual bool setup_buffers(RunContext& ctx, BufferFactory& bufs, uint32_t poly);
void activate(BufferFactory& bufs);
void deactivate();
@@ -272,6 +268,22 @@ public:
bool is_toggled() const { return _is_toggled; }
protected:
+ typedef BufferRef (BufferFactory::*GetFn)(LV2_URID, LV2_URID, uint32_t);
+
+ /** Set `voices` as the buffers to be used for this port.
+ *
+ * This is real-time safe only if `get` is as well, use in the real-time
+ * thread should pass &BufferFactory::claim_buffer.
+ *
+ * @param get Method used to get new buffers as necessary.
+ * @return true iff buffers are locally owned by the port
+ */
+ virtual bool get_buffers(BufferFactory& bufs,
+ GetFn get,
+ Raul::Array<Voice>* voices,
+ uint32_t poly,
+ size_t num_in_arcs) const;
+
BufferFactory& _bufs;
uint32_t _index;
uint32_t _poly;
@@ -287,6 +299,7 @@ protected:
Raul::Array<Voice>* _voices;
Raul::Array<Voice>* _prepared_voices;
BufferRef _user_buffer;
+ std::atomic_flag _connected_flag;
bool _monitored;
bool _force_monitor_update;
bool _is_morph;