summaryrefslogtreecommitdiff
path: root/libs/ardour/ardour/buffer.h
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2006-08-01 17:19:38 +0000
committerDavid Robillard <d@drobilla.net>2006-08-01 17:19:38 +0000
commit79fc27de2ef9db51a8c7c69764b663a9921c5a40 (patch)
tree09d5e86fa212f2b8dde0811b2c9e8cc7cfbc7136 /libs/ardour/ardour/buffer.h
parent9d5d82b4df5b3510177fd31557ac765f46778fe8 (diff)
Mostly Cosmetic/Design changes to bring trunk and midi branch closer
git-svn-id: svn://localhost/ardour2/branches/midi@733 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/ardour/buffer.h')
-rw-r--r--libs/ardour/ardour/buffer.h36
1 files changed, 21 insertions, 15 deletions
diff --git a/libs/ardour/ardour/buffer.h b/libs/ardour/ardour/buffer.h
index f0ad3be67e..cd36a06e36 100644
--- a/libs/ardour/ardour/buffer.h
+++ b/libs/ardour/ardour/buffer.h
@@ -45,12 +45,7 @@ namespace ARDOUR {
class Buffer
{
public:
- /** Unfortunately using RTTI and dynamic_cast to find the type of the
- * buffer is just too slow, this is done in very performance critical
- * bits of the code. */
- enum Type { NIL = 0, AUDIO, MIDI };
-
- Buffer(Type type, size_t capacity)
+ Buffer(DataType type, size_t capacity)
: _type(type), _capacity(capacity), _size(0)
{}
@@ -65,7 +60,7 @@ public:
/** Type of this buffer.
* Based on this you can static cast a Buffer* to the desired type. */
- virtual Type type() const { return _type; }
+ virtual DataType type() const { return _type; }
/** Jack type (eg JACK_DEFAULT_AUDIO_TYPE) */
const char* jack_type() const { return type_to_jack_type(type()); }
@@ -74,8 +69,11 @@ public:
const char* type_string() const { return type_to_string(type()); }
/* The below static methods need to be separate from the above methods
- * because the conversion is needed in places where there's no Buffer */
- static const char* type_to_jack_type(Type t) {
+ * because the conversion is needed in places where there's no Buffer.
+ * These should probably live somewhere else...
+ */
+
+ static const char* type_to_jack_type(DataType t) {
switch (t) {
case AUDIO: return JACK_DEFAULT_AUDIO_TYPE;
case MIDI: return JACK_DEFAULT_MIDI_TYPE;
@@ -83,7 +81,7 @@ public:
}
}
- static const char* type_to_string(Type t) {
+ static const char* type_to_string(DataType t) {
switch (t) {
case AUDIO: return "audio";
case MIDI: return "midi";
@@ -92,7 +90,7 @@ public:
}
/** Used for loading from XML (route default types etc) */
- static Type type_from_string(const string& str) {
+ static DataType type_from_string(const string& str) {
if (str == "audio")
return AUDIO;
else if (str == "midi")
@@ -102,9 +100,9 @@ public:
}
protected:
- Type _type;
- size_t _capacity;
- size_t _size;
+ DataType _type;
+ size_t _capacity;
+ size_t _size;
};
@@ -119,8 +117,12 @@ public:
: Buffer(AUDIO, capacity)
, _data(NULL)
{
- _size = capacity; // For audio buffers, size = capacity always
+ _size = capacity; // For audio buffers, size = capacity (always)
+#ifdef NO_POSIX_MEMALIGN
+ b = (Sample *) malloc(sizeof(Sample) * capacity);
+#else
posix_memalign((void**)_data, 16, sizeof(Sample) * capacity);
+#endif
assert(_data);
memset(_data, 0, sizeof(Sample) * capacity);
}
@@ -146,7 +148,11 @@ public:
: Buffer(MIDI, capacity)
, _data(NULL)
{
+#ifdef NO_POSIX_MEMALIGN
+ b = (Sample *) malloc(sizeof(RawMidi) * capacity);
+#else
posix_memalign((void**)_data, 16, sizeof(RawMidi) * capacity);
+#endif
assert(_data);
assert(_size == 0);
memset(_data, 0, sizeof(Sample) * capacity);