*** NEW CODING POLICY ***
[ardour.git] / libs / ardour / buffer_set.cc
index 3dc580caa221b3da79ddc7e2d1e4709b18fb2ad0..a2dd1109413e67d9c32c6b507397c5220ce9765d 100644 (file)
     675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
+#include <iostream>
 #include <algorithm>
-#include <ardour/buffer_set.h>
-#include <ardour/buffer.h>
-#include <ardour/port.h>
-#include <ardour/port_set.h>
+#include "ardour/buffer_set.h"
+#include "ardour/buffer.h"
+#include "ardour/port.h"
+#include "ardour/port_set.h"
 
 namespace ARDOUR {
 
@@ -61,7 +62,7 @@ BufferSet::clear()
 /** Make this BufferSet a direct mirror of a PortSet's buffers.
  */
 void
-BufferSet::attach_buffers(PortSet& ports)
+BufferSet::attach_buffers(PortSet& ports, nframes_t nframes, nframes_t offset)
 {
        clear();
 
@@ -71,9 +72,8 @@ BufferSet::attach_buffers(PortSet& ports)
 
                for (PortSet::iterator p = ports.begin(*t); p != ports.end(*t); ++p) {
                        assert(p->type() == *t);
-                       v.push_back(&(p->get_buffer()));
+                       v.push_back(&(p->get_buffer(nframes, offset)));
                }
-
        }
        
        _count = ports.count();
@@ -103,6 +103,12 @@ BufferSet::ensure_buffers(DataType type, size_t num_buffers, size_t buffer_capac
        if (num_buffers == 0)
                return;
 
+       // FIXME: Kludge to make MIDI buffers larger (size is bytes, not frames)
+       // See MidiPort::MidiPort
+       // We probably need a map<DataType, size_t> parameter for capacity
+       if (type == DataType::MIDI)
+               buffer_capacity *= 8;
+
        // The vector of buffers of the type we care about
        BufferVec& bufs = _buffers[type];