From 99904735e066804358f1d0bd138a84f1e9ecda91 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 18 Mar 2007 06:07:08 +0000 Subject: Merged with trunk R1612. git-svn-id: svn://localhost/ardour2/branches/midi@1614 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/buffer.cc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'libs/ardour/buffer.cc') diff --git a/libs/ardour/buffer.cc b/libs/ardour/buffer.cc index d4a370685c..f13aa82207 100644 --- a/libs/ardour/buffer.cc +++ b/libs/ardour/buffer.cc @@ -22,6 +22,12 @@ using std::cerr; using std::endl; #include +#ifdef __x86_64__ +static const int CPU_CACHE_ALIGN = 64; +#else +static const int CPU_CACHE_ALIGN = 16; /* arguably 32 on most arches, but it matters less */ +#endif + namespace ARDOUR { @@ -47,7 +53,7 @@ AudioBuffer::AudioBuffer(size_t capacity) #ifdef NO_POSIX_MEMALIGN _data = (Sample *) malloc(sizeof(Sample) * capacity); #else - posix_memalign((void**)&_data, 16, sizeof(Sample) * capacity); + posix_memalign((void**)&_data, CPU_CACHE_ALIGN, sizeof(Sample) * capacity); #endif assert(_data); _owns_data = true; @@ -76,8 +82,8 @@ MidiBuffer::MidiBuffer(size_t capacity) _events = (MidiEvent *) malloc(sizeof(MidiEvent) * capacity); _data = (RawMidi *) malloc(sizeof(RawMidi) * capacity * MAX_EVENT_SIZE); #else - posix_memalign((void**)&_events, 16, sizeof(MidiEvent) * capacity); - posix_memalign((void**)&_data, 16, sizeof(RawMidi) * capacity * MAX_EVENT_SIZE); + posix_memalign((void**)&_events, CPU_CACHE_ALIGN, sizeof(MidiEvent) * capacity); + posix_memalign((void**)&_data, CPU_CACHE_ALIGN, sizeof(RawMidi) * capacity * MAX_EVENT_SIZE); #endif assert(_data); assert(_events); -- cgit v1.2.3