#include <set>
-#include <boost/signals2.hpp>
-#include <boost/shared_ptr.hpp>
#include <boost/scoped_array.hpp>
-#include <boost/operators.hpp>
+#include <boost/shared_ptr.hpp>
#include "pbd/signals.h"
#include "ardour/buffer_set.h"
+#include "ardour/export_pointers.h"
namespace ARDOUR {
class AudioTrack;
class AudioPort;
class AudioRegion;
+class CapturingProcessor;
/// Export channel base class interface for different source types
class ExportChannel : public boost::less_than_comparable<ExportChannel>
virtual ~ExportChannel () {}
- virtual void set_max_buffer_size(framecnt_t frames) { }
+ virtual void set_max_buffer_size(framecnt_t) { }
- virtual void read (Sample *& data, framecnt_t frames) const = 0;
+ virtual void read (Sample const *& data, framecnt_t frames) const = 0;
virtual bool empty () const = 0;
/// Adds state to node passed
virtual bool operator< (ExportChannel const & other) const = 0;
};
-/// Safe pointer for storing ExportChannels in ordered STL containers
-class ExportChannelPtr : public boost::shared_ptr<ExportChannel>
- , public boost::less_than_comparable<ExportChannel>
-{
- public:
- ExportChannelPtr () {}
- template<typename Y> explicit ExportChannelPtr (Y * ptr) : boost::shared_ptr<ExportChannel> (ptr) {}
-
- bool operator< (ExportChannelPtr const & other) const { return **this < *other; }
-};
-
/// Basic export channel that reads from AudioPorts
class PortExportChannel : public ExportChannel
{
public:
- typedef std::set<AudioPort *> PortSet;
+ typedef std::set<boost::weak_ptr<AudioPort> > PortSet;
PortExportChannel ();
void set_max_buffer_size(framecnt_t frames);
- void read (Sample *& data, framecnt_t frames) const;
+ void read (Sample const *& data, framecnt_t frames) const;
bool empty () const { return ports.empty(); }
void get_state (XMLNode * node) const;
bool operator< (ExportChannel const & other) const;
- void add_port (AudioPort * port) { ports.insert (port); }
+ void add_port (boost::weak_ptr<AudioPort> port) { ports.insert (port); }
PortSet const & get_ports () { return ports; }
private:
framecnt_t buffer_size;
};
+
/// Handles RegionExportChannels and does actual reading from region
-class RegionExportChannelFactory
+class RegionExportChannelFactory
{
public:
enum Type {
+ None,
Raw,
Fades,
Processed
~RegionExportChannelFactory ();
ExportChannelPtr create (uint32_t channel);
- void read (uint32_t channel, Sample *& data, framecnt_t frames_to_read);
+ void read (uint32_t channel, Sample const *& data, framecnt_t frames_to_read);
private:
friend class RegionExportChannelFactory;
public:
- void read (Sample *& data, framecnt_t frames_to_read) const { factory.read (channel, data, frames_to_read); }
+ void read (Sample const *& data, framecnt_t frames_to_read) const { factory.read (channel, data, frames_to_read); }
void get_state (XMLNode * /*node*/) const {};
void set_state (XMLNode * /*node*/, Session & /*session*/) {};
bool empty () const { return false; }
uint32_t channel;
};
+/// Export channel for exporting from different positions in a route
+class RouteExportChannel : public ExportChannel
+{
+ class ProcessorRemover; // fwd declaration
+
+ public:
+ RouteExportChannel(boost::shared_ptr<CapturingProcessor> processor, size_t channel,
+ boost::shared_ptr<ProcessorRemover> remover);
+ ~RouteExportChannel();
+
+ static void create_from_route(std::list<ExportChannelPtr> & result, boost::shared_ptr<Route> route);
+
+ public: // ExportChannel interface
+ void set_max_buffer_size(framecnt_t frames);
+
+ void read (Sample const *& data, framecnt_t frames) const;
+ bool empty () const { return false; }
+
+ void get_state (XMLNode * node) const;
+ void set_state (XMLNode * node, Session & session);
+
+ bool operator< (ExportChannel const & other) const;
+
+ private:
+
+ // Removes the processor from the track when deleted
+ class ProcessorRemover {
+ public:
+ ProcessorRemover (boost::shared_ptr<Route> route, boost::shared_ptr<CapturingProcessor> processor)
+ : route (route), processor (processor) {}
+ ~ProcessorRemover();
+ private:
+ boost::shared_ptr<Route> route;
+ boost::shared_ptr<CapturingProcessor> processor;
+ };
+
+ boost::shared_ptr<CapturingProcessor> processor;
+ 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<ProcessorRemover> remover;
+};
+
} // namespace ARDOUR
#endif