summaryrefslogtreecommitdiffstats
path: root/src/engine/AudioBuffer.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2008-10-18 21:33:59 +0000
committerDavid Robillard <d@drobilla.net>2008-10-18 21:33:59 +0000
commit2d0f699e5ddaab31e936d3c76cbc59cef487987d (patch)
treed718003782ab00dc89249eed6d370f86aa782796 /src/engine/AudioBuffer.cpp
parenta4876d30d938322a48537be2d29e73fb64174c0a (diff)
downloadingen-2d0f699e5ddaab31e936d3c76cbc59cef487987d.tar.gz
ingen-2d0f699e5ddaab31e936d3c76cbc59cef487987d.tar.bz2
ingen-2d0f699e5ddaab31e936d3c76cbc59cef487987d.zip
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
Diffstat (limited to 'src/engine/AudioBuffer.cpp')
-rw-r--r--src/engine/AudioBuffer.cpp32
1 files changed, 17 insertions, 15 deletions
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
@@ -45,6 +45,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)
{
_size = 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;