From b1198f0842e6e4d6b1c01f07d91b42ef4a212788 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 12 Feb 2017 15:04:20 +0100 Subject: Use smart pointers to handle real-time memory disposal --- src/server/internals/Note.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'src/server/internals/Note.cpp') diff --git a/src/server/internals/Note.cpp b/src/server/internals/Note.cpp index 564ae34c..cc592794 100644 --- a/src/server/internals/Note.cpp +++ b/src/server/internals/Note.cpp @@ -53,12 +53,11 @@ NoteNode::NoteNode(InternalPlugin* plugin, GraphImpl* parent, SampleRate srate) : InternalBlock(plugin, symbol, polyphonic, parent, srate) - , _voices(new Raul::Array(_polyphony)) - , _prepared_voices(NULL) + , _voices(bufs.maid().make_managed(_polyphony)) , _sustain(false) { const Ingen::URIs& uris = bufs.uris(); - _ports = new Raul::Array(8); + _ports = bufs.maid().make_managed(8); const Atom zero = bufs.forge().make(0.0f); const Atom one = bufs.forge().make(1.0f); @@ -131,7 +130,6 @@ NoteNode::NoteNode(InternalPlugin* plugin, NoteNode::~NoteNode() { - delete _voices; } bool @@ -145,22 +143,21 @@ NoteNode::prepare_poly(BufferFactory& bufs, uint32_t poly) if (_prepared_voices && poly <= _prepared_voices->size()) return true; - _prepared_voices = new Raul::Array(poly, *_voices, Voice()); + _prepared_voices = bufs.maid().make_managed( + poly, *_voices, Voice()); return true; } bool -NoteNode::apply_poly(RunContext& context, Raul::Maid& maid, uint32_t poly) +NoteNode::apply_poly(RunContext& context, uint32_t poly) { - if (!BlockImpl::apply_poly(context, maid, poly)) + if (!BlockImpl::apply_poly(context, poly)) return false; if (_prepared_voices) { assert(_polyphony <= _prepared_voices->size()); - maid.dispose(_voices); - _voices = _prepared_voices; - _prepared_voices = NULL; + _voices = std::move(_prepared_voices); } assert(_polyphony <= _voices->size()); -- cgit v1.2.1