diff options
-rw-r--r-- | libs/ardour/ardour/route.h | 6 | ||||
-rw-r--r-- | libs/ardour/ardour/send.h | 1 | ||||
-rw-r--r-- | libs/ardour/ardour/session.h | 5 | ||||
-rw-r--r-- | libs/ardour/midi_diskstream.cc | 2 | ||||
-rw-r--r-- | libs/ardour/midi_port.cc | 4 | ||||
-rw-r--r-- | libs/ardour/route.cc | 15 | ||||
-rw-r--r-- | libs/ardour/send.cc | 42 | ||||
-rw-r--r-- | libs/ardour/session.cc | 67 |
8 files changed, 115 insertions, 27 deletions
diff --git a/libs/ardour/ardour/route.h b/libs/ardour/ardour/route.h index e41682dd8e..1724439dc2 100644 --- a/libs/ardour/ardour/route.h +++ b/libs/ardour/ardour/route.h @@ -163,7 +163,6 @@ class Route : public SessionObject, public Automatable, public RouteGroupMember, void set_listen (bool yn, void* src); bool listening_via_monitor () const; void enable_monitor_send (); - void disable_monitor_send (); void set_phase_invert (uint32_t, bool yn); void set_phase_invert (boost::dynamic_bitset<>); @@ -305,9 +304,8 @@ class Route : public SessionObject, public Automatable, public RouteGroupMember, PBD::Signal1<void,void*> SelectedChanged; - int listen_via_monitor (); - int listen_via (boost::shared_ptr<Route>, Placement p); - void drop_listen (boost::shared_ptr<Route>); + int add_aux_send (boost::shared_ptr<Route>, Placement p); + void remove_aux_or_listen (boost::shared_ptr<Route>); /** * return true if this route feeds the first argument via at least one diff --git a/libs/ardour/ardour/send.h b/libs/ardour/ardour/send.h index 6afc131e70..ddb9e60285 100644 --- a/libs/ardour/ardour/send.h +++ b/libs/ardour/ardour/send.h @@ -79,6 +79,7 @@ class Send : public Delivery int set_state_2X (XMLNode const &, int); uint32_t _bitslot; + static std::string name_and_id_new_send (Session&, Delivery::Role r, uint32_t&); }; } // namespace ARDOUR diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index fab442f07a..1df8ac6c49 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -51,6 +51,7 @@ #include "ardour/ardour.h" #include "ardour/chan_count.h" +#include "ardour/delivery.h" #include "ardour/rc_configuration.h" #include "ardour/session_configuration.h" #include "ardour/session_event.h" @@ -650,12 +651,15 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi } uint32_t next_send_id(); + uint32_t next_aux_send_id(); uint32_t next_return_id(); uint32_t next_insert_id(); void mark_send_id (uint32_t); + void mark_aux_send_id (uint32_t); void mark_return_id (uint32_t); void mark_insert_id (uint32_t); void unmark_send_id (uint32_t); + void unmark_aux_send_id (uint32_t); void unmark_return_id (uint32_t); void unmark_insert_id (uint32_t); @@ -1313,6 +1317,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi /* INSERT AND SEND MANAGEMENT */ boost::dynamic_bitset<uint32_t> send_bitset; + boost::dynamic_bitset<uint32_t> aux_send_bitset; boost::dynamic_bitset<uint32_t> return_bitset; boost::dynamic_bitset<uint32_t> insert_bitset; diff --git a/libs/ardour/midi_diskstream.cc b/libs/ardour/midi_diskstream.cc index e3d7014457..fd6e1707db 100644 --- a/libs/ardour/midi_diskstream.cc +++ b/libs/ardour/midi_diskstream.cc @@ -737,7 +737,7 @@ MidiDiskstream::read (framepos_t& start, framecnt_t dur, bool reversed) start = loop_start + ((start - loop_start) % loop_length); //cerr << "to " << start << endl; } - // cerr << "start is " << start << " loopstart: " << loop_start << " loopend: " << loop_end << endl; + // cerr << "start is " << start << " end " << start+dur << " loopstart: " << loop_start << " loopend: " << loop_end << endl; } while (dur) { diff --git a/libs/ardour/midi_port.cc b/libs/ardour/midi_port.cc index 9383bb237b..0f91dd3e36 100644 --- a/libs/ardour/midi_port.cc +++ b/libs/ardour/midi_port.cc @@ -182,8 +182,8 @@ MidiPort::flush_buffers (pframes_t nframes, framepos_t /*time*/) << ev.time() << " > " << _global_port_buffer_offset + _port_buffer_offset << endl; } } else { - cerr << "drop flushed event on the floor, time " << ev.time() - << " < " << _global_port_buffer_offset + _port_buffer_offset << endl; + cerr << "drop flushed event on the floor, time " << ev + << " to early for " << _global_port_buffer_offset + _port_buffer_offset << endl; } } } diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index de2e801d31..1481a1fd1c 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -2595,12 +2595,12 @@ Route::enable_monitor_send () configure_processors (0); } -/** Add an internal send to a route. +/** Add an aux send to a route. * @param route route to send to. * @param placement placement for the send. */ int -Route::listen_via (boost::shared_ptr<Route> route, Placement placement) +Route::add_aux_send (boost::shared_ptr<Route> route, Placement placement) { assert (route != _session.monitor_out ()); @@ -2619,7 +2619,14 @@ Route::listen_via (boost::shared_ptr<Route> route, Placement placement) } try { - boost::shared_ptr<InternalSend> listener (new InternalSend (_session, _pannable, _mute_master, route, Delivery::Aux)); + + boost::shared_ptr<InternalSend> listener; + + { + Glib::Mutex::Lock lm (AudioEngine::instance()->process_lock ()); + listener.reset (new InternalSend (_session, _pannable, _mute_master, route, Delivery::Aux)); + } + add_processor (listener, placement); } catch (failed_constructor& err) { @@ -2630,7 +2637,7 @@ Route::listen_via (boost::shared_ptr<Route> route, Placement placement) } void -Route::drop_listen (boost::shared_ptr<Route> route) +Route::remove_aux_or_listen (boost::shared_ptr<Route> route) { ProcessorStreams err; ProcessorList::iterator tmp; diff --git a/libs/ardour/send.cc b/libs/ardour/send.cc index f299995ffa..fb364e38d6 100644 --- a/libs/ardour/send.cc +++ b/libs/ardour/send.cc @@ -39,8 +39,26 @@ using namespace ARDOUR; using namespace PBD; using namespace std; +string +Send::name_and_id_new_send (Session& s, Role r, uint32_t& bitslot) +{ + switch (r) { + case Delivery::Aux: + return string_compose (_("aux %1"), (bitslot = s.next_aux_send_id ()) + 1); + case Delivery::Listen: + return _("listen"); // no ports, no need for numbering + case Delivery::Send: + return string_compose (_("send %1"), (bitslot = s.next_send_id ()) + 1); + default: + fatal << string_compose (_("programming error: send created using role %1"), enum_2_string (r)) << endmsg; + /*NOTREACHED*/ + return string(); + } + +} + Send::Send (Session& s, boost::shared_ptr<Pannable> p, boost::shared_ptr<MuteMaster> mm, Role r) - : Delivery (s, p, mm, string_compose (_("send %1"), (_bitslot = s.next_send_id()) + 1), r) + : Delivery (s, p, mm, name_and_id_new_send (s, r, _bitslot), r) , _metering (false) { boost_debug_shared_ptr_mark_interesting (this, "send"); @@ -157,11 +175,25 @@ Send::set_state (const XMLNode& node, int version) */ if ((prop = node.property ("bitslot")) == 0) { - _bitslot = _session.next_send_id(); + if (_role == Delivery::Aux) { + _bitslot = _session.next_aux_send_id (); + } else if (_role == Delivery::Send) { + _bitslot = _session.next_send_id (); + } else { + // bitslot doesn't matter + } } else { - _session.unmark_send_id (_bitslot); - sscanf (prop->value().c_str(), "%" PRIu32, &_bitslot); - _session.mark_send_id (_bitslot); + if (_role == Delivery::Aux) { + _session.unmark_aux_send_id (_bitslot); + sscanf (prop->value().c_str(), "%" PRIu32, &_bitslot); + _session.mark_aux_send_id (_bitslot); + } else if (_role == Delivery::Send) { + _session.unmark_send_id (_bitslot); + sscanf (prop->value().c_str(), "%" PRIu32, &_bitslot); + _session.mark_send_id (_bitslot); + } else { + // bitslot doesn't matter + } } XMLNodeList nlist = node.children(); diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index ef0a6c2a48..7ee854dc2d 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -624,7 +624,7 @@ Session::remove_monitor_section () } else if ((*x)->is_master()) { /* relax */ } else { - (*x)->drop_listen (_monitor_out); + (*x)->remove_aux_or_listen (_monitor_out); } } } @@ -2143,13 +2143,17 @@ Session::add_routes (RouteList& new_routes, bool auto_connect, bool save) if (_monitor_out && IO::connecting_legal) { - for (RouteList::iterator x = new_routes.begin(); x != new_routes.end(); ++x) { - if ((*x)->is_monitor()) { - /* relax */ - } else if ((*x)->is_master()) { - /* relax */ - } else { - (*x)->enable_monitor_send (); + { + Glib::Mutex::Lock lm (_engine.process_lock()); + + for (RouteList::iterator x = new_routes.begin(); x != new_routes.end(); ++x) { + if ((*x)->is_monitor()) { + /* relax */ + } else if ((*x)->is_master()) { + /* relax */ + } else { + (*x)->enable_monitor_send (); + } } } @@ -2233,13 +2237,14 @@ Session::add_internal_sends (boost::shared_ptr<Route> dest, Placement p, boost:: dest->add_internal_return(); } + for (RouteList::iterator i = senders->begin(); i != senders->end(); ++i) { - + if ((*i)->is_monitor() || (*i)->is_master() || (*i) == dest) { continue; } - - (*i)->listen_via (dest, p); + + (*i)->add_aux_send (dest, p); } graph_reordered (); @@ -3622,6 +3627,26 @@ Session::next_send_id () } uint32_t +Session::next_aux_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 < aux_send_bitset.size(); ++n) { + if (!aux_send_bitset[n]) { + aux_send_bitset[n] = true; + return n; + + } + } + + /* none available, so resize and try again */ + + aux_send_bitset.resize (aux_send_bitset.size() + 16, false); + } +} + +uint32_t Session::next_return_id () { /* this doesn't really loop forever. just think about it */ @@ -3654,6 +3679,18 @@ Session::mark_send_id (uint32_t id) } void +Session::mark_aux_send_id (uint32_t id) +{ + if (id >= aux_send_bitset.size()) { + aux_send_bitset.resize (id+16, false); + } + if (aux_send_bitset[id]) { + warning << string_compose (_("aux send ID %1 appears to be in use already"), id) << endmsg; + } + aux_send_bitset[id] = true; +} + +void Session::mark_return_id (uint32_t id) { if (id >= return_bitset.size()) { @@ -3686,6 +3723,14 @@ Session::unmark_send_id (uint32_t id) } void +Session::unmark_aux_send_id (uint32_t id) +{ + if (id < aux_send_bitset.size()) { + aux_send_bitset[id] = false; + } +} + +void Session::unmark_return_id (uint32_t id) { if (id < return_bitset.size()) { |