MuteMaster should (a) use a Muteable's own ::muted_by_others_soloing() (b) not try...
[ardour.git] / libs / ardour / ardour / export_channel_configuration.h
index 70b2bb00d9fef861b5f81e42305c0d98e53879de..4cab886c88d78811343a599ab97b4463f7c58f9a 100644 (file)
 #define __ardour_export_channel_configuration_h__
 
 #include <list>
+#include <string>
+#include <algorithm>
 
-#include <glibmm/ustring.h>
-#include <sigc++/signal.h>
+#include <boost/enable_shared_from_this.hpp>
 
 #include "ardour/export_channel.h"
-#include "ardour/export_status.h"
-#include "ardour/ardour.h"
+#include "ardour/export_pointers.h"
 
 #include "pbd/xml++.h"
 
 namespace ARDOUR
 {
 
-class ExportHandler;
-class AudioPort;
-class ExportChannel;
-class ExportFormatSpecification;
-class ExportFilename;
-class ExportProcessor;
-class ExportTimespan;
 class Session;
 
-class ExportChannelConfiguration
+class LIBARDOUR_API ExportChannelConfiguration : public boost::enable_shared_from_this<ExportChannelConfiguration>
 {
-  private:
-       typedef boost::shared_ptr<ExportProcessor> ProcessorPtr;
-       typedef boost::shared_ptr<ExportTimespan> TimespanPtr;
-       typedef boost::shared_ptr<ExportFormatSpecification const> FormatPtr;
-       typedef boost::shared_ptr<ExportFilename> FilenamePtr;
-       
-       typedef std::pair<FormatPtr, FilenamePtr> FileConfig;
-       typedef std::list<FileConfig> FileConfigList;
-       
-       /// Struct for threading, acts like a pointer to a ExportChannelConfiguration
-       struct WriterThread {
-               WriterThread (ExportChannelConfiguration & channel_config) :
-                 channel_config (channel_config), running (false) {}
-               
-               ExportChannelConfiguration * operator-> () { return &channel_config; }
-               ExportChannelConfiguration & operator* () { return channel_config; }
-               
-               ExportChannelConfiguration & channel_config;
-               
-               pthread_t thread;
-               bool      running;
-       };
 
   private:
        friend class ExportElementFactory;
        ExportChannelConfiguration (Session & session);
-       
+
   public:
+       bool operator== (ExportChannelConfiguration const & other) const { return channels == other.channels; }
+       bool operator!= (ExportChannelConfiguration const & other) const { return channels != other.channels; }
+
        XMLNode & get_state ();
        int set_state (const XMLNode &);
-       
+
        typedef std::list<ExportChannelPtr> ChannelList;
-       
+
        ChannelList const & get_channels () const { return channels; }
        bool all_channels_have_ports () const;
-       
-       Glib::ustring name () const { return _name; }
-       void set_name (Glib::ustring name) { _name = name; }
+
+       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; }
+
        bool get_split () const { return split; }
        uint32_t get_n_chans () const { return channels.size(); }
-       
+
        void register_channel (ExportChannelPtr channel) { channels.push_back (channel); }
-       void register_file_config (FormatPtr format, FilenamePtr filename) { file_configs.push_back (FileConfig (format, filename)); }
-       
+       void register_channels (ChannelList const & new_channels) {
+               std::copy (new_channels.begin(), new_channels.end(), std::back_inserter(channels));
+       }
        void clear_channels () { channels.clear (); }
-       
-       /// Writes all files for this channel config @return true if a new thread was spawned
-       bool write_files (boost::shared_ptr<ExportProcessor> new_processor);
-       sigc::signal<void> FilesWritten;
-       
-       // Tells the handler the necessary information for it to handle tempfiles
-       void register_with_timespan (TimespanPtr timespan);
-       
-       void unregister_all ();
-       
-  private:
-
-       typedef boost::shared_ptr<ExportStatus> ExportStatusPtr;
 
-        Session & session;
+       /** 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<boost::shared_ptr<ExportChannelConfiguration> > & configs);
 
-       // processor has to be prepared before doing this.
-       void write_file ();
-       
-       /// The actual write files, needed for threading
-       static void *  _write_files (void *arg);
-       WriterThread    writer_thread;
-       ProcessorPtr    processor;
-       ExportStatusPtr status;
+  private:
 
-       bool            files_written;
+       Session & session;
 
-       TimespanPtr     timespan;
        ChannelList     channels;
-       FileConfigList  file_configs;
-       
        bool            split; // Split to mono files
-       Glib::ustring  _name;
+       std::string  _name;
+       RegionExportChannelFactory::Type region_type;
 };
 
 } // namespace ARDOUR