From e7b2f7ee286350bc3bb56b44ed98e4d8bf49af82 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 13 Dec 2016 20:53:58 -0500 Subject: Fix real-time issues with buffer allocation --- src/server/InputPort.hpp | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'src/server/InputPort.hpp') diff --git a/src/server/InputPort.hpp b/src/server/InputPort.hpp index 1a27ac93..59e79463 100644 --- a/src/server/InputPort.hpp +++ b/src/server/InputPort.hpp @@ -85,14 +85,17 @@ public: ArcImpl* remove_arc(RunContext& context, const PortImpl* tail); - /** Set `voices` as the buffers to be used for this port. + /** Like `get_buffers`, but for the pre-process thread. * - * @return true iff buffers are locally owned by the port + * This uses the "current" number of arcs fromthe perspective of the + * pre-process thread to allocate buffers for application of a + * connection/disconnection/etc in the next process cycle. */ - bool get_buffers(BufferFactory& bufs, - Raul::Array* voices, - uint32_t poly, - bool real_time) const; + bool pre_get_buffers(BufferFactory& bufs, + Raul::Array* voices, + uint32_t poly) const; + + bool setup_buffers(RunContext& ctx, BufferFactory& bufs, uint32_t poly) override; /** Set up buffer pointers. */ void pre_process(RunContext& context); @@ -106,13 +109,19 @@ public: SampleCount next_value_offset(SampleCount offset, SampleCount end) const; void update_values(SampleCount offset, uint32_t voice); - size_t num_arcs() const { return _num_arcs; } ///< Pre-process thread - void increment_num_arcs() { ++_num_arcs; } - void decrement_num_arcs() { --_num_arcs; } + size_t num_arcs() const override { return _num_arcs; } + void increment_num_arcs() { ++_num_arcs; } + void decrement_num_arcs() { --_num_arcs; } bool direct_connect() const; protected: + bool get_buffers(BufferFactory& bufs, + PortImpl::GetFn get, + Raul::Array* voices, + uint32_t poly, + size_t num_in_arcs) const override; + size_t _num_arcs; ///< Pre-process thread Arcs _arcs; ///< Audio thread }; -- cgit v1.2.1