fix two major assert failures arising from the optional monitor section commit; separate numbering of aux sends, sends and listens to fix #3671 (still testing, but the assert failures are critical)

git-svn-id: svn://localhost/ardour2/branches/3.0@11263 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2012-01-18 17:51:57 +00:00
parent 8983d84fb2
commit 9524b08752
8 changed files with 115 additions and 27 deletions

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -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) {

View File

@ -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;
}
}
}

View File

@ -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;

View File

@ -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();

View File

@ -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 ();
@ -3621,6 +3626,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 ()
{
@ -3653,6 +3678,18 @@ Session::mark_send_id (uint32_t id)
send_bitset[id] = true;
}
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)
{
@ -3685,6 +3722,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)
{