Some refactoring. Add port group headers to the port matrix.

git-svn-id: svn://localhost/ardour2/branches/3.0@4443 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Carl Hetherington 2009-01-25 06:47:11 +00:00
parent a9d67a2cc9
commit 49510ba1d7
27 changed files with 486 additions and 328 deletions

View file

@ -127,8 +127,8 @@ class IO : public SessionObject, public AutomatableControls, public Latent
int connect_input_ports_to_bundle (boost::shared_ptr<Bundle>, void *src);
int connect_output_ports_to_bundle (boost::shared_ptr<Bundle>, void *src);
std::vector<boost::shared_ptr<Bundle> > bundles_connected_to_inputs ();
std::vector<boost::shared_ptr<Bundle> > bundles_connected_to_outputs ();
BundleList bundles_connected_to_inputs ();
BundleList bundles_connected_to_outputs ();
boost::shared_ptr<Bundle> bundle_for_inputs () { return _bundle_for_inputs; }
boost::shared_ptr<Bundle> bundle_for_outputs () { return _bundle_for_outputs; }
@ -380,9 +380,6 @@ class IO : public SessionObject, public AutomatableControls, public Latent
void create_bundles_for_inputs_and_outputs ();
void setup_bundles_for_inputs_and_outputs ();
void maybe_add_input_bundle_to_list (boost::shared_ptr<Bundle>, std::vector<boost::shared_ptr<Bundle> >*);
void maybe_add_output_bundle_to_list (boost::shared_ptr<Bundle>, std::vector<boost::shared_ptr<Bundle> >*);
};
} // namespace ARDOUR

View file

@ -317,6 +317,10 @@ class Session : public PBD::StatefulDestructible
uint32_t ntracks () const;
uint32_t nbusses () const;
boost::shared_ptr<BundleList> bundles () {
return _bundles.reader ();
}
struct RoutePublicOrderSorter {
bool operator() (boost::shared_ptr<Route>, boost::shared_ptr<Route> b);
};
@ -771,7 +775,6 @@ class Session : public PBD::StatefulDestructible
/* I/O bundles */
void foreach_bundle (sigc::slot<void, boost::shared_ptr<Bundle> >);
void add_bundle (boost::shared_ptr<Bundle>);
void remove_bundle (boost::shared_ptr<Bundle>);
boost::shared_ptr<Bundle> bundle_by_name (string) const;
@ -1616,9 +1619,7 @@ class Session : public PBD::StatefulDestructible
/* I/O bundles */
typedef list<boost::shared_ptr<Bundle> > BundleList;
mutable Glib::Mutex bundle_lock;
BundleList _bundles;
SerializedRCUManager<BundleList> _bundles;
XMLNode* _bundle_xml_node;
int load_bundles (XMLNode const &);

View file

@ -419,6 +419,9 @@ namespace ARDOUR {
typedef std::list<nframes64_t> AnalysisFeatureList;
class Bundle;
typedef std::vector<boost::shared_ptr<Bundle> > BundleList;
} // namespace ARDOUR
std::istream& operator>>(std::istream& o, ARDOUR::SampleFormat& sf);

View file

@ -2629,42 +2629,11 @@ IO::create_bundles_for_inputs_and_outputs ()
setup_bundles_for_inputs_and_outputs ();
}
/** Add a bundle to a list if is connected to our inputs.
* @param b Bundle to check.
* @param bundles List to add to.
*/
void
IO::maybe_add_input_bundle_to_list (boost::shared_ptr<Bundle> b, std::vector<boost::shared_ptr<Bundle> >* bundles)
{
if (b->ports_are_outputs() == false) {
return;
}
if (b->nchannels() != n_inputs().n_total ()) {
return;
}
for (uint32_t i = 0; i < n_inputs().n_total (); ++i) {
Bundle::PortList const & pl = b->channel_ports (i);
if (pl.empty()) {
return;
}
if (!input(i)->connected_to (pl[0])) {
return;
}
}
bundles->push_back (b);
}
/** @return Bundles connected to our inputs */
std::vector<boost::shared_ptr<Bundle> >
BundleList
IO::bundles_connected_to_inputs ()
{
std::vector<boost::shared_ptr<Bundle> > bundles;
BundleList bundles;
/* User bundles */
for (std::vector<UserBundleInfo>::iterator i = _bundles_connected_to_inputs.begin(); i != _bundles_connected_to_inputs.end(); ++i) {
@ -2672,51 +2641,31 @@ IO::bundles_connected_to_inputs ()
}
/* Normal bundles */
_session.foreach_bundle (
sigc::bind (sigc::mem_fun (*this, &IO::maybe_add_input_bundle_to_list), &bundles)
);
boost::shared_ptr<ARDOUR::BundleList> b = _session.bundles ();
for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
if ((*i)->ports_are_outputs() == false || (*i)->nchannels() != n_inputs().n_total()) {
continue;
}
for (uint32_t j = 0; j < n_inputs().n_total(); ++j) {
Bundle::PortList const& pl = (*i)->channel_ports (j);
if (!pl.empty() && input(j)->connected_to (pl[0])) {
bundles.push_back (*i);
}
}
}
return bundles;
}
/** Add a bundle to a list if is connected to our outputs.
* @param b Bundle to check.
* @param bundles List to add to.
*/
void
IO::maybe_add_output_bundle_to_list (boost::shared_ptr<Bundle> b, std::vector<boost::shared_ptr<Bundle> >* bundles)
{
if (b->ports_are_inputs() == false) {
return;
}
if (b->nchannels () != n_outputs().n_total ()) {
return;
}
for (uint32_t i = 0; i < n_outputs().n_total (); ++i) {
Bundle::PortList const & pl = b->channel_ports (i);
if (pl.empty()) {
return;
}
if (!output(i)->connected_to (pl[0])) {
return;
}
}
bundles->push_back (b);
}
/* @return Bundles connected to our outputs */
std::vector<boost::shared_ptr<Bundle> >
BundleList
IO::bundles_connected_to_outputs ()
{
std::vector<boost::shared_ptr<Bundle> > bundles;
BundleList bundles;
/* User bundles */
for (std::vector<UserBundleInfo>::iterator i = _bundles_connected_to_outputs.begin(); i != _bundles_connected_to_outputs.end(); ++i) {
@ -2724,9 +2673,21 @@ IO::bundles_connected_to_outputs ()
}
/* Auto bundles */
_session.foreach_bundle (
sigc::bind (sigc::mem_fun (*this, &IO::maybe_add_output_bundle_to_list), &bundles)
);
boost::shared_ptr<ARDOUR::BundleList> b = _session.bundles ();
for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
if ((*i)->ports_are_inputs() == false || (*i)->nchannels() != n_outputs().n_total()) {
continue;
}
for (uint32_t j = 0; j < n_outputs().n_total(); ++j) {
Bundle::PortList const& pl = (*i)->channel_ports (j);
if (!pl.empty() && output(j)->connected_to (pl[0])) {
bundles.push_back (*i);
}
}
}
return bundles;
}

View file

@ -138,6 +138,7 @@ Session::Session (AudioEngine &eng,
routes (new RouteList),
auditioner ((Auditioner*) 0),
_total_free_4k_blocks (0),
_bundles (new BundleList),
_bundle_xml_node (0),
_click_io ((IO*) 0),
click_data (0),
@ -219,6 +220,7 @@ Session::Session (AudioEngine &eng,
routes (new RouteList),
auditioner ((Auditioner *) 0),
_total_free_4k_blocks (0),
_bundles (new BundleList),
_bundle_xml_node (0),
_click_io ((IO *) 0),
click_data (0),
@ -3761,8 +3763,9 @@ void
Session::add_bundle (shared_ptr<Bundle> bundle)
{
{
Glib::Mutex::Lock guard (bundle_lock);
_bundles.push_back (bundle);
RCUWriter<BundleList> writer (_bundles);
boost::shared_ptr<BundleList> b = writer.get_copy ();
b->push_back (bundle);
}
BundleAdded (bundle); /* EMIT SIGNAL */
@ -3776,11 +3779,12 @@ Session::remove_bundle (shared_ptr<Bundle> bundle)
bool removed = false;
{
Glib::Mutex::Lock guard (bundle_lock);
BundleList::iterator i = find (_bundles.begin(), _bundles.end(), bundle);
RCUWriter<BundleList> writer (_bundles);
boost::shared_ptr<BundleList> b = writer.get_copy ();
BundleList::iterator i = find (b->begin(), b->end(), bundle);
if (i != _bundles.end()) {
_bundles.erase (i);
if (i != b->end()) {
b->erase (i);
removed = true;
}
}
@ -3795,9 +3799,9 @@ Session::remove_bundle (shared_ptr<Bundle> bundle)
shared_ptr<Bundle>
Session::bundle_by_name (string name) const
{
Glib::Mutex::Lock lm (bundle_lock);
for (BundleList::const_iterator i = _bundles.begin(); i != _bundles.end(); ++i) {
boost::shared_ptr<BundleList> b = _bundles.reader ();
for (BundleList::const_iterator i = b->begin(); i != b->end(); ++i) {
if ((*i)->name() == name) {
return* i;
}
@ -4290,12 +4294,4 @@ Session::sync_order_keys (const char* base)
Route::SyncOrderKeys (base); // EMIT SIGNAL
}
void
Session::foreach_bundle (sigc::slot<void, boost::shared_ptr<Bundle> > sl)
{
Glib::Mutex::Lock lm (bundle_lock);
for (BundleList::iterator i = _bundles.begin(); i != _bundles.end(); ++i) {
sl (*i);
}
}

View file

@ -1061,8 +1061,8 @@ Session::state(bool full_state)
child = node->add_child ("Bundles");
{
Glib::Mutex::Lock lm (bundle_lock);
for (BundleList::iterator i = _bundles.begin(); i != _bundles.end(); ++i) {
boost::shared_ptr<BundleList> bundles = _bundles.reader ();
for (BundleList::iterator i = bundles->begin(); i != bundles->end(); ++i) {
boost::shared_ptr<UserBundle> b = boost::dynamic_pointer_cast<UserBundle> (*i);
if (b) {
child->add_child_nocopy (b->get_state());