Fix split channel export (which was broken during export refactoring)
authorSakari Bergen <sakari.bergen@beatwaves.net>
Tue, 30 Mar 2010 15:25:28 +0000 (15:25 +0000)
committerSakari Bergen <sakari.bergen@beatwaves.net>
Tue, 30 Mar 2010 15:25:28 +0000 (15:25 +0000)
Possibly fixes bug #3052

Also clarify some comments which weren't quite clear :)

git-svn-id: svn://localhost/ardour2/branches/3.0@6808 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/ardour/export_channel_configuration.h
libs/ardour/ardour/export_filename.h
libs/ardour/ardour/export_graph_builder.h
libs/ardour/export_channel_configuration.cc
libs/ardour/export_graph_builder.cc

index 4b027cc02050fd851681688a525a8e34d09fbfa4..e088aba2f072ccc4c42b6828e07f1328b312079f 100644 (file)
@@ -22,8 +22,8 @@
 #define __ardour_export_channel_configuration_h__
 
 #include <list>
-
 #include <glibmm/ustring.h>
+#include <boost/enable_shared_from_this.hpp>
 
 #include "ardour/export_channel.h"
 #include "ardour/export_status.h"
@@ -43,7 +43,7 @@ class ExportProcessor;
 class ExportTimespan;
 class Session;
 
-class ExportChannelConfiguration
+class ExportChannelConfiguration : public boost::enable_shared_from_this<ExportChannelConfiguration>
 {
 
   private:
@@ -71,6 +71,10 @@ class ExportChannelConfiguration
 
        void register_channel (ExportChannelPtr channel) { channels.push_back (channel); }
        void clear_channels () { channels.clear (); }
+       
+       /** 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);
 
   private:
 
index 2847291a13896ab615f74aef3238dd526a14ed9c..c5f0e3b5caf5cbdc56e4ad75aaf1dd480b4a184a 100644 (file)
@@ -116,7 +116,8 @@ class ExportFilename {
        TimeFormat time_format;
 
        Glib::ustring get_formatted_time (Glib::ustring const & format) const;
-       struct tm * time_struct; // Due to static allocation no destructor or copy-ctor is needed because of this
+       // Due to the static allocation used in strftime(), no destructor or copy-ctor is needed for this
+       struct tm * time_struct;
 
        TimespanPtr timespan;
        ChannelConfigPtr channel_config;
index 7bb5cf9aa1373d554b249970bcf07a67a8286252..e67c2fe90c4896d3c319535abd3dfc2538fa129e 100644 (file)
@@ -69,6 +69,8 @@ class ExportGraphBuilder
        
   private:
        
+       void add_split_config (FileSpec const & config);
+       
        class Encoder : public sigc::trackable {
          public:
                template <typename T> boost::shared_ptr<AudioGrapher::Sink<T> > init (FileSpec const & new_config);
index cc68356d824c8e7419c7b1a018b44c03e9224ab0..eb3b2838c64e68cf3bd117d873359f9fbf5db444 100644 (file)
@@ -99,4 +99,22 @@ ExportChannelConfiguration::all_channels_have_ports () const
        return true;
 }
 
+void
+ExportChannelConfiguration::configurations_for_files (std::list<boost::shared_ptr<ExportChannelConfiguration> > & configs)
+{
+       configs.clear ();
+       
+       if (!split) {
+               configs.push_back (shared_from_this ());
+               return;
+       }
+       
+       for (ChannelList::const_iterator it = channels.begin (); it != channels.end (); ++it) {
+               boost::shared_ptr<ExportChannelConfiguration> config (new ExportChannelConfiguration (session));
+               config->set_name (_name);
+               config->register_channel (*it);
+               configs.push_back (config);
+       }
+}
+
 } // namespace ARDOUR
index 738f888b3d817643d2d9a9db24303f872be9c342..bc3a162e042558c58cbb7805cc961a4d0e1b4da3 100644 (file)
@@ -73,6 +73,33 @@ ExportGraphBuilder::reset ()
 
 void
 ExportGraphBuilder::add_config (FileSpec const & config)
+{
+       if (!config.channel_config->get_split ()) {
+               add_split_config (config);
+               return;
+       }
+       
+       // Split channel configurations are split into several channel configurations,
+       // each corresponding to a file, at this stage
+       typedef std::list<boost::shared_ptr<ExportChannelConfiguration> > ConfigList;
+       ConfigList file_configs;
+       config.channel_config->configurations_for_files (file_configs);
+       
+       unsigned chan = 1;
+       for (ConfigList::iterator it = file_configs.begin(); it != file_configs.end(); ++it, ++chan) {
+               FileSpec copy = config;
+               copy.channel_config = *it;
+               
+               copy.filename.reset (new ExportFilename (*copy.filename));
+               copy.filename->include_channel = true;
+               copy.filename->set_channel (chan);
+               
+               add_split_config (copy);
+       }
+}
+
+void
+ExportGraphBuilder::add_split_config (FileSpec const & config)
 {
        for (ChannelConfigList::iterator it = channel_configs.begin(); it != channel_configs.end(); ++it) {
                if (*it == config) {