diff --git a/libs/ardour/ardour/export_channel.h b/libs/ardour/ardour/export_channel.h index 9a570f71ba..273e2ec258 100644 --- a/libs/ardour/ardour/export_channel.h +++ b/libs/ardour/ardour/export_channel.h @@ -32,6 +32,7 @@ #include "pbd/ringbuffer.h" #include "pbd/signals.h" +#include "ardour/audio_buffer.h" #include "ardour/buffer_set.h" #include "ardour/export_pointers.h" @@ -52,7 +53,7 @@ public: virtual samplecnt_t common_port_playback_latency () const { return 0; } virtual void prepare_export (samplecnt_t max_samples, sampleoffset_t common_latency) {} - virtual void read (Sample const*& data, samplecnt_t samples) const = 0; + virtual void read (Buffer const*&, samplecnt_t samples) const = 0; virtual bool empty () const = 0; @@ -78,7 +79,7 @@ public: samplecnt_t common_port_playback_latency () const; void prepare_export (samplecnt_t max_samples, sampleoffset_t common_latency); - void read (Sample const*& data, samplecnt_t samples) const; + void read (Buffer const*&, samplecnt_t samples) const; bool empty () const { return ports.empty (); } @@ -94,6 +95,7 @@ private: PortSet ports; samplecnt_t _buffer_size; boost::scoped_array _buffer; + mutable AudioBuffer _buf; std::list>> _delaylines; }; @@ -112,7 +114,7 @@ public: ExportChannelPtr create (uint32_t channel); - void read (uint32_t channel, Sample const*& data, samplecnt_t samples_to_read); + void read (uint32_t channel, Buffer const*&, samplecnt_t samples_to_read); private: int new_cycle_started (samplecnt_t) @@ -145,9 +147,9 @@ class LIBARDOUR_API RegionExportChannel : public ExportChannel friend class RegionExportChannelFactory; public: - void read (Sample const*& data, samplecnt_t samples_to_read) const + void read (Buffer const*& buf, samplecnt_t samples_to_read) const { - factory.read (channel, data, samples_to_read); + factory.read (channel, buf, samples_to_read); } void get_state (XMLNode* /*node*/) const {}; @@ -188,7 +190,7 @@ public: public: // ExportChannel interface void prepare_export (samplecnt_t max_samples, sampleoffset_t common_latency); - void read (Sample const*& data, samplecnt_t samples) const; + void read (Buffer const*&, samplecnt_t samples) const; bool empty () const { return false; } diff --git a/libs/ardour/export_channel.cc b/libs/ardour/export_channel.cc index f2e2587b14..e3e217f287 100644 --- a/libs/ardour/export_channel.cc +++ b/libs/ardour/export_channel.cc @@ -38,6 +38,7 @@ using namespace ARDOUR; PortExportChannel::PortExportChannel () : _buffer_size (0) + , _buf (0) { } @@ -101,7 +102,7 @@ PortExportChannel::operator< (ExportChannel const& other) const } void -PortExportChannel::read (Sample const*& data, samplecnt_t samples) const +PortExportChannel::read (Buffer const*& buf, samplecnt_t samples) const { assert (_buffer); assert (samples <= _buffer_size); @@ -109,8 +110,8 @@ PortExportChannel::read (Sample const*& data, samplecnt_t samples) const if (ports.size () == 1 && _delaylines.size () == 1 && _delaylines.front ()->bufsize () == _buffer_size + 1) { boost::shared_ptr p = ports.begin ()->lock (); AudioBuffer& ab (p->get_audio_buffer (samples)); // unsets AudioBuffer::_written - data = ab.data (); ab.set_written (true); + buf = &ab; return; } @@ -143,7 +144,8 @@ PortExportChannel::read (Sample const*& data, samplecnt_t samples) const ++di; } - data = _buffer.get (); + _buf.set_data (_buffer.get(), samples); + buf = &_buf; } void @@ -217,7 +219,7 @@ RegionExportChannelFactory::create (uint32_t channel) } void -RegionExportChannelFactory::read (uint32_t channel, Sample const*& data, samplecnt_t samples_to_read) +RegionExportChannelFactory::read (uint32_t channel, Buffer const*& buf, samplecnt_t samples_to_read) { assert (channel < n_channels); assert (samples_to_read <= samples_per_cycle); @@ -227,7 +229,7 @@ RegionExportChannelFactory::read (uint32_t channel, Sample const*& data, samplec buffers_up_to_date = true; } - data = buffers.get_audio (channel).data (); + buf = &buffers.get_audio (channel); } void @@ -290,7 +292,7 @@ RouteExportChannel::prepare_export (samplecnt_t max_samples, sampleoffset_t) } void -RouteExportChannel::read (Sample const*& data, samplecnt_t samples) const +RouteExportChannel::read (Buffer const*& buf, samplecnt_t samples) const { assert (processor); AudioBuffer const& buffer = processor->get_capture_buffers ().get_audio (channel); @@ -299,7 +301,7 @@ RouteExportChannel::read (Sample const*& data, samplecnt_t samples) const #else assert (samples <= (samplecnt_t)buffer.capacity ()); #endif - data = buffer.data (); + buf = &buffer; } void diff --git a/libs/ardour/export_graph_builder.cc b/libs/ardour/export_graph_builder.cc index 9fdfe5bb20..dd14166b61 100644 --- a/libs/ardour/export_graph_builder.cc +++ b/libs/ardour/export_graph_builder.cc @@ -86,8 +86,12 @@ ExportGraphBuilder::process (samplecnt_t samples, bool last_cycle) sampleoffset_t off = 0; for (ChannelMap::iterator it = channels.begin(); it != channels.end(); ++it) { - Sample const * process_buffer = 0; - it->first->read (process_buffer, samples); + // TODO special case MIDI.. + Buffer const* buf; + it->first->read (buf, samples); + AudioBuffer const* ab = dynamic_cast (buf); + assert (ab); + Sample const* process_buffer = ab->data (); if (session.remaining_latency_preroll () >= _master_align + samples) { /* Skip processing during pre-roll, only read/write export ringbuffers */