}
AudioBuffer& get_audio_buffer (pframes_t nframes);
+ void set_buffer_size (pframes_t nframes);
protected:
friend class PortManager;
virtual void flush_buffers (pframes_t /*nframes*/) {}
virtual void transport_stopped () {}
virtual void realtime_locate () {}
+ virtual void set_buffer_size (pframes_t) {}
bool physically_connected () const;
uint32_t externally_connected () const { return _externally_connected; }
void fill_midi_port_info_locked ();
void filter_midi_ports (std::vector<std::string>&, MidiPortFlags, MidiPortFlags);
+
+ void set_port_buffer_sizes (pframes_t);
};
#include "ardour/audio_port.h"
#include "ardour/data_type.h"
#include "ardour/port_engine.h"
+#include "ardour/rc_configuration.h"
using namespace ARDOUR;
using namespace std;
AudioPort::AudioPort (const std::string& name, PortFlags flags)
: Port (name, DataType::AUDIO, flags)
, _buffer (new AudioBuffer (0))
+ , _data (0)
{
assert (name.find_first_of (':') == string::npos);
- cache_aligned_malloc ((void**) &_data, sizeof (Sample) * 8192);
_src.setup (_resampler_quality);
_src.set_rrfilt (10);
}
AudioPort::~AudioPort ()
{
- cache_aligned_free (_data);
+ if (_data) cache_aligned_free (_data);
delete _buffer;
}
+void
+AudioPort::set_buffer_size (pframes_t nframes)
+{
+ if (_data) cache_aligned_free (_data);
+ cache_aligned_malloc ((void**) &_data, sizeof (Sample) * lrint (floor (nframes * Config->get_max_transport_speed())));
+}
+
void
AudioPort::cycle_start (pframes_t nframes)
{
int
AudioEngine::buffer_size_change (pframes_t bufsiz)
{
+ set_port_buffer_sizes (bufsiz);
+
if (_session) {
_session->set_block_size (bufsiz);
last_monitor_check = 0;
#include "pbd/compose.h"
#include "pbd/error.h"
#include "pbd/failed_constructor.h"
+#include "pbd/i18n.h"
#include "ardour/audioengine.h"
#include "ardour/debug.h"
#include "ardour/port.h"
#include "ardour/port_engine.h"
-
-#include "pbd/i18n.h"
+#include "ardour/rc_configuration.h"
using namespace std;
using namespace ARDOUR;
/*static*/ void
Port::set_speed_ratio (double s) {
/* see VMResampler::set_rratio() for min/max range */
- _speed_ratio = std::min (16.0, std::max (0.5, s));
+ _speed_ratio = std::min ((double) Config->get_max_transport_speed(), std::max (0.5, s));
}
/*static*/ void
-Port::set_cycle_samplecnt (pframes_t n) {
+Port::set_cycle_samplecnt (pframes_t n)
+{
_cycle_nframes = floor (n * _speed_ratio);
}
throw PortRegistrationFailure (string_compose ("unable to create port '%1': %2", portname, _("(unknown type)")));
}
+ newport->set_buffer_size (AudioEngine::instance()->samples_per_cycle());
+
RCUWriter<Ports> writer (ports);
boost::shared_ptr<Ports> ps = writer.get_copy ();
ps->insert (make_pair (make_port_name_relative (portname), newport));
/* writer goes out of scope, forces update */
-
}
catch (PortRegistrationFailure& err) {
midi_info_dirty = false;
}
+
+void
+PortManager::set_port_buffer_sizes (pframes_t n)
+{
+
+ boost::shared_ptr<Ports> all = ports.reader();
+
+ for (Ports::iterator p = all->begin(); p != all->end(); ++p) {
+ p->second->set_buffer_size (n);
+ }
+}