NO-OP: re-indent, and cleanup

This commit is contained in:
Robin Gareus 2022-05-14 18:18:33 +02:00
parent 4339e3c729
commit 86597d7e1c
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
4 changed files with 247 additions and 217 deletions

View File

@ -23,14 +23,14 @@
#ifndef __ardour_export_channel_h__ #ifndef __ardour_export_channel_h__
#define __ardour_export_channel_h__ #define __ardour_export_channel_h__
#include <set>
#include <list> #include <list>
#include <set>
#include <boost/scoped_array.hpp> #include <boost/scoped_array.hpp>
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
#include "pbd/signals.h"
#include "pbd/ringbuffer.h" #include "pbd/ringbuffer.h"
#include "pbd/signals.h"
#include "ardour/buffer_set.h" #include "ardour/buffer_set.h"
#include "ardour/export_pointers.h" #include "ardour/export_pointers.h"
@ -46,85 +46,90 @@ class CapturingProcessor;
/// Export channel base class interface for different source types /// Export channel base class interface for different source types
class LIBARDOUR_API ExportChannel : public boost::less_than_comparable<ExportChannel> class LIBARDOUR_API ExportChannel : public boost::less_than_comparable<ExportChannel>
{ {
public: public:
virtual ~ExportChannel () {} virtual ~ExportChannel () {}
virtual samplecnt_t common_port_playback_latency () const { return 0; } virtual samplecnt_t common_port_playback_latency () const { return 0; }
virtual void prepare_export (samplecnt_t max_samples, sampleoffset_t common_latency) { } 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 (Sample const *& data, samplecnt_t samples) const = 0;
virtual bool empty () const = 0; virtual bool empty () const = 0;
/// Adds state to node passed /// Adds state to node passed
virtual void get_state (XMLNode * node) const = 0; virtual void get_state (XMLNode* node) const = 0;
/// Sets state from node passed /// Sets state from node passed
virtual void set_state (XMLNode * node, Session & session) = 0; virtual void set_state (XMLNode* node, Session& session) = 0;
// Operator< must be defined for usage in e.g. std::map or std::set to disallow duplicates when necessary // Operator< must be defined for usage in e.g. std::map or std::set to disallow duplicates when necessary
virtual bool operator< (ExportChannel const & other) const = 0; virtual bool operator< (ExportChannel const& other) const = 0;
}; };
/// Basic export channel that reads from AudioPorts /// Basic export channel that reads from AudioPorts
class LIBARDOUR_API PortExportChannel : public ExportChannel class LIBARDOUR_API PortExportChannel : public ExportChannel
{ {
public: public:
typedef std::set<boost::weak_ptr<AudioPort> > PortSet; typedef std::set<boost::weak_ptr<AudioPort>> PortSet;
PortExportChannel (); PortExportChannel ();
~PortExportChannel (); ~PortExportChannel ();
samplecnt_t common_port_playback_latency () const; samplecnt_t common_port_playback_latency () const;
void prepare_export (samplecnt_t max_samples, sampleoffset_t common_latency); void prepare_export (samplecnt_t max_samples, sampleoffset_t common_latency);
void read (Sample const *& data, samplecnt_t samples) const; void read (Sample const*& data, samplecnt_t samples) const;
bool empty () const { return ports.empty(); }
void get_state (XMLNode * node) const; bool empty () const { return ports.empty (); }
void set_state (XMLNode * node, Session & session);
bool operator< (ExportChannel const & other) const; void get_state (XMLNode* node) const;
void set_state (XMLNode* node, Session& session);
bool operator< (ExportChannel const& other) const;
void add_port (boost::weak_ptr<AudioPort> port) { ports.insert (port); } void add_port (boost::weak_ptr<AudioPort> port) { ports.insert (port); }
PortSet const & get_ports () { return ports; } PortSet const& get_ports () { return ports; }
private: private:
PortSet ports; PortSet ports;
samplecnt_t _buffer_size; samplecnt_t _buffer_size;
boost::scoped_array<Sample> _buffer; boost::scoped_array<Sample> _buffer;
std::list <boost::shared_ptr<PBD::RingBuffer<Sample> > > _delaylines; std::list<boost::shared_ptr<PBD::RingBuffer<Sample>>> _delaylines;
}; };
/// Handles RegionExportChannels and does actual reading from region /// Handles RegionExportChannels and does actual reading from region
class LIBARDOUR_API RegionExportChannelFactory class LIBARDOUR_API RegionExportChannelFactory
{ {
public: public:
enum Type { enum Type {
None, None,
Raw, Raw,
Fades, Fades,
}; };
RegionExportChannelFactory (Session * session, AudioRegion const & region, AudioTrack & track, Type type); RegionExportChannelFactory (Session* session, AudioRegion const& region, AudioTrack& track, Type type);
~RegionExportChannelFactory (); ~RegionExportChannelFactory ();
ExportChannelPtr create (uint32_t channel); ExportChannelPtr create (uint32_t channel);
void read (uint32_t channel, Sample const *& data, samplecnt_t samples_to_read);
private: void read (uint32_t channel, Sample const*& data, samplecnt_t samples_to_read);
private:
int new_cycle_started (samplecnt_t)
{
buffers_up_to_date = false;
return 0;
}
int new_cycle_started (samplecnt_t) { buffers_up_to_date = false; return 0; }
void update_buffers (samplecnt_t samples); void update_buffers (samplecnt_t samples);
AudioRegion const & region; AudioRegion const& region;
Type type;
Type type;
samplecnt_t samples_per_cycle; samplecnt_t samples_per_cycle;
size_t n_channels; size_t n_channels;
BufferSet buffers; BufferSet buffers;
bool buffers_up_to_date; bool buffers_up_to_date;
samplepos_t region_start; samplepos_t region_start;
samplepos_t position; samplepos_t position;
@ -139,23 +144,32 @@ class LIBARDOUR_API RegionExportChannel : public ExportChannel
{ {
friend class RegionExportChannelFactory; friend class RegionExportChannelFactory;
public: public:
void read (Sample const *& data, samplecnt_t samples_to_read) const { factory.read (channel, data, samples_to_read); } void read (Sample const*& data, samplecnt_t samples_to_read) const
void get_state (XMLNode * /*node*/) const {}; {
void set_state (XMLNode * /*node*/, Session & /*session*/) {}; factory.read (channel, data, samples_to_read);
}
void get_state (XMLNode* /*node*/) const {};
void set_state (XMLNode* /*node*/, Session& /*session*/){};
bool empty () const { return false; } bool empty () const { return false; }
// Region export should never have duplicate channels, so there need not be any semantics here // Region export should never have duplicate channels, so there need not be any semantics here
bool operator< (ExportChannel const & other) const { return this < &other; } bool operator< (ExportChannel const& other) const
{
return this < &other;
}
private: private:
RegionExportChannel (RegionExportChannelFactory& factory, uint32_t channel)
RegionExportChannel (RegionExportChannelFactory & factory, uint32_t channel)
: factory (factory) : factory (factory)
, channel (channel) , channel (channel)
{} {
}
RegionExportChannelFactory & factory; RegionExportChannelFactory& factory;
uint32_t channel; uint32_t channel;
}; };
/// Export channel for exporting from different positions in a route /// Export channel for exporting from different positions in a route
@ -163,39 +177,45 @@ class LIBARDOUR_API RouteExportChannel : public ExportChannel
{ {
class ProcessorRemover; // fwd declaration class ProcessorRemover; // fwd declaration
public: public:
RouteExportChannel(boost::shared_ptr<CapturingProcessor> processor, size_t channel, RouteExportChannel (boost::shared_ptr<CapturingProcessor> processor,
boost::shared_ptr<ProcessorRemover> remover); size_t channel,
~RouteExportChannel(); boost::shared_ptr<ProcessorRemover> remover);
~RouteExportChannel ();
static void create_from_route(std::list<ExportChannelPtr> & result, boost::shared_ptr<Route> route); static void create_from_route (std::list<ExportChannelPtr>& result, boost::shared_ptr<Route> route);
public: // ExportChannel interface public: // ExportChannel interface
void prepare_export (samplecnt_t max_samples, sampleoffset_t common_latency); void prepare_export (samplecnt_t max_samples, sampleoffset_t common_latency);
void read (Sample const *& data, samplecnt_t samples) const; void read (Sample const*& data, samplecnt_t samples) const;
bool empty () const { return false; } bool empty () const { return false; }
void get_state (XMLNode * node) const; void get_state (XMLNode* node) const;
void set_state (XMLNode * node, Session & session); void set_state (XMLNode* node, Session& session);
bool operator< (ExportChannel const & other) const; bool operator< (ExportChannel const& other) const;
private:
private:
// Removes the processor from the track when deleted // Removes the processor from the track when deleted
class ProcessorRemover { class ProcessorRemover
public: {
ProcessorRemover (boost::shared_ptr<Route> route, boost::shared_ptr<CapturingProcessor> processor) public:
: route (route), processor (processor) {} ProcessorRemover (boost::shared_ptr<Route> route, boost::shared_ptr<CapturingProcessor> processor)
~ProcessorRemover(); : route (route)
private: , processor (processor)
boost::shared_ptr<Route> route; {
boost::shared_ptr<CapturingProcessor> processor; }
~ProcessorRemover ();
private:
boost::shared_ptr<Route> route;
boost::shared_ptr<CapturingProcessor> processor;
}; };
boost::shared_ptr<CapturingProcessor> processor; boost::shared_ptr<CapturingProcessor> processor;
size_t channel; size_t channel;
// Each channel keeps a ref to the remover. Last one alive // Each channel keeps a ref to the remover. Last one alive
// will cause the processor to be removed on deletion. // will cause the processor to be removed on deletion.
boost::shared_ptr<ProcessorRemover> remover; boost::shared_ptr<ProcessorRemover> remover;

View File

@ -21,9 +21,9 @@
#ifndef __ardour_export_channel_configuration_h__ #ifndef __ardour_export_channel_configuration_h__
#define __ardour_export_channel_configuration_h__ #define __ardour_export_channel_configuration_h__
#include <algorithm>
#include <list> #include <list>
#include <string> #include <string>
#include <algorithm>
#include <boost/enable_shared_from_this.hpp> #include <boost/enable_shared_from_this.hpp>
@ -32,57 +32,61 @@
#include "pbd/xml++.h" #include "pbd/xml++.h"
namespace ARDOUR namespace ARDOUR {
{
class Session; class Session;
class LIBARDOUR_API ExportChannelConfiguration : public boost::enable_shared_from_this<ExportChannelConfiguration> class LIBARDOUR_API ExportChannelConfiguration : public boost::enable_shared_from_this<ExportChannelConfiguration>
{ {
private:
private:
friend class ExportElementFactory; friend class ExportElementFactory;
ExportChannelConfiguration (Session & session); ExportChannelConfiguration (Session& session);
public: public:
bool operator== (ExportChannelConfiguration const & other) const { return channels == other.channels; } bool operator== (ExportChannelConfiguration const& other) const
bool operator!= (ExportChannelConfiguration const & other) const { return channels != other.channels; } {
return channels == other.channels;
}
bool operator!= (ExportChannelConfiguration const& other) const
{
return channels != other.channels;
}
XMLNode & get_state () const; XMLNode& get_state () const;
int set_state (const XMLNode &); int set_state (const XMLNode&);
typedef std::list<ExportChannelPtr> ChannelList; typedef std::list<ExportChannelPtr> ChannelList;
ChannelList const & get_channels () const { return channels; }
bool all_channels_have_ports () const; bool all_channels_have_ports () const;
std::string name () const { return _name; } std::string name () const { return _name; }
void set_name (std::string name) { _name = name; } void set_name (std::string name) { _name = name; }
void set_split (bool value) { split = value; }
RegionExportChannelFactory::Type region_processing_type() const { return region_type; } RegionExportChannelFactory::Type region_processing_type () const { return region_type; }
void set_region_processing_type(RegionExportChannelFactory::Type type) { region_type = type; } void set_region_processing_type (RegionExportChannelFactory::Type type) { region_type = type; }
bool get_split () const { return split; } bool get_split () const { return split; }
uint32_t get_n_chans () const { return channels.size(); } void set_split (bool value) { split = value; }
void register_channel (ExportChannelPtr channel) { channels.push_back (channel); } uint32_t get_n_chans () const { return channels.size (); }
void register_channels (ChannelList const & new_channels) { ChannelList const& get_channels () const { return channels; }
std::copy (new_channels.begin(), new_channels.end(), std::back_inserter(channels));
}
void clear_channels () { channels.clear (); } void clear_channels () { channels.clear (); }
void register_channel (ExportChannelPtr channel) { channels.push_back (channel); }
void register_channels (ChannelList const& new_channels)
{
std::copy (new_channels.begin (), new_channels.end (), std::back_inserter (channels));
}
/** Returns a list of channel configurations that match the files created. /** Returns a list of channel configurations that match the files created.
* I.e. many configurations if splitting is enabled, one if not. */ * I.e. many configurations if splitting is enabled, one if not. */
void configurations_for_files (std::list<boost::shared_ptr<ExportChannelConfiguration> > & configs); void configurations_for_files (std::list<boost::shared_ptr<ExportChannelConfiguration>>& configs);
private: private:
Session& session;
Session & session; ChannelList channels;
bool split; // Split to mono files
ChannelList channels; std::string _name;
bool split; // Split to mono files
std::string _name;
RegionExportChannelFactory::Type region_type; RegionExportChannelFactory::Type region_type;
}; };

View File

@ -20,13 +20,13 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
#include "ardour/export_channel.h"
#include "ardour/audio_buffer.h" #include "ardour/audio_buffer.h"
#include "ardour/audio_port.h" #include "ardour/audio_port.h"
#include "ardour/audio_track.h" #include "ardour/audio_track.h"
#include "ardour/audioengine.h" #include "ardour/audioengine.h"
#include "ardour/audioregion.h" #include "ardour/audioregion.h"
#include "ardour/capturing_processor.h" #include "ardour/capturing_processor.h"
#include "ardour/export_channel.h"
#include "ardour/export_failed.h" #include "ardour/export_failed.h"
#include "ardour/session.h" #include "ardour/session.h"
@ -46,17 +46,20 @@ PortExportChannel::~PortExportChannel ()
_delaylines.clear (); _delaylines.clear ();
} }
samplecnt_t PortExportChannel::common_port_playback_latency () const samplecnt_t
PortExportChannel::common_port_playback_latency () const
{ {
samplecnt_t l = 0; samplecnt_t l = 0;
bool first = true; bool first = true;
for (PortSet::const_iterator it = ports.begin(); it != ports.end(); ++it) { for (PortSet::const_iterator it = ports.begin (); it != ports.end (); ++it) {
boost::shared_ptr<AudioPort> p = it->lock (); boost::shared_ptr<AudioPort> p = it->lock ();
if (!p) { continue; } if (!p) {
continue;
}
samplecnt_t latency = p->private_latency_range (true).max; samplecnt_t latency = p->private_latency_range (true).max;
if (first) { if (first) {
first = false; first = false;
l = p->private_latency_range (true).max; l = p->private_latency_range (true).max;
continue; continue;
} }
l = std::min (l, latency); l = std::min (l, latency);
@ -64,60 +67,63 @@ samplecnt_t PortExportChannel::common_port_playback_latency () const
return l; return l;
} }
void PortExportChannel::prepare_export (samplecnt_t max_samples, sampleoffset_t common_latency) void
PortExportChannel::prepare_export (samplecnt_t max_samples, sampleoffset_t common_latency)
{ {
_buffer_size = max_samples; _buffer_size = max_samples;
_buffer.reset (new Sample[max_samples]); _buffer.reset (new Sample[max_samples]);
_delaylines.clear (); _delaylines.clear ();
for (PortSet::const_iterator it = ports.begin(); it != ports.end(); ++it) { for (PortSet::const_iterator it = ports.begin (); it != ports.end (); ++it) {
boost::shared_ptr<AudioPort> p = it->lock (); boost::shared_ptr<AudioPort> p = it->lock ();
if (!p) { continue; } if (!p) {
samplecnt_t latency = p->private_latency_range (true).max - common_latency; continue;
PBD::RingBuffer<Sample>* rb = new PBD::RingBuffer<Sample> (latency + 1 + _buffer_size); }
samplecnt_t latency = p->private_latency_range (true).max - common_latency;
PBD::RingBuffer<Sample>* rb = new PBD::RingBuffer<Sample> (latency + 1 + _buffer_size);
for (samplepos_t i = 0; i < latency; ++i) { for (samplepos_t i = 0; i < latency; ++i) {
Sample zero = 0; Sample zero = 0;
rb->write (&zero, 1); rb->write (&zero, 1);
} }
_delaylines.push_back (boost::shared_ptr<PBD::RingBuffer<Sample> >(rb)); _delaylines.push_back (boost::shared_ptr<PBD::RingBuffer<Sample>> (rb));
} }
} }
bool bool
PortExportChannel::operator< (ExportChannel const & other) const PortExportChannel::operator< (ExportChannel const& other) const
{ {
PortExportChannel const * pec; PortExportChannel const* pec;
if (!(pec = dynamic_cast<PortExportChannel const *> (&other))) { if (!(pec = dynamic_cast<PortExportChannel const*> (&other))) {
return this < &other; return this < &other;
} }
return ports < pec->ports; return ports < pec->ports;
} }
void void
PortExportChannel::read (Sample const *& data, samplecnt_t samples) const PortExportChannel::read (Sample const*& data, samplecnt_t samples) const
{ {
assert(_buffer); assert (_buffer);
assert(samples <= _buffer_size); assert (samples <= _buffer_size);
if (ports.size() == 1 && _delaylines.size() ==1 && _delaylines.front()->bufsize () == _buffer_size + 1) { if (ports.size () == 1 && _delaylines.size () == 1 && _delaylines.front ()->bufsize () == _buffer_size + 1) {
boost::shared_ptr<AudioPort> p = ports.begin()->lock (); boost::shared_ptr<AudioPort> p = ports.begin ()->lock ();
AudioBuffer& ab (p->get_audio_buffer(samples)); // unsets AudioBuffer::_written AudioBuffer& ab (p->get_audio_buffer (samples)); // unsets AudioBuffer::_written
data = ab.data(); data = ab.data ();
ab.set_written (true); ab.set_written (true);
return; return;
} }
memset (_buffer.get(), 0, samples * sizeof (Sample)); memset (_buffer.get (), 0, samples * sizeof (Sample));
std::list <boost::shared_ptr<PBD::RingBuffer<Sample> > >::const_iterator di = _delaylines.begin (); std::list<boost::shared_ptr<PBD::RingBuffer<Sample>>>::const_iterator di = _delaylines.begin ();
for (PortSet::const_iterator it = ports.begin(); it != ports.end(); ++it) { for (PortSet::const_iterator it = ports.begin (); it != ports.end (); ++it) {
boost::shared_ptr<AudioPort> p = it->lock (); boost::shared_ptr<AudioPort> p = it->lock ();
if (!p) { if (!p) {
continue; continue;
} }
AudioBuffer& ab (p->get_audio_buffer(samples)); // unsets AudioBuffer::_written AudioBuffer& ab (p->get_audio_buffer (samples)); // unsets AudioBuffer::_written
Sample* port_buffer = ab.data(); Sample* port_buffer = ab.data ();
ab.set_written (true); ab.set_written (true);
(*di)->write (port_buffer, samples); (*di)->write (port_buffer, samples);
@ -125,10 +131,10 @@ PortExportChannel::read (Sample const *& data, samplecnt_t samples) const
(*di)->get_read_vector (&vec); (*di)->get_read_vector (&vec);
assert (vec.len[0] + vec.len[1] >= samples); assert (vec.len[0] + vec.len[1] >= samples);
samplecnt_t to_write = std::min (samples, (samplecnt_t) vec.len[0]); samplecnt_t to_write = std::min (samples, (samplecnt_t)vec.len[0]);
mix_buffers_no_gain (&_buffer[0], vec.buf[0], to_write); mix_buffers_no_gain (&_buffer[0], vec.buf[0], to_write);
to_write = std::min (samples - to_write, (samplecnt_t) vec.len[1]); to_write = std::min (samples - to_write, (samplecnt_t)vec.len[1]);
if (to_write > 0) { if (to_write > 0) {
mix_buffers_no_gain (&_buffer[vec.len[0]], vec.buf[1], to_write); mix_buffers_no_gain (&_buffer[vec.len[0]], vec.buf[1], to_write);
} }
@ -137,29 +143,29 @@ PortExportChannel::read (Sample const *& data, samplecnt_t samples) const
++di; ++di;
} }
data = _buffer.get(); data = _buffer.get ();
} }
void void
PortExportChannel::get_state (XMLNode * node) const PortExportChannel::get_state (XMLNode* node) const
{ {
XMLNode * port_node; XMLNode* port_node;
for (PortSet::const_iterator it = ports.begin(); it != ports.end(); ++it) { for (PortSet::const_iterator it = ports.begin (); it != ports.end (); ++it) {
boost::shared_ptr<Port> p = it->lock (); boost::shared_ptr<Port> p = it->lock ();
if (p && (port_node = node->add_child ("Port"))) { if (p && (port_node = node->add_child ("Port"))) {
port_node->set_property ("name", p->name()); port_node->set_property ("name", p->name ());
} }
} }
} }
void void
PortExportChannel::set_state (XMLNode * node, Session & session) PortExportChannel::set_state (XMLNode* node, Session& session)
{ {
XMLNodeList xml_ports = node->children ("Port"); XMLNodeList xml_ports = node->children ("Port");
for (XMLNodeList::iterator it = xml_ports.begin(); it != xml_ports.end(); ++it) { for (XMLNodeList::iterator it = xml_ports.begin (); it != xml_ports.end (); ++it) {
std::string name; std::string name;
if ((*it)->get_property ("name", name)) { if ((*it)->get_property ("name", name)) {
boost::shared_ptr<AudioPort> port = boost::dynamic_pointer_cast<AudioPort> (session.engine().get_port_by_name (name)); boost::shared_ptr<AudioPort> port = boost::dynamic_pointer_cast<AudioPort> (session.engine ().get_port_by_name (name));
if (port) { if (port) {
ports.insert (port); ports.insert (port);
} else { } else {
@ -169,28 +175,28 @@ PortExportChannel::set_state (XMLNode * node, Session & session)
} }
} }
RegionExportChannelFactory::RegionExportChannelFactory (Session * session, AudioRegion const & region, AudioTrack&, Type type) RegionExportChannelFactory::RegionExportChannelFactory (Session* session, AudioRegion const& region, AudioTrack&, Type type)
: region (region) : region (region)
, type (type) , type (type)
, samples_per_cycle (session->engine().samples_per_cycle ()) , samples_per_cycle (session->engine ().samples_per_cycle ())
, buffers_up_to_date (false) , buffers_up_to_date (false)
, region_start (region.position_sample()) , region_start (region.position_sample ())
, position (region_start) , position (region_start)
{ {
switch (type) { switch (type) {
case Raw: case Raw:
n_channels = region.n_channels(); n_channels = region.n_channels ();
break; break;
case Fades: case Fades:
n_channels = region.n_channels(); n_channels = region.n_channels ();
mixdown_buffer.reset (new Sample [samples_per_cycle]); mixdown_buffer.reset (new Sample[samples_per_cycle]);
gain_buffer.reset (new Sample [samples_per_cycle]); gain_buffer.reset (new Sample[samples_per_cycle]);
std::fill_n (gain_buffer.get(), samples_per_cycle, Sample (1.0)); std::fill_n (gain_buffer.get (), samples_per_cycle, Sample (1.0));
break; break;
default: default:
throw ExportFailed ("Unhandled type in ExportChannelFactory constructor"); throw ExportFailed ("Unhandled type in ExportChannelFactory constructor");
} }
session->ProcessExport.connect_same_thread (export_connection, boost::bind (&RegionExportChannelFactory::new_cycle_started, this, _1)); session->ProcessExport.connect_same_thread (export_connection, boost::bind (&RegionExportChannelFactory::new_cycle_started, this, _1));
@ -211,17 +217,17 @@ RegionExportChannelFactory::create (uint32_t channel)
} }
void void
RegionExportChannelFactory::read (uint32_t channel, Sample const *& data, samplecnt_t samples_to_read) RegionExportChannelFactory::read (uint32_t channel, Sample const*& data, samplecnt_t samples_to_read)
{ {
assert (channel < n_channels); assert (channel < n_channels);
assert (samples_to_read <= samples_per_cycle); assert (samples_to_read <= samples_per_cycle);
if (!buffers_up_to_date) { if (!buffers_up_to_date) {
update_buffers(samples_to_read); update_buffers (samples_to_read);
buffers_up_to_date = true; buffers_up_to_date = true;
} }
data = buffers.get_audio (channel).data(); data = buffers.get_audio (channel).data ();
} }
void void
@ -230,47 +236,46 @@ RegionExportChannelFactory::update_buffers (samplecnt_t samples)
assert (samples <= samples_per_cycle); assert (samples <= samples_per_cycle);
switch (type) { switch (type) {
case Raw: case Raw:
for (size_t channel = 0; channel < n_channels; ++channel) { for (size_t channel = 0; channel < n_channels; ++channel) {
region.read (buffers.get_audio (channel).data(), position - region_start, samples, channel); region.read (buffers.get_audio (channel).data (), position - region_start, samples, channel);
} }
break; break;
case Fades: case Fades:
assert (mixdown_buffer && gain_buffer); assert (mixdown_buffer && gain_buffer);
for (size_t channel = 0; channel < n_channels; ++channel) { for (size_t channel = 0; channel < n_channels; ++channel) {
memset (mixdown_buffer.get(), 0, sizeof (Sample) * samples); memset (mixdown_buffer.get (), 0, sizeof (Sample) * samples);
buffers.get_audio (channel).silence(samples); buffers.get_audio (channel).silence (samples);
region.read_at (buffers.get_audio (channel).data(), mixdown_buffer.get(), gain_buffer.get(), position, samples, channel); region.read_at (buffers.get_audio (channel).data (), mixdown_buffer.get (), gain_buffer.get (), position, samples, channel);
} }
break; break;
default: default:
throw ExportFailed ("Unhandled type in ExportChannelFactory::update_buffers"); throw ExportFailed ("Unhandled type in ExportChannelFactory::update_buffers");
} }
position += samples; position += samples;
} }
RouteExportChannel::RouteExportChannel (boost::shared_ptr<CapturingProcessor> processor, size_t channel,
RouteExportChannel::RouteExportChannel(boost::shared_ptr<CapturingProcessor> processor, size_t channel, boost::shared_ptr<ProcessorRemover> remover)
boost::shared_ptr<ProcessorRemover> remover) : processor (processor)
: processor (processor) , channel (channel)
, channel (channel) , remover (remover)
, remover (remover)
{ {
} }
RouteExportChannel::~RouteExportChannel() RouteExportChannel::~RouteExportChannel ()
{ {
} }
void void
RouteExportChannel::create_from_route(std::list<ExportChannelPtr> & result, boost::shared_ptr<Route> route) RouteExportChannel::create_from_route (std::list<ExportChannelPtr>& result, boost::shared_ptr<Route> route)
{ {
boost::shared_ptr<CapturingProcessor> processor = route->add_export_point(); boost::shared_ptr<CapturingProcessor> processor = route->add_export_point ();
uint32_t channels = processor->input_streams().n_audio(); uint32_t channels = processor->input_streams ().n_audio ();
boost::shared_ptr<ProcessorRemover> remover (new ProcessorRemover (route, processor)); boost::shared_ptr<ProcessorRemover> remover (new ProcessorRemover (route, processor));
result.clear(); result.clear ();
for (uint32_t i = 0; i < channels; ++i) { for (uint32_t i = 0; i < channels; ++i) {
result.push_back (ExportChannelPtr (new RouteExportChannel (processor, i, remover))); result.push_back (ExportChannelPtr (new RouteExportChannel (processor, i, remover)));
} }
@ -285,45 +290,45 @@ RouteExportChannel::prepare_export (samplecnt_t max_samples, sampleoffset_t)
} }
void void
RouteExportChannel::read (Sample const *& data, samplecnt_t samples) const RouteExportChannel::read (Sample const*& data, samplecnt_t samples) const
{ {
assert(processor); assert (processor);
AudioBuffer const & buffer = processor->get_capture_buffers().get_audio (channel); AudioBuffer const& buffer = processor->get_capture_buffers ().get_audio (channel);
#ifndef NDEBUG #ifndef NDEBUG
(void) samples; (void)samples;
#else #else
assert (samples <= (samplecnt_t) buffer.capacity()); assert (samples <= (samplecnt_t)buffer.capacity ());
#endif #endif
data = buffer.data(); data = buffer.data ();
} }
void void
RouteExportChannel::get_state (XMLNode *) const RouteExportChannel::get_state (XMLNode*) const
{ {
// TODO // TODO
} }
void void
RouteExportChannel::set_state (XMLNode *, Session &) RouteExportChannel::set_state (XMLNode*, Session&)
{ {
// TODO // TODO
} }
bool bool
RouteExportChannel::operator< (ExportChannel const & other) const RouteExportChannel::operator< (ExportChannel const& other) const
{ {
RouteExportChannel const * rec; RouteExportChannel const* rec;
if ((rec = dynamic_cast<RouteExportChannel const *>(&other)) == 0) { if ((rec = dynamic_cast<RouteExportChannel const*> (&other)) == 0) {
return this < &other; return this < &other;
} }
if (processor.get() == rec->processor.get()) { if (processor.get () == rec->processor.get ()) {
return channel < rec->channel; return channel < rec->channel;
} }
return processor.get() < rec->processor.get(); return processor.get () < rec->processor.get ();
} }
RouteExportChannel::ProcessorRemover::~ProcessorRemover() RouteExportChannel::ProcessorRemover::~ProcessorRemover ()
{ {
route->remove_processor (processor); route->remove_processor (processor);
} }

View File

@ -28,42 +28,42 @@ using namespace PBD;
namespace ARDOUR namespace ARDOUR
{ {
/* ExportChannelConfiguration */ /* ExportChannelConfiguration */
ExportChannelConfiguration::ExportChannelConfiguration (Session & session) ExportChannelConfiguration::ExportChannelConfiguration (Session& session)
: session (session) : session (session)
, split (false) , split (false)
, region_type (RegionExportChannelFactory::None) , region_type (RegionExportChannelFactory::None)
{ {
} }
XMLNode & XMLNode&
ExportChannelConfiguration::get_state () const ExportChannelConfiguration::get_state () const
{ {
XMLNode * root = new XMLNode ("ExportChannelConfiguration"); XMLNode* root = new XMLNode ("ExportChannelConfiguration");
XMLNode * channel; XMLNode* channel;
root->set_property ("split", get_split()); root->set_property ("split", get_split ());
root->set_property ("channels", get_n_chans()); root->set_property ("channels", get_n_chans ());
switch (region_type) { switch (region_type) {
case RegionExportChannelFactory::None: case RegionExportChannelFactory::None:
// Do nothing // Do nothing
break; break;
default: default:
root->set_property ("region-processing", enum_2_string (region_type)); root->set_property ("region-processing", enum_2_string (region_type));
break; break;
} }
uint32_t i = 1; uint32_t i = 1;
for (ExportChannelConfiguration::ChannelList::const_iterator c_it = channels.begin(); c_it != channels.end(); ++c_it) { for (auto const& c : channels) {
channel = root->add_child ("Channel"); channel = root->add_child ("Channel");
if (!channel) { continue; } if (!channel) {
continue;
}
channel->set_property ("number", i); channel->set_property ("number", i);
(*c_it)->get_state (channel); c->get_state (channel);
++i; ++i;
} }
@ -72,7 +72,7 @@ ExportChannelConfiguration::get_state () const
} }
int int
ExportChannelConfiguration::set_state (const XMLNode & root) ExportChannelConfiguration::set_state (const XMLNode& root)
{ {
bool yn; bool yn;
if (root.get_property ("split", yn)) { if (root.get_property ("split", yn)) {
@ -81,12 +81,11 @@ ExportChannelConfiguration::set_state (const XMLNode & root)
std::string str; std::string str;
if (root.get_property ("region-processing", str)) { if (root.get_property ("region-processing", str)) {
set_region_processing_type ((RegionExportChannelFactory::Type) set_region_processing_type ((RegionExportChannelFactory::Type) string_2_enum (str, RegionExportChannelFactory::Type));
string_2_enum (str, RegionExportChannelFactory::Type));
} }
XMLNodeList channels = root.children ("Channel"); XMLNodeList channels = root.children ("Channel");
for (XMLNodeList::iterator it = channels.begin(); it != channels.end(); ++it) { for (XMLNodeList::iterator it = channels.begin (); it != channels.end (); ++it) {
ExportChannelPtr channel (new PortExportChannel ()); ExportChannelPtr channel (new PortExportChannel ());
channel->set_state (*it, session); channel->set_state (*it, session);
register_channel (channel); register_channel (channel);
@ -98,15 +97,17 @@ ExportChannelConfiguration::set_state (const XMLNode & root)
bool bool
ExportChannelConfiguration::all_channels_have_ports () const ExportChannelConfiguration::all_channels_have_ports () const
{ {
for (ChannelList::const_iterator it = channels.begin(); it != channels.end(); ++it) { for (auto const& c : channels) {
if ((*it)->empty ()) { return false; } if (c->empty ()) {
return false;
}
} }
return true; return true;
} }
void void
ExportChannelConfiguration::configurations_for_files (std::list<boost::shared_ptr<ExportChannelConfiguration> > & configs) ExportChannelConfiguration::configurations_for_files (std::list<boost::shared_ptr<ExportChannelConfiguration>>& configs)
{ {
configs.clear (); configs.clear ();
@ -115,10 +116,10 @@ ExportChannelConfiguration::configurations_for_files (std::list<boost::shared_pt
return; return;
} }
for (ChannelList::const_iterator it = channels.begin (); it != channels.end (); ++it) { for (auto const& c : channels) {
boost::shared_ptr<ExportChannelConfiguration> config (new ExportChannelConfiguration (session)); boost::shared_ptr<ExportChannelConfiguration> config (new ExportChannelConfiguration (session));
config->set_name (_name); config->set_name (_name);
config->register_channel (*it); config->register_channel (c);
configs.push_back (config); configs.push_back (config);
} }
} }