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/BufferFactory.hpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src/server/BufferFactory.hpp') diff --git a/src/server/BufferFactory.hpp b/src/server/BufferFactory.hpp index ccb01899..09722b4e 100644 --- a/src/server/BufferFactory.hpp +++ b/src/server/BufferFactory.hpp @@ -50,12 +50,22 @@ public: uint32_t audio_buffer_size() const; uint32_t default_size(LV2_URID type) const; + /** Dynamically allocate a new Buffer. */ + BufferRef create(LV2_URID type, + LV2_URID value_type, + uint32_t capacity = 0); + + /** Get a new buffer, reusing if possible, allocating if otherwise. */ BufferRef get_buffer(LV2_URID type, LV2_URID value_type, - uint32_t capacity, - bool real_time, - bool force_create = false); + uint32_t capacity); + + /** Claim an existing buffer, never allocates, real-time safe. */ + BufferRef claim_buffer(LV2_URID type, + LV2_URID value_type, + uint32_t capacity); + /** Return a reference to a shared silent buffer. */ BufferRef silent_buffer(); void set_block_length(SampleCount block_length); @@ -69,7 +79,7 @@ private: friend class Buffer; void recycle(Buffer* buf); - BufferRef create(LV2_URID type, LV2_URID value_type, uint32_t capacity=0); + Buffer* try_get_buffer(LV2_URID type); inline std::atomic& free_list(LV2_URID type) { if (type == _uris.atom_Float) { -- cgit v1.2.1