From 4c0a274b43687e4513c8c24f92dd581b064c2c4c Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 27 Nov 2013 17:41:22 -0500 Subject: [PATCH 1/6] do not push new state to backend from audio/MIDI setup until OK or Apply are clicked (i.e. do not do this when device is changed) --- gtk2_ardour/engine_dialog.cc | 12 ------------ gtk2_ardour/engine_dialog.h | 1 - 2 files changed, 13 deletions(-) diff --git a/gtk2_ardour/engine_dialog.cc b/gtk2_ardour/engine_dialog.cc index 37c29f4187..d438ff8327 100644 --- a/gtk2_ardour/engine_dialog.cc +++ b/gtk2_ardour/engine_dialog.cc @@ -87,7 +87,6 @@ EngineControl::EngineControl () , midi_refresh_button (_("Refresh list")) , ignore_changes (0) , _desired_sample_rate (0) - , no_push (true) , started_at_least_once (false) { using namespace Notebook_Helpers; @@ -290,8 +289,6 @@ EngineControl::EngineControl () output_channels.signal_changed().connect (sigc::mem_fun (*this, &EngineControl::parameter_changed)); notebook.signal_switch_page().connect (sigc::mem_fun (*this, &EngineControl::on_switch_page)); - - no_push = false; } void @@ -874,10 +871,6 @@ EngineControl::EngineControl () /* pick up any saved state for this device */ maybe_display_saved_state (); - - /* and push it to the backend */ - - push_state_to_backend (false); } string @@ -1207,14 +1200,9 @@ EngineControl::EngineControl () } } - int EngineControl::push_state_to_backend (bool start) { - if (no_push) { - return 0; - } - boost::shared_ptr backend = ARDOUR::AudioEngine::instance()->current_backend(); if (!backend) { diff --git a/gtk2_ardour/engine_dialog.h b/gtk2_ardour/engine_dialog.h index 31648b6dbb..6d10eb76ac 100644 --- a/gtk2_ardour/engine_dialog.h +++ b/gtk2_ardour/engine_dialog.h @@ -114,7 +114,6 @@ class EngineControl : public ArdourDialog, public PBD::ScopedConnectionList { uint32_t ignore_changes; uint32_t _desired_sample_rate; - bool no_push; bool started_at_least_once; void driver_changed (); From 1190f1d0e008e8097b5ad86ea01ecba1a8c4832f Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 27 Nov 2013 17:41:54 -0500 Subject: [PATCH 2/6] make JACK backend return the right set of values when asked for buffer sizes or sample rate of a device other than the one in use --- libs/backends/jack/jack_audiobackend.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libs/backends/jack/jack_audiobackend.cc b/libs/backends/jack/jack_audiobackend.cc index 332b6eec85..8df97a1e30 100644 --- a/libs/backends/jack/jack_audiobackend.cc +++ b/libs/backends/jack/jack_audiobackend.cc @@ -155,11 +155,11 @@ JACKAudioBackend::enumerate_devices () const } vector -JACKAudioBackend::available_sample_rates (const string& /*device*/) const +JACKAudioBackend::available_sample_rates (const string& device) const { vector f; - if (available()) { + if (device == _target_device && available()) { f.push_back (sample_rate()); return f; } @@ -183,11 +183,11 @@ JACKAudioBackend::available_sample_rates (const string& /*device*/) const } vector -JACKAudioBackend::available_buffer_sizes (const string& /*device*/) const +JACKAudioBackend::available_buffer_sizes (const string& device) const { vector s; - - if (available()) { + + if (device == _target_device && available()) { s.push_back (buffer_size()); return s; } From 074b0c4dca635227bb801f433189e66271b6abce Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Fri, 29 Nov 2013 22:24:37 -0500 Subject: [PATCH 3/6] add explicit linkage to libtimecode --- gtk2_ardour/wscript | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/gtk2_ardour/wscript b/gtk2_ardour/wscript index 3ca90744c7..b657e5fcd5 100644 --- a/gtk2_ardour/wscript +++ b/gtk2_ardour/wscript @@ -378,12 +378,13 @@ def build(bld): ../libs/fst/vstwin.c ../vst/winmain.c ''' - obj.uselib = 'ALSA' obj.use = [ 'libpbd', 'libmidipp', 'libtaglib', 'libardour', 'libardour_cp', + 'libtimecode', + 'libmidipp', 'libgtk2_ardour', 'libgtkmm2ext', 'libtaglib'] @@ -406,20 +407,22 @@ def build(bld): obj.source = gtk2_ardour_sources obj.target = 'ardour-' + bld.env['VERSION'] obj.includes = ['.'] + obj.use = [ 'libpbd', + 'libardour', + 'libardour_cp', + 'libtimecode', + 'libmidipp', + 'libgtk2_ardour', + 'libgtkmm2ext', + ] # continue with setup of obj, which could be a shared library # or an executable. obj.install_path = os.path.join(bld.env['LIBDIR'], 'ardour3') - - obj.uselib = 'UUID FLAC FONTCONFIG GLIBMM GTHREAD GTK OGG ALSA CURL DL' + obj.uselib = 'UUID FLAC FONTCONFIG GLIBMM GTHREAD GTK OGG CURL DL' obj.uselib += ' GTKMM GNOMECANVASMM GNOMECANVAS FFTW3F' obj.uselib += ' AUDIOUNITS OSX GTKOSX LO ' - obj.use = [ 'libpbd', - 'libmidipp', - 'ardour', - 'libardour_cp', - 'libgtkmm2ext'] if bld.is_defined('USE_EXTERNAL_LIBS'): obj.uselib += ' TAGLIB' else: From 146734526cbffc461a546feb32662495453d2296 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Fri, 29 Nov 2013 22:24:59 -0500 Subject: [PATCH 4/6] fix indentation --- libs/ardour/ardour/audio_buffer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/ardour/ardour/audio_buffer.h b/libs/ardour/ardour/audio_buffer.h index 42aba607f9..054a1f7b45 100644 --- a/libs/ardour/ardour/audio_buffer.h +++ b/libs/ardour/ardour/audio_buffer.h @@ -207,7 +207,7 @@ public: return _data + offset; } - bool check_silence (pframes_t, pframes_t&) const; + bool check_silence (pframes_t, pframes_t&) const; void prepare () { _written = false; _silent = false; } bool written() const { return _written; } From 0c4457fa8361d7678b09ec5911917750e7ade67e Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Fri, 29 Nov 2013 22:25:36 -0500 Subject: [PATCH 5/6] drop capacity argument from Buffer constructor, since the abstract class cannot (and should not) do anything with it --- libs/ardour/ardour/buffer.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/ardour/ardour/buffer.h b/libs/ardour/ardour/buffer.h index cbb92e7c4a..4570a7a663 100644 --- a/libs/ardour/ardour/buffer.h +++ b/libs/ardour/ardour/buffer.h @@ -80,8 +80,8 @@ public: virtual void merge_from (const Buffer& src, framecnt_t len, framecnt_t dst_offset = 0, framecnt_t src_offset = 0) = 0; protected: - Buffer(DataType type, size_t capacity) - : _type(type), _capacity(capacity), _size(0), _silent(true) + Buffer(DataType type) + : _type(type), _capacity(0), _size(0), _silent (true) {} DataType _type; From d1cc7e5a50e2144d7aea01bc5eceed6657513c1b Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Fri, 29 Nov 2013 22:26:33 -0500 Subject: [PATCH 6/6] fix up a bunch of confusion regarding the size/capacity/allocation of audio & midi buffers --- libs/ardour/audio_buffer.cc | 28 ++++++++++++++++++---------- libs/ardour/audio_port.cc | 9 +++------ libs/ardour/buffer_set.cc | 4 ++-- libs/ardour/midi_buffer.cc | 21 +++++++++++++-------- libs/ardour/thread_buffers.cc | 14 ++++++++------ 5 files changed, 44 insertions(+), 32 deletions(-) diff --git a/libs/ardour/audio_buffer.cc b/libs/ardour/audio_buffer.cc index 1fd0337dd1..a36ad81c2a 100644 --- a/libs/ardour/audio_buffer.cc +++ b/libs/ardour/audio_buffer.cc @@ -28,15 +28,15 @@ using namespace PBD; using namespace ARDOUR; AudioBuffer::AudioBuffer(size_t capacity) - : Buffer(DataType::AUDIO, capacity) + : Buffer (DataType::AUDIO) , _owns_data (false) , _data (0) { - if (_capacity > 0) { + if (capacity) { _owns_data = true; // prevent resize() from gagging - resize (_capacity); + resize (capacity); _silent = false; // force silence on the intial buffer state - silence (_capacity); + clear (); } } @@ -50,21 +50,29 @@ void AudioBuffer::resize (size_t size) { if (!_owns_data) { + /* XXX how the hell is this enforced? */ + _capacity = size; return; } - if (size < _capacity) { - _size = size; + if (_data && size < _capacity) { + /* buffer is already large enough */ + + if (size < _size) { + /* truncate */ + _size = size; + } + return; } free (_data); - _capacity = size; - _size = size; - _silent = false; + cache_aligned_malloc ((void**) &_data, sizeof (Sample) * size); - cache_aligned_malloc ((void**) &_data, sizeof (Sample) * _capacity); + _capacity = size; + _size = 0; + _silent = false; } bool diff --git a/libs/ardour/audio_port.cc b/libs/ardour/audio_port.cc index 6a86360b69..2fecbf9392 100644 --- a/libs/ardour/audio_port.cc +++ b/libs/ardour/audio_port.cc @@ -56,14 +56,11 @@ AudioPort::cycle_start (pframes_t nframes) } void -AudioPort::cycle_end (pframes_t) +AudioPort::cycle_end (pframes_t nframes) { if (sends_output() && !_buffer->written()) { - /* we can't use nframes here because the current buffer capacity may - be shorter than the full buffer size if we split the cycle. - */ - if (_buffer->capacity () > 0) { - _buffer->silence (_buffer->capacity()); + if (_buffer->capacity() >= nframes) { + _buffer->silence (nframes); } } } diff --git a/libs/ardour/buffer_set.cc b/libs/ardour/buffer_set.cc index e67aee6be7..227d7a1e95 100644 --- a/libs/ardour/buffer_set.cc +++ b/libs/ardour/buffer_set.cc @@ -167,7 +167,7 @@ BufferSet::ensure_buffers(DataType type, size_t num_buffers, size_t buffer_capac // If there's not enough or they're too small, just nuke the whole thing and // rebuild it (so I'm lazy..) if (bufs.size() < num_buffers - || (bufs.size() > 0 && bufs[0]->capacity() < buffer_capacity)) { + || (bufs.size() > 0 && bufs[0]->capacity() < buffer_capacity)) { // Nuke it for (BufferVec::iterator i = bufs.begin(); i != bufs.end(); ++i) { @@ -179,7 +179,7 @@ BufferSet::ensure_buffers(DataType type, size_t num_buffers, size_t buffer_capac for (size_t i = 0; i < num_buffers; ++i) { bufs.push_back(Buffer::create(type, buffer_capacity)); } - + _available.set(type, num_buffers); _count.set (type, num_buffers); } diff --git a/libs/ardour/midi_buffer.cc b/libs/ardour/midi_buffer.cc index d75b861ea1..1a6cb7fa26 100644 --- a/libs/ardour/midi_buffer.cc +++ b/libs/ardour/midi_buffer.cc @@ -33,12 +33,12 @@ using namespace PBD; // FIXME: mirroring for MIDI buffers? MidiBuffer::MidiBuffer(size_t capacity) - : Buffer(DataType::MIDI, capacity) - , _data(0) + : Buffer (DataType::MIDI) + , _data (0) { if (capacity) { - resize(_capacity); - silence(_capacity); + resize (capacity); + silence (capacity); } } @@ -50,17 +50,22 @@ MidiBuffer::~MidiBuffer() void MidiBuffer::resize(size_t size) { - assert(size > 0); + if (_data && size < _capacity) { + + if (_size < size) { + /* truncate */ + _size = size; + } - if (size < _capacity) { return; } - free(_data); + free (_data); + + cache_aligned_malloc ((void**) &_data, size); _size = 0; _capacity = size; - cache_aligned_malloc ((void**) &_data, _capacity); assert(_data); } diff --git a/libs/ardour/thread_buffers.cc b/libs/ardour/thread_buffers.cc index fd3160bb15..e469187ce9 100644 --- a/libs/ardour/thread_buffers.cc +++ b/libs/ardour/thread_buffers.cc @@ -60,7 +60,7 @@ ThreadBuffers::ensure_buffers (ChanCount howmany) for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) { size_t count = std::max (scratch_buffers->available().get(*t), howmany.get(*t)); - size_t size = _engine->raw_buffer_size (*t); + size_t size = _engine->raw_buffer_size (*t) / sizeof (Sample); scratch_buffers->ensure_buffers (*t, count, size); mix_buffers->ensure_buffers (*t, count, size); @@ -68,12 +68,14 @@ ThreadBuffers::ensure_buffers (ChanCount howmany) route_buffers->ensure_buffers (*t, count, size); } - delete [] gain_automation_buffer; - gain_automation_buffer = new gain_t[_engine->raw_buffer_size (DataType::AUDIO)]; - delete [] send_gain_automation_buffer; - send_gain_automation_buffer = new gain_t[_engine->raw_buffer_size (DataType::AUDIO)]; + size_t audio_buffer_size = _engine->raw_buffer_size (DataType::AUDIO) / sizeof (Sample); - allocate_pan_automation_buffers (_engine->raw_buffer_size (DataType::AUDIO), howmany.n_audio(), false); + delete [] gain_automation_buffer; + gain_automation_buffer = new gain_t[audio_buffer_size]; + delete [] send_gain_automation_buffer; + send_gain_automation_buffer = new gain_t[audio_buffer_size]; + + allocate_pan_automation_buffers (audio_buffer_size, howmany.n_audio(), false); } void