ardour
export_channel_configuration.cc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 Paul Davis
3  Author: Sakari Bergen
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; if not, write to the Free Software
17  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 
19 */
20 
22 
23 #include "pbd/convert.h"
24 #include "pbd/enumwriter.h"
25 #include "pbd/pthread_utils.h"
26 
27 using namespace PBD;
28 
29 namespace ARDOUR
30 {
31 
32 /* ExportChannelConfiguration */
33 
34 ExportChannelConfiguration::ExportChannelConfiguration (Session & session)
35  : session (session)
36  , split (false)
37  , region_type (RegionExportChannelFactory::None)
38 {
39 
40 }
41 
42 XMLNode &
44 {
45  XMLNode * root = new XMLNode ("ExportChannelConfiguration");
46  XMLNode * channel;
47 
48  root->add_property ("split", get_split() ? "true" : "false");
49  root->add_property ("channels", to_string (get_n_chans(), std::dec));
50 
51  switch (region_type) {
53  // Do nothing
54  break;
55  default:
56  root->add_property ("region-processing", enum_2_string (region_type));
57  break;
58  }
59 
60  uint32_t i = 1;
61  for (ExportChannelConfiguration::ChannelList::const_iterator c_it = channels.begin(); c_it != channels.end(); ++c_it) {
62  channel = root->add_child ("Channel");
63  if (!channel) { continue; }
64 
65  channel->add_property ("number", to_string (i, std::dec));
66  (*c_it)->get_state (channel);
67 
68  ++i;
69  }
70 
71  return *root;
72 }
73 
74 int
76 {
77  XMLProperty const * prop;
78 
79  if ((prop = root.property ("split"))) {
80  set_split (!prop->value().compare ("true"));
81  }
82 
83  if ((prop = root.property ("region-processing"))) {
86  }
87 
88  XMLNodeList channels = root.children ("Channel");
89  for (XMLNodeList::iterator it = channels.begin(); it != channels.end(); ++it) {
90  ExportChannelPtr channel (new PortExportChannel ());
91  channel->set_state (*it, session);
92  register_channel (channel);
93  }
94 
95  return 0;
96 }
97 
98 bool
100 {
101  for (ChannelList::const_iterator it = channels.begin(); it != channels.end(); ++it) {
102  if ((*it)->empty ()) { return false; }
103  }
104 
105  return true;
106 }
107 
108 void
110 {
111  configs.clear ();
112 
113  if (!split) {
114  configs.push_back (shared_from_this ());
115  return;
116  }
117 
118  for (ChannelList::const_iterator it = channels.begin (); it != channels.end (); ++it) {
120  config->set_name (_name);
121  config->register_channel (*it);
122  configs.push_back (config);
123  }
124 }
125 
126 } // namespace ARDOUR
Handles RegionExportChannels and does actual reading from region.
std::string to_string(T t, std::ios_base &(*f)(std::ios_base &))
Definition: convert.h:53
const std::string & value() const
Definition: xml++.h:159
#define enum_2_string(e)
Definition: enumwriter.h:97
void set_region_processing_type(RegionExportChannelFactory::Type type)
LIBPBD_API void split(std::string, std::vector< std::string > &, char)
Basic export channel that reads from AudioPorts.
const XMLNodeList & children(const std::string &str=std::string()) const
Definition: xml++.cc:329
XMLNode * add_child(const char *)
Definition: xml++.cc:351
void configurations_for_files(std::list< boost::shared_ptr< ExportChannelConfiguration > > &configs)
std::list< XMLNode * > XMLNodeList
Definition: xml++.h:44
XMLProperty * property(const char *)
Definition: xml++.cc:413
#define string_2_enum(str, e)
Definition: enumwriter.h:98
Definition: amp.h:29
RegionExportChannelFactory::Type region_type
XMLProperty * add_property(const char *name, const std::string &value)
void register_channel(ExportChannelPtr channel)
Definition: xml++.h:95
Definition: debug.h:30