From 2d0f699e5ddaab31e936d3c76cbc59cef487987d Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 18 Oct 2008 21:33:59 +0000 Subject: Lower glib/glibmm dependency to 2.14. Fix optional parameters all over the palce because waf is retarded and sets failed check variables to ##some#stupid#name#like#this instead of false. Portability fixes (Ingen (except GUI) and all dependencies builds on OSX). git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@1681 a436a847-0d15-0410-975c-d299462d15a1 --- src/engine/AudioBuffer.cpp | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) (limited to 'src/engine/AudioBuffer.cpp') diff --git a/src/engine/AudioBuffer.cpp b/src/engine/AudioBuffer.cpp index f13e109f..5eb89855 100644 --- a/src/engine/AudioBuffer.cpp +++ b/src/engine/AudioBuffer.cpp @@ -44,6 +44,21 @@ AudioBuffer::AudioBuffer(size_t size) } +void +AudioBuffer::alloc_local_data(size_t size) +{ +#ifdef POSIX_MEMALIGN + const int ret = posix_memalign((void**)&_local_data, 16, size * sizeof(Sample)); +#else + _local_data = (Sample*)malloc(size * sizeof(Sample)); + int ret = (_local_data != NULL); +#endif + if (ret != 0) { + cerr << "[Buffer] Failed to allocate buffer. Aborting." << endl; + exit(EXIT_FAILURE); + } +} + void AudioBuffer::resize(size_t size) { @@ -54,14 +69,7 @@ AudioBuffer::resize(size_t size) const bool using_local_data = (_data == _local_data); deallocate(); - - const int ret = posix_memalign((void**)&_local_data, 16, _size * sizeof(Sample)); - if (ret != 0) { - cerr << "[Buffer] Failed to allocate buffer. Aborting." << endl; - exit(EXIT_FAILURE); - } - - assert(ret == 0); + alloc_local_data(_size * sizeof(Sample)); assert(_local_data); if (using_local_data) @@ -82,13 +90,7 @@ AudioBuffer::allocate() assert(_local_data == NULL); assert(_size > 0); - const int ret = posix_memalign((void**)&_local_data, 16, _size * sizeof(Sample)); - if (ret != 0) { - cerr << "[Buffer] Failed to allocate buffer. Aborting." << endl; - exit(EXIT_FAILURE); - } - - assert(ret == 0); + alloc_local_data(_size * sizeof(Sample)); assert(_local_data); _data = _local_data; -- cgit v1.2.1