From 86597d7e1c832abde94b39781e25a95b5d1184d5 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sat, 14 May 2022 18:18:33 +0200 Subject: [PATCH] NO-OP: re-indent, and cleanup --- libs/ardour/ardour/export_channel.h | 152 ++++++++------ .../ardour/export_channel_configuration.h | 58 +++--- libs/ardour/export_channel.cc | 195 +++++++++--------- libs/ardour/export_channel_configuration.cc | 59 +++--- 4 files changed, 247 insertions(+), 217 deletions(-) diff --git a/libs/ardour/ardour/export_channel.h b/libs/ardour/ardour/export_channel.h index 8345d5940c..9a570f71ba 100644 --- a/libs/ardour/ardour/export_channel.h +++ b/libs/ardour/ardour/export_channel.h @@ -23,14 +23,14 @@ #ifndef __ardour_export_channel_h__ #define __ardour_export_channel_h__ -#include #include +#include #include #include -#include "pbd/signals.h" #include "pbd/ringbuffer.h" +#include "pbd/signals.h" #include "ardour/buffer_set.h" #include "ardour/export_pointers.h" @@ -46,85 +46,90 @@ class CapturingProcessor; /// Export channel base class interface for different source types class LIBARDOUR_API ExportChannel : public boost::less_than_comparable { - public: - +public: virtual ~ExportChannel () {} 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; /// 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 - 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 - virtual bool operator< (ExportChannel const & other) const = 0; + virtual bool operator< (ExportChannel const& other) const = 0; }; /// Basic export channel that reads from AudioPorts class LIBARDOUR_API PortExportChannel : public ExportChannel { - public: - typedef std::set > PortSet; +public: + typedef std::set> PortSet; PortExportChannel (); ~PortExportChannel (); 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; - bool empty () const { return ports.empty(); } + void read (Sample const*& data, samplecnt_t samples) const; - void get_state (XMLNode * node) const; - void set_state (XMLNode * node, Session & session); + bool empty () const { return ports.empty (); } - 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 port) { ports.insert (port); } - PortSet const & get_ports () { return ports; } + PortSet const& get_ports () { return ports; } - private: - PortSet ports; - samplecnt_t _buffer_size; - boost::scoped_array _buffer; - std::list > > _delaylines; +private: + PortSet ports; + samplecnt_t _buffer_size; + boost::scoped_array _buffer; + std::list>> _delaylines; }; - /// Handles RegionExportChannels and does actual reading from region class LIBARDOUR_API RegionExportChannelFactory { - public: +public: enum Type { None, Raw, Fades, }; - RegionExportChannelFactory (Session * session, AudioRegion const & region, AudioTrack & track, Type type); + RegionExportChannelFactory (Session* session, AudioRegion const& region, AudioTrack& track, Type type); ~RegionExportChannelFactory (); 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); - AudioRegion const & region; - Type type; + AudioRegion const& region; + Type type; samplecnt_t samples_per_cycle; - size_t n_channels; - BufferSet buffers; - bool buffers_up_to_date; + size_t n_channels; + BufferSet buffers; + bool buffers_up_to_date; samplepos_t region_start; samplepos_t position; @@ -139,23 +144,32 @@ class LIBARDOUR_API RegionExportChannel : public ExportChannel { friend class RegionExportChannelFactory; - public: - void read (Sample const *& data, samplecnt_t samples_to_read) const { factory.read (channel, data, samples_to_read); } - void get_state (XMLNode * /*node*/) const {}; - void set_state (XMLNode * /*node*/, Session & /*session*/) {}; +public: + void read (Sample const*& data, samplecnt_t samples_to_read) const + { + 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; } + // 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: - - RegionExportChannel (RegionExportChannelFactory & factory, uint32_t channel) +private: + RegionExportChannel (RegionExportChannelFactory& factory, uint32_t channel) : factory (factory) , channel (channel) - {} + { + } - RegionExportChannelFactory & factory; - uint32_t channel; + RegionExportChannelFactory& factory; + uint32_t channel; }; /// Export channel for exporting from different positions in a route @@ -163,39 +177,45 @@ class LIBARDOUR_API RouteExportChannel : public ExportChannel { class ProcessorRemover; // fwd declaration - public: - RouteExportChannel(boost::shared_ptr processor, size_t channel, - boost::shared_ptr remover); - ~RouteExportChannel(); +public: + RouteExportChannel (boost::shared_ptr processor, + size_t channel, + boost::shared_ptr remover); + ~RouteExportChannel (); - static void create_from_route(std::list & result, boost::shared_ptr route); + static void create_from_route (std::list& result, boost::shared_ptr route); - public: // ExportChannel interface +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 (Sample const*& data, samplecnt_t samples) const; + bool empty () const { return false; } - void get_state (XMLNode * node) const; - void set_state (XMLNode * node, Session & session); + void get_state (XMLNode* node) const; + void set_state (XMLNode* node, Session& session); - bool operator< (ExportChannel const & other) const; - - private: + bool operator< (ExportChannel const& other) const; +private: // Removes the processor from the track when deleted - class ProcessorRemover { - public: - ProcessorRemover (boost::shared_ptr route, boost::shared_ptr processor) - : route (route), processor (processor) {} - ~ProcessorRemover(); - private: - boost::shared_ptr route; - boost::shared_ptr processor; + class ProcessorRemover + { + public: + ProcessorRemover (boost::shared_ptr route, boost::shared_ptr processor) + : route (route) + , processor (processor) + { + } + ~ProcessorRemover (); + + private: + boost::shared_ptr route; + boost::shared_ptr processor; }; boost::shared_ptr processor; - size_t channel; + size_t channel; // Each channel keeps a ref to the remover. Last one alive // will cause the processor to be removed on deletion. boost::shared_ptr remover; diff --git a/libs/ardour/ardour/export_channel_configuration.h b/libs/ardour/ardour/export_channel_configuration.h index 3aa8c43b28..f3ef95aeb8 100644 --- a/libs/ardour/ardour/export_channel_configuration.h +++ b/libs/ardour/ardour/export_channel_configuration.h @@ -21,9 +21,9 @@ #ifndef __ardour_export_channel_configuration_h__ #define __ardour_export_channel_configuration_h__ +#include #include #include -#include #include @@ -32,57 +32,61 @@ #include "pbd/xml++.h" -namespace ARDOUR -{ +namespace ARDOUR { class Session; class LIBARDOUR_API ExportChannelConfiguration : public boost::enable_shared_from_this { - - private: +private: friend class ExportElementFactory; - ExportChannelConfiguration (Session & session); + ExportChannelConfiguration (Session& session); - public: - bool operator== (ExportChannelConfiguration const & other) const { return channels == other.channels; } - bool operator!= (ExportChannelConfiguration const & other) const { return channels != other.channels; } +public: + bool operator== (ExportChannelConfiguration const& other) const + { + return channels == other.channels; + } + bool operator!= (ExportChannelConfiguration const& other) const + { + return channels != other.channels; + } - XMLNode & get_state () const; - int set_state (const XMLNode &); + XMLNode& get_state () const; + int set_state (const XMLNode&); typedef std::list ChannelList; - ChannelList const & get_channels () const { return channels; } bool all_channels_have_ports () const; std::string name () const { return _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; } - void set_region_processing_type(RegionExportChannelFactory::Type type) { region_type = type; } + RegionExportChannelFactory::Type region_processing_type () const { return region_type; } + void set_region_processing_type (RegionExportChannelFactory::Type type) { region_type = type; } 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); } - void register_channels (ChannelList const & new_channels) { - std::copy (new_channels.begin(), new_channels.end(), std::back_inserter(channels)); - } + uint32_t get_n_chans () const { return channels.size (); } + ChannelList const& get_channels () const { return channels; } 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. * I.e. many configurations if splitting is enabled, one if not. */ - void configurations_for_files (std::list > & configs); + void configurations_for_files (std::list>& configs); - private: +private: + Session& session; - Session & session; - - ChannelList channels; - bool split; // Split to mono files - std::string _name; + ChannelList channels; + bool split; // Split to mono files + std::string _name; RegionExportChannelFactory::Type region_type; }; diff --git a/libs/ardour/export_channel.cc b/libs/ardour/export_channel.cc index 85dcf7c46a..f2e2587b14 100644 --- a/libs/ardour/export_channel.cc +++ b/libs/ardour/export_channel.cc @@ -20,13 +20,13 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include "ardour/export_channel.h" #include "ardour/audio_buffer.h" #include "ardour/audio_port.h" #include "ardour/audio_track.h" #include "ardour/audioengine.h" #include "ardour/audioregion.h" #include "ardour/capturing_processor.h" -#include "ardour/export_channel.h" #include "ardour/export_failed.h" #include "ardour/session.h" @@ -46,17 +46,20 @@ PortExportChannel::~PortExportChannel () _delaylines.clear (); } -samplecnt_t PortExportChannel::common_port_playback_latency () const +samplecnt_t +PortExportChannel::common_port_playback_latency () const { - samplecnt_t l = 0; - bool first = true; - for (PortSet::const_iterator it = ports.begin(); it != ports.end(); ++it) { + samplecnt_t l = 0; + bool first = true; + for (PortSet::const_iterator it = ports.begin (); it != ports.end (); ++it) { boost::shared_ptr p = it->lock (); - if (!p) { continue; } + if (!p) { + continue; + } samplecnt_t latency = p->private_latency_range (true).max; if (first) { first = false; - l = p->private_latency_range (true).max; + l = p->private_latency_range (true).max; continue; } l = std::min (l, latency); @@ -64,60 +67,63 @@ samplecnt_t PortExportChannel::common_port_playback_latency () const 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.reset (new Sample[max_samples]); _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 p = it->lock (); - if (!p) { continue; } - samplecnt_t latency = p->private_latency_range (true).max - common_latency; - PBD::RingBuffer* rb = new PBD::RingBuffer (latency + 1 + _buffer_size); + if (!p) { + continue; + } + samplecnt_t latency = p->private_latency_range (true).max - common_latency; + PBD::RingBuffer* rb = new PBD::RingBuffer (latency + 1 + _buffer_size); for (samplepos_t i = 0; i < latency; ++i) { Sample zero = 0; rb->write (&zero, 1); } - _delaylines.push_back (boost::shared_ptr >(rb)); + _delaylines.push_back (boost::shared_ptr> (rb)); } } bool -PortExportChannel::operator< (ExportChannel const & other) const +PortExportChannel::operator< (ExportChannel const& other) const { - PortExportChannel const * pec; - if (!(pec = dynamic_cast (&other))) { + PortExportChannel const* pec; + if (!(pec = dynamic_cast (&other))) { return this < &other; } return ports < pec->ports; } void -PortExportChannel::read (Sample const *& data, samplecnt_t samples) const +PortExportChannel::read (Sample const*& data, samplecnt_t samples) const { - assert(_buffer); - assert(samples <= _buffer_size); + assert (_buffer); + assert (samples <= _buffer_size); - 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(); + 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); return; } - memset (_buffer.get(), 0, samples * sizeof (Sample)); + memset (_buffer.get (), 0, samples * sizeof (Sample)); - std::list > >::const_iterator di = _delaylines.begin (); - for (PortSet::const_iterator it = ports.begin(); it != ports.end(); ++it) { + std::list>>::const_iterator di = _delaylines.begin (); + for (PortSet::const_iterator it = ports.begin (); it != ports.end (); ++it) { boost::shared_ptr p = it->lock (); if (!p) { continue; } - AudioBuffer& ab (p->get_audio_buffer(samples)); // unsets AudioBuffer::_written - Sample* port_buffer = ab.data(); + AudioBuffer& ab (p->get_audio_buffer (samples)); // unsets AudioBuffer::_written + Sample* port_buffer = ab.data (); ab.set_written (true); (*di)->write (port_buffer, samples); @@ -125,10 +131,10 @@ PortExportChannel::read (Sample const *& data, samplecnt_t samples) const (*di)->get_read_vector (&vec); 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); - 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) { 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; } - data = _buffer.get(); + data = _buffer.get (); } void -PortExportChannel::get_state (XMLNode * node) const +PortExportChannel::get_state (XMLNode* node) const { - XMLNode * port_node; - for (PortSet::const_iterator it = ports.begin(); it != ports.end(); ++it) { + XMLNode* port_node; + for (PortSet::const_iterator it = ports.begin (); it != ports.end (); ++it) { boost::shared_ptr p = it->lock (); if (p && (port_node = node->add_child ("Port"))) { - port_node->set_property ("name", p->name()); + port_node->set_property ("name", p->name ()); } } } void -PortExportChannel::set_state (XMLNode * node, Session & session) +PortExportChannel::set_state (XMLNode* node, Session& session) { 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; if ((*it)->get_property ("name", name)) { - boost::shared_ptr port = boost::dynamic_pointer_cast (session.engine().get_port_by_name (name)); + boost::shared_ptr port = boost::dynamic_pointer_cast (session.engine ().get_port_by_name (name)); if (port) { ports.insert (port); } 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) , type (type) - , samples_per_cycle (session->engine().samples_per_cycle ()) + , samples_per_cycle (session->engine ().samples_per_cycle ()) , buffers_up_to_date (false) - , region_start (region.position_sample()) + , region_start (region.position_sample ()) , position (region_start) { switch (type) { - case Raw: - n_channels = region.n_channels(); - break; - case Fades: - n_channels = region.n_channels(); + case Raw: + n_channels = region.n_channels (); + break; + case Fades: + n_channels = region.n_channels (); - mixdown_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)); + mixdown_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)); - break; - default: - throw ExportFailed ("Unhandled type in ExportChannelFactory constructor"); + break; + default: + throw ExportFailed ("Unhandled type in ExportChannelFactory constructor"); } 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 -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 (samples_to_read <= samples_per_cycle); if (!buffers_up_to_date) { - update_buffers(samples_to_read); + update_buffers (samples_to_read); buffers_up_to_date = true; } - data = buffers.get_audio (channel).data(); + data = buffers.get_audio (channel).data (); } void @@ -230,47 +236,46 @@ RegionExportChannelFactory::update_buffers (samplecnt_t samples) assert (samples <= samples_per_cycle); switch (type) { - case Raw: - for (size_t channel = 0; channel < n_channels; ++channel) { - region.read (buffers.get_audio (channel).data(), position - region_start, samples, channel); - } - break; - case Fades: - assert (mixdown_buffer && gain_buffer); - for (size_t channel = 0; channel < n_channels; ++channel) { - memset (mixdown_buffer.get(), 0, sizeof (Sample) * samples); - buffers.get_audio (channel).silence(samples); - region.read_at (buffers.get_audio (channel).data(), mixdown_buffer.get(), gain_buffer.get(), position, samples, channel); - } - break; - default: - throw ExportFailed ("Unhandled type in ExportChannelFactory::update_buffers"); + case Raw: + for (size_t channel = 0; channel < n_channels; ++channel) { + region.read (buffers.get_audio (channel).data (), position - region_start, samples, channel); + } + break; + case Fades: + assert (mixdown_buffer && gain_buffer); + for (size_t channel = 0; channel < n_channels; ++channel) { + memset (mixdown_buffer.get (), 0, sizeof (Sample) * samples); + buffers.get_audio (channel).silence (samples); + region.read_at (buffers.get_audio (channel).data (), mixdown_buffer.get (), gain_buffer.get (), position, samples, channel); + } + break; + default: + throw ExportFailed ("Unhandled type in ExportChannelFactory::update_buffers"); } position += samples; } - -RouteExportChannel::RouteExportChannel(boost::shared_ptr processor, size_t channel, - boost::shared_ptr remover) - : processor (processor) - , channel (channel) - , remover (remover) +RouteExportChannel::RouteExportChannel (boost::shared_ptr processor, size_t channel, + boost::shared_ptr remover) + : processor (processor) + , channel (channel) + , remover (remover) { } -RouteExportChannel::~RouteExportChannel() +RouteExportChannel::~RouteExportChannel () { } void -RouteExportChannel::create_from_route(std::list & result, boost::shared_ptr route) +RouteExportChannel::create_from_route (std::list& result, boost::shared_ptr route) { - boost::shared_ptr processor = route->add_export_point(); - uint32_t channels = processor->input_streams().n_audio(); + boost::shared_ptr processor = route->add_export_point (); + uint32_t channels = processor->input_streams ().n_audio (); boost::shared_ptr remover (new ProcessorRemover (route, processor)); - result.clear(); + result.clear (); for (uint32_t i = 0; i < channels; ++i) { result.push_back (ExportChannelPtr (new RouteExportChannel (processor, i, remover))); } @@ -285,45 +290,45 @@ RouteExportChannel::prepare_export (samplecnt_t max_samples, sampleoffset_t) } void -RouteExportChannel::read (Sample const *& data, samplecnt_t samples) const +RouteExportChannel::read (Sample const*& data, samplecnt_t samples) const { - assert(processor); - AudioBuffer const & buffer = processor->get_capture_buffers().get_audio (channel); + assert (processor); + AudioBuffer const& buffer = processor->get_capture_buffers ().get_audio (channel); #ifndef NDEBUG - (void) samples; + (void)samples; #else - assert (samples <= (samplecnt_t) buffer.capacity()); + assert (samples <= (samplecnt_t)buffer.capacity ()); #endif - data = buffer.data(); + data = buffer.data (); } void -RouteExportChannel::get_state (XMLNode *) const +RouteExportChannel::get_state (XMLNode*) const { // TODO } void -RouteExportChannel::set_state (XMLNode *, Session &) +RouteExportChannel::set_state (XMLNode*, Session&) { // TODO } bool -RouteExportChannel::operator< (ExportChannel const & other) const +RouteExportChannel::operator< (ExportChannel const& other) const { - RouteExportChannel const * rec; - if ((rec = dynamic_cast(&other)) == 0) { + RouteExportChannel const* rec; + if ((rec = dynamic_cast (&other)) == 0) { return this < &other; } - if (processor.get() == rec->processor.get()) { + if (processor.get () == rec->processor.get ()) { 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); } diff --git a/libs/ardour/export_channel_configuration.cc b/libs/ardour/export_channel_configuration.cc index 71690b7fa1..deb5ec09f0 100644 --- a/libs/ardour/export_channel_configuration.cc +++ b/libs/ardour/export_channel_configuration.cc @@ -28,42 +28,42 @@ using namespace PBD; namespace ARDOUR { - /* ExportChannelConfiguration */ -ExportChannelConfiguration::ExportChannelConfiguration (Session & session) - : session (session) - , split (false) - , region_type (RegionExportChannelFactory::None) +ExportChannelConfiguration::ExportChannelConfiguration (Session& session) + : session (session) + , split (false) + , region_type (RegionExportChannelFactory::None) { - } -XMLNode & +XMLNode& ExportChannelConfiguration::get_state () const { - XMLNode * root = new XMLNode ("ExportChannelConfiguration"); - XMLNode * channel; + XMLNode* root = new XMLNode ("ExportChannelConfiguration"); + XMLNode* channel; - root->set_property ("split", get_split()); - root->set_property ("channels", get_n_chans()); + root->set_property ("split", get_split ()); + root->set_property ("channels", get_n_chans ()); switch (region_type) { - case RegionExportChannelFactory::None: - // Do nothing - break; - default: - root->set_property ("region-processing", enum_2_string (region_type)); - break; + case RegionExportChannelFactory::None: + // Do nothing + break; + default: + root->set_property ("region-processing", enum_2_string (region_type)); + break; } 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"); - if (!channel) { continue; } + if (!channel) { + continue; + } channel->set_property ("number", i); - (*c_it)->get_state (channel); + c->get_state (channel); ++i; } @@ -72,7 +72,7 @@ ExportChannelConfiguration::get_state () const } int -ExportChannelConfiguration::set_state (const XMLNode & root) +ExportChannelConfiguration::set_state (const XMLNode& root) { bool yn; if (root.get_property ("split", yn)) { @@ -81,12 +81,11 @@ ExportChannelConfiguration::set_state (const XMLNode & root) std::string str; if (root.get_property ("region-processing", str)) { - set_region_processing_type ((RegionExportChannelFactory::Type) - string_2_enum (str, RegionExportChannelFactory::Type)); + set_region_processing_type ((RegionExportChannelFactory::Type) string_2_enum (str, RegionExportChannelFactory::Type)); } 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 ()); channel->set_state (*it, session); register_channel (channel); @@ -98,15 +97,17 @@ ExportChannelConfiguration::set_state (const XMLNode & root) bool ExportChannelConfiguration::all_channels_have_ports () const { - for (ChannelList::const_iterator it = channels.begin(); it != channels.end(); ++it) { - if ((*it)->empty ()) { return false; } + for (auto const& c : channels) { + if (c->empty ()) { + return false; + } } return true; } void -ExportChannelConfiguration::configurations_for_files (std::list > & configs) +ExportChannelConfiguration::configurations_for_files (std::list>& configs) { configs.clear (); @@ -115,10 +116,10 @@ ExportChannelConfiguration::configurations_for_files (std::list config (new ExportChannelConfiguration (session)); config->set_name (_name); - config->register_channel (*it); + config->register_channel (c); configs.push_back (config); } }