13
0

RT-safety use stack (not heap) for plugin pin mappings

This commit is contained in:
Robin Gareus 2020-03-06 19:13:54 +01:00
parent 50556db405
commit 77d12b490e
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
2 changed files with 7 additions and 4 deletions

View File

@ -25,13 +25,14 @@
#include <ostream>
#include <utility>
#include "pbd/stack_allocator.h"
#include "pbd/xml++.h"
#include "ardour/data_type.h"
#include "ardour/chan_count.h"
namespace ARDOUR {
/** A mapping from one set of channels to another.
* The general form is 1 source (from), many sinks (to).
* numeric IDs are used to identify sources and sinks.
@ -103,8 +104,8 @@ public:
*/
bool is_subset (const ChanMapping& superset) const;
typedef std::map<uint32_t, uint32_t> TypeMapping;
typedef std::map<DataType, TypeMapping> Mappings;
typedef std::map<uint32_t, uint32_t, std::less<uint32_t>, PBD::StackAllocator<std::pair<const uint32_t, uint32_t>, 16> > TypeMapping;
typedef std::map<DataType, TypeMapping, std::less<DataType>, PBD::StackAllocator<std::pair<const DataType, TypeMapping>, 2> > Mappings;
Mappings mappings() { return _mappings; }
const Mappings& mappings() const { return _mappings; }

View File

@ -29,6 +29,7 @@
#include <boost/weak_ptr.hpp>
#include "pbd/stack_allocator.h"
#include "pbd/timing.h"
#include "ardour/ardour.h"
@ -370,7 +371,8 @@ private:
/* ordered map [plugin instance ID] => ARDOUR::ChanMapping
* TODO: consider replacing with boost::flat_map<> or std::vector<>.
*/
class PinMappings : public std::map <uint32_t, ARDOUR::ChanMapping> {
class PinMappings : public std::map <uint32_t, ARDOUR::ChanMapping, std::less<uint32_t>, PBD::StackAllocator<std::pair<const uint32_t, ARDOUR::ChanMapping>, 4> >
{
public:
/* this emulates C++11's std::map::at()
* return mapping for given plugin instance */