X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fardour%2Fexport_channel.h;h=894406874e40ec8b1e249be71c4e7ba80ba26718;hb=eaa1dacf5fc9537cfff36e2339bd07aab348aa2e;hp=96b9c1eda2cda6c800182dcf701d892d39ffd4a8;hpb=73192bc1a7ea55fa1864dc3826845b15c00dd2ec;p=ardour.git diff --git a/libs/ardour/ardour/export_channel.h b/libs/ardour/ardour/export_channel.h index 96b9c1eda2..894406874e 100644 --- a/libs/ardour/ardour/export_channel.h +++ b/libs/ardour/ardour/export_channel.h @@ -23,27 +23,32 @@ #include -#include +#include #include -#include -#include "ardour/audioregion.h" +#include "pbd/signals.h" + #include "ardour/buffer_set.h" +#include "ardour/export_pointers.h" namespace ARDOUR { class Session; class AudioTrack; class AudioPort; +class AudioRegion; +class CapturingProcessor; /// Export channel base class interface for different source types -class ExportChannel : public boost::less_than_comparable +class LIBARDOUR_API ExportChannel : public boost::less_than_comparable { public: virtual ~ExportChannel () {} - virtual void read (Sample * data, framecnt_t frames) const = 0; + virtual void set_max_buffer_size(framecnt_t) { } + + virtual void read (Sample const *& data, framecnt_t frames) const = 0; virtual bool empty () const = 0; /// Adds state to node passed @@ -56,26 +61,16 @@ class ExportChannel : public boost::less_than_comparable virtual bool operator< (ExportChannel const & other) const = 0; }; -/// Safe pointer for storing ExportChannels in ordered STL containers -class ExportChannelPtr : public boost::shared_ptr - , public boost::less_than_comparable -{ - public: - ExportChannelPtr () {} - template explicit ExportChannelPtr (Y * ptr) : boost::shared_ptr (ptr) {} - - bool operator< (ExportChannelPtr const & other) const { return **this < *other; } -}; - /// Basic export channel that reads from AudioPorts -class PortExportChannel : public ExportChannel +class LIBARDOUR_API PortExportChannel : public ExportChannel { public: - typedef std::set PortSet; + typedef std::set > PortSet; - PortExportChannel () {} + 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; @@ -83,18 +78,22 @@ class PortExportChannel : public ExportChannel bool operator< (ExportChannel const & other) const; - void add_port (AudioPort * port) { ports.insert (port); } + void add_port (boost::weak_ptr port) { ports.insert (port); } PortSet const & get_ports () { return ports; } private: PortSet ports; + boost::scoped_array buffer; + framecnt_t buffer_size; }; + /// Handles RegionExportChannels and does actual reading from region -class RegionExportChannelFactory +class LIBARDOUR_API RegionExportChannelFactory { public: enum Type { + None, Raw, Fades, Processed @@ -104,7 +103,7 @@ class RegionExportChannelFactory ~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: @@ -122,19 +121,19 @@ class RegionExportChannelFactory framecnt_t region_start; framecnt_t position; - Sample * mixdown_buffer; - Sample * gain_buffer; + boost::scoped_array mixdown_buffer; + boost::scoped_array gain_buffer; PBD::ScopedConnection export_connection; }; /// Export channel that reads from region channel -class RegionExportChannel : public ExportChannel +class LIBARDOUR_API RegionExportChannel : public ExportChannel { 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; } @@ -152,6 +151,49 @@ class RegionExportChannel : public ExportChannel uint32_t channel; }; +/// Export channel for exporting from different positions in a route +class LIBARDOUR_API RouteExportChannel : public ExportChannel +{ + class ProcessorRemover; // fwd declaration + + 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); + + 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, 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; + // Each channel keeps a ref to the remover. Last one alive + // will cause the processor to be removed on deletion. + boost::shared_ptr remover; +}; + } // namespace ARDOUR #endif