diff options
Diffstat (limited to 'libs')
-rw-r--r-- | libs/ardour/ardour/insert.h | 11 | ||||
-rw-r--r-- | libs/ardour/ardour/route.h | 2 | ||||
-rw-r--r-- | libs/ardour/ardour/send.h | 6 | ||||
-rw-r--r-- | libs/ardour/ardour/session.h | 12 | ||||
-rw-r--r-- | libs/ardour/insert.cc | 30 | ||||
-rw-r--r-- | libs/ardour/route.cc | 15 | ||||
-rw-r--r-- | libs/ardour/send.cc | 15 | ||||
-rw-r--r-- | libs/ardour/session.cc | 86 |
8 files changed, 120 insertions, 57 deletions
diff --git a/libs/ardour/ardour/insert.h b/libs/ardour/ardour/insert.h index 61bee6c803..99b4e4b373 100644 --- a/libs/ardour/ardour/insert.h +++ b/libs/ardour/ardour/insert.h @@ -45,10 +45,8 @@ class Plugin; class Insert : public Redirect { public: - Insert(Session& s, Placement p); - Insert(Session& s, string name, Placement p); - - Insert(Session& s, Placement p, int imin, int imax, int omin, int omax); + Insert(Session& s, std::string name, Placement p); + Insert(Session& s, std::string name, Placement p, int imin, int imax, int omin, int omax); virtual ~Insert() { } @@ -84,6 +82,11 @@ class PortInsert : public Insert int32_t can_support_input_configuration (int32_t) const; int32_t configure_io (int32_t magic, int32_t in, int32_t out); int32_t compute_output_streams (int32_t cnt) const; + + uint32_t bit_slot() const { return bitslot; } + + private: + uint32_t bitslot; }; class PluginInsert : public Insert diff --git a/libs/ardour/ardour/route.h b/libs/ardour/ardour/route.h index 2067c31b9c..869d7eb239 100644 --- a/libs/ardour/ardour/route.h +++ b/libs/ardour/ardour/route.h @@ -173,8 +173,6 @@ class Route : public IO void all_redirects_flip(); void all_redirects_active (bool state); - uint32_t count_sends (); - virtual nframes_t update_total_latency(); nframes_t signal_latency() const { return _own_latency; } virtual void set_latency_delay (nframes_t); diff --git a/libs/ardour/ardour/send.h b/libs/ardour/ardour/send.h index d22d483a8f..38c3d2a20a 100644 --- a/libs/ardour/ardour/send.h +++ b/libs/ardour/ardour/send.h @@ -33,12 +33,15 @@ namespace ARDOUR { -class Send : public Redirect { +class Send : public Redirect +{ public: Send (Session&, Placement); Send (Session&, const XMLNode&); Send (const Send&); ~Send (); + + uint32_t bit_slot() const { return bitslot; } void run (vector<Sample *> &bufs, uint32_t nbufs, nframes_t nframes, nframes_t offset); void activate() {} @@ -58,6 +61,7 @@ class Send : public Redirect { private: bool _metering; uint32_t expected_inputs; + uint32_t bitslot; }; } // namespace ARDOUR diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 5aa53e274f..03e50d152d 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -30,6 +30,7 @@ #include <stack> #include <boost/weak_ptr.hpp> +#include <boost/dynamic_bitset.hpp> #include <stdint.h> @@ -677,9 +678,11 @@ class Session : public PBD::StatefulDestructible uint32_t n_plugin_inserts() const { return _plugin_inserts.size(); } uint32_t n_sends() const { return _sends.size(); } - string next_send_name(); - string next_insert_name(); - + uint32_t next_send_id(); + uint32_t next_insert_id(); + void mark_send_id (uint32_t); + void mark_insert_id (uint32_t); + /* s/w "RAID" management */ nframes_t available_capture_duration(); @@ -1520,9 +1523,12 @@ class Session : public PBD::StatefulDestructible list<PortInsert *> _port_inserts; list<PluginInsert *> _plugin_inserts; list<Send *> _sends; + boost::dynamic_bitset<uint32_t> send_bitset; + boost::dynamic_bitset<uint32_t> insert_bitset; uint32_t send_cnt; uint32_t insert_cnt; + void add_redirect (Redirect *); void remove_redirect (Redirect *); diff --git a/libs/ardour/insert.cc b/libs/ardour/insert.cc index 0416d3e1e4..8231cbbbe6 100644 --- a/libs/ardour/insert.cc +++ b/libs/ardour/insert.cc @@ -49,18 +49,13 @@ using namespace std; using namespace ARDOUR; using namespace PBD; -Insert::Insert(Session& s, Placement p) - : Redirect (s, s.next_insert_name(), p) +Insert::Insert(Session& s, string name, Placement p) + : Redirect (s, name, p) { } -Insert::Insert(Session& s, Placement p, int imin, int imax, int omin, int omax) - : Redirect (s, s.next_insert_name(), p, imin, imax, omin, omax) -{ -} - -Insert::Insert(Session& s, string name, Placement p) - : Redirect (s, name, p) +Insert::Insert(Session& s, string name, Placement p, int imin, int imax, int omin, int omax) + : Redirect (s, name, p, imin, imax, omin, omax) { } @@ -833,7 +828,7 @@ PluginInsert::type () ***************************************************************/ PortInsert::PortInsert (Session& s, Placement p) - : Insert (s, p, 1, -1, 1, -1) + : Insert (s, string_compose (_("insert %1"), (bitslot = s.next_insert_id()) + 1), p, 1, -1, 1, -1) { init (); RedirectCreated (this); /* EMIT SIGNAL */ @@ -841,7 +836,7 @@ PortInsert::PortInsert (Session& s, Placement p) } PortInsert::PortInsert (const PortInsert& other) - : Insert (other._session, other.placement(), 1, -1, 1, -1) + : Insert (other._session, string_compose (_("insert %1"), (bitslot = other._session.next_insert_id()) + 1), other.placement(), 1, -1, 1, -1) { init (); RedirectCreated (this); /* EMIT SIGNAL */ @@ -917,9 +912,11 @@ XMLNode& PortInsert::state (bool full) { XMLNode *node = new XMLNode("Insert"); - + char buf[32]; node->add_child_nocopy (Redirect::state(full)); - node->add_property("type", "port"); + node->add_property ("type", "port"); + snprintf (buf, sizeof (buf), "%" PRIu32, bitslot); + node->add_property ("bitslot", buf); return *node; } @@ -942,6 +939,13 @@ PortInsert::set_state(const XMLNode& node) return -1; } + if ((prop = node.property ("bitslot")) == 0) { + bitslot = _session.next_insert_id(); + } else { + sscanf (prop->value().c_str(), "%" PRIu32, &bitslot); + _session.mark_insert_id (bitslot); + } + for (niter = nlist.begin(); niter != nlist.end(); ++niter) { if ((*niter)->name() == Redirect::state_node_name) { Redirect::set_state (**niter); diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index 4e82e89b3e..a322c10068 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -781,21 +781,6 @@ Route::set_mute (bool yn, void *src) } } -uint32_t -Route::count_sends () -{ - uint32_t cnt = 0; - Glib::RWLock::ReaderLock lm (redirect_lock); - - for (RedirectList::iterator i = _redirects.begin(); i != _redirects.end(); ++i) { - if (boost::dynamic_pointer_cast<Send> (*i)) { - ++cnt; - } - } - - return cnt; -} - int Route::add_redirect (boost::shared_ptr<Redirect> redirect, void *src, uint32_t* err_streams) { diff --git a/libs/ardour/send.cc b/libs/ardour/send.cc index 21069e3899..7888f89d41 100644 --- a/libs/ardour/send.cc +++ b/libs/ardour/send.cc @@ -32,7 +32,7 @@ using namespace ARDOUR; using namespace PBD; Send::Send (Session& s, Placement p) - : Redirect (s, s.next_send_name(), p) + : Redirect (s, string_compose (_("send %1"), (bitslot = s.next_send_id()) + 1), p) { _metering = false; expected_inputs = 0; @@ -53,7 +53,7 @@ Send::Send (Session& s, const XMLNode& node) } Send::Send (const Send& other) - : Redirect (other._session, other._session.next_send_name(), other.placement()) + : Redirect (other._session, string_compose (_("send %1"), (bitslot = other._session.next_send_id()) + 1), other.placement()) { _metering = false; expected_inputs = 0; @@ -76,7 +76,10 @@ XMLNode& Send::state(bool full) { XMLNode *node = new XMLNode("Send"); + char buf[32]; node->add_child_nocopy (Redirect::state (full)); + snprintf (buf, sizeof (buf), "%" PRIu32, bitslot); + node->add_property ("bitslot", buf); return *node; } @@ -85,6 +88,14 @@ Send::set_state(const XMLNode& node) { XMLNodeList nlist = node.children(); XMLNodeIterator niter; + const XMLProperty* prop; + + if ((prop = node.property ("bitslot")) == 0) { + bitslot = _session.next_send_id(); + } else { + sscanf (prop->value().c_str(), "%" PRIu32, &bitslot); + _session.mark_send_id (bitslot); + } /* Send has regular IO automation (gain, pan) */ diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index c6cd6528d3..4d8a77613c 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -3347,10 +3347,14 @@ Session::remove_redirect (Redirect* redirect) Insert* insert; PortInsert* port_insert; PluginInsert* plugin_insert; - + if ((insert = dynamic_cast<Insert *> (redirect)) != 0) { if ((port_insert = dynamic_cast<PortInsert *> (insert)) != 0) { - _port_inserts.remove (port_insert); + list<PortInsert*>::iterator x = find (_port_inserts.begin(), _port_inserts.end(), port_insert); + if (x != _port_inserts.end()) { + insert_bitset[port_insert->bit_slot()] = false; + _port_inserts.erase (x); + } } else if ((plugin_insert = dynamic_cast<PluginInsert *> (insert)) != 0) { _plugin_inserts.remove (plugin_insert); } else { @@ -3360,7 +3364,11 @@ Session::remove_redirect (Redirect* redirect) /*NOTREACHED*/ } } else if ((send = dynamic_cast<Send *> (redirect)) != 0) { - _sends.remove (send); + list<Send*>::iterator x = find (_sends.begin(), _sends.end(), send); + if (x != _sends.end()) { + send_bitset[send->bit_slot()] = false; + _sends.erase (x); + } } else { fatal << _("programming error: unknown type of Redirect deleted!") << endmsg; /*NOTREACHED*/ @@ -3492,26 +3500,70 @@ Session::ensure_passthru_buffers (uint32_t howmany) allocate_pan_automation_buffers (current_block_size, howmany, false); } -string -Session::next_send_name () +uint32_t +Session::next_insert_id () { - uint32_t cnt = 0; - - shared_ptr<RouteList> r = routes.reader (); - - for (RouteList::const_iterator i = r->begin(); i != r->end(); ++i) { - cnt += (*i)->count_sends (); + /* this doesn't really loop forever. just think about it */ + + while (true) { + for (boost::dynamic_bitset<uint32_t>::size_type n = 0; n < insert_bitset.size(); ++n) { + if (!insert_bitset[n]) { + insert_bitset[n] = true; + cerr << "Returning " << n << " as insert ID\n"; + return n; + + } + } + + /* none available, so resize and try again */ + + insert_bitset.resize (insert_bitset.size() + 16, false); + } +} + +uint32_t +Session::next_send_id () +{ + /* this doesn't really loop forever. just think about it */ + + while (true) { + for (boost::dynamic_bitset<uint32_t>::size_type n = 0; n < send_bitset.size(); ++n) { + if (!send_bitset[n]) { + send_bitset[n] = true; + cerr << "Returning " << n << " as send ID\n"; + return n; + + } + } + + /* none available, so resize and try again */ + + send_bitset.resize (send_bitset.size() + 16, false); } +} - return string_compose (_("send %1"), ++cnt); +void +Session::mark_send_id (uint32_t id) +{ + if (id >= send_bitset.size()) { + send_bitset.resize (id+16, false); + } + if (send_bitset[id]) { + warning << string_compose (_("send ID %1 appears to be in use already"), id) << endmsg; + } + send_bitset[id] = true; } -string -Session::next_insert_name () +void +Session::mark_insert_id (uint32_t id) { - char buf[32]; - snprintf (buf, sizeof (buf), "insert %" PRIu32, ++insert_cnt); - return buf; + if (id >= insert_bitset.size()) { + insert_bitset.resize (id+16, false); + } + if (insert_bitset[id]) { + warning << string_compose (_("insert ID %1 appears to be in use already"), id) << endmsg; + } + insert_bitset[id] = true; } /* Named Selection management */ |