redesign how XML state, bitslots and names get propagated during copying a send/port insert/return
git-svn-id: svn://localhost/ardour2/branches/3.0@11669 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
b557061ec4
commit
d46acb86ea
|
@ -45,6 +45,8 @@ class PortInsert : public IOProcessor
|
|||
{
|
||||
public:
|
||||
PortInsert (Session&, boost::shared_ptr<Pannable>, boost::shared_ptr<MuteMaster> mm);
|
||||
PortInsert (Session&, const std::string&, uint32_t bitslot,
|
||||
boost::shared_ptr<Pannable>, boost::shared_ptr<MuteMaster> mm);
|
||||
~PortInsert ();
|
||||
|
||||
XMLNode& state(bool full);
|
||||
|
@ -63,7 +65,7 @@ class PortInsert : public IOProcessor
|
|||
void activate ();
|
||||
void deactivate ();
|
||||
|
||||
uint32_t bit_slot() const { return bitslot; }
|
||||
uint32_t bit_slot() const { return _bitslot; }
|
||||
|
||||
void start_latency_detection ();
|
||||
void stop_latency_detection ();
|
||||
|
@ -72,13 +74,16 @@ class PortInsert : public IOProcessor
|
|||
void set_measured_latency (framecnt_t);
|
||||
framecnt_t latency () const;
|
||||
|
||||
static void make_unique (XMLNode &);
|
||||
static std::string name_and_id_new_insert (Session&, uint32_t&);
|
||||
|
||||
private:
|
||||
/* disallow copy construction */
|
||||
PortInsert (const PortInsert&);
|
||||
|
||||
boost::shared_ptr<Delivery> _out;
|
||||
|
||||
uint32_t bitslot;
|
||||
uint32_t _bitslot;
|
||||
MTDM* _mtdm;
|
||||
bool _latency_detect;
|
||||
framecnt_t _latency_flush_frames;
|
||||
|
|
|
@ -37,6 +37,7 @@ class Return : public IOProcessor
|
|||
{
|
||||
public:
|
||||
Return (Session&, bool internal = false);
|
||||
Return (Session&, const std::string& name, uint32_t bslot, bool internal = false);
|
||||
virtual ~Return ();
|
||||
|
||||
uint32_t bit_slot() const { return _bitslot; }
|
||||
|
@ -59,7 +60,8 @@ public:
|
|||
bool configure_io (ChanCount in, ChanCount out);
|
||||
|
||||
static uint32_t how_many_returns();
|
||||
static void make_unique (XMLNode &, Session &);
|
||||
static void make_unique (XMLNode &);
|
||||
static std::string name_and_id_new_return (Session&, uint32_t&);
|
||||
|
||||
protected:
|
||||
bool _metering;
|
||||
|
|
|
@ -36,6 +36,7 @@ class Send : public Delivery
|
|||
{
|
||||
public:
|
||||
Send (Session&, boost::shared_ptr<Pannable> pannable, boost::shared_ptr<MuteMaster>, Delivery::Role r = Delivery::Send);
|
||||
Send (Session&, const std::string& name, uint32_t bitslot, boost::shared_ptr<Pannable> pannable, boost::shared_ptr<MuteMaster>, Delivery::Role r = Delivery::Send);
|
||||
virtual ~Send ();
|
||||
|
||||
uint32_t bit_slot() const { return _bitslot; }
|
||||
|
@ -67,7 +68,8 @@ class Send : public Delivery
|
|||
std::string value_as_string (boost::shared_ptr<AutomationControl>) const;
|
||||
|
||||
static uint32_t how_many_sends();
|
||||
static void make_unique (XMLNode &, Session &);
|
||||
static void make_unique (XMLNode &);
|
||||
static std::string name_and_id_new_send (Session&, Delivery::Role r, uint32_t&);
|
||||
|
||||
protected:
|
||||
bool _metering;
|
||||
|
@ -81,7 +83,6 @@ 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
|
||||
|
|
|
@ -169,7 +169,7 @@ IOProcessor::set_state (const XMLNode& node, int version)
|
|||
XMLNodeIterator niter;
|
||||
const string instr = enum_2_string (IO::Input);
|
||||
const string outstr = enum_2_string (IO::Output);
|
||||
|
||||
|
||||
if (_own_input) {
|
||||
for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
|
||||
const XMLProperty* prop;
|
||||
|
@ -184,21 +184,21 @@ IOProcessor::set_state (const XMLNode& node, int version)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (io_node) {
|
||||
_input->set_state(*io_node, version);
|
||||
|
||||
|
||||
// legacy sessions: use IO name
|
||||
if ((prop = node.property ("name")) == 0) {
|
||||
set_name (_input->name());
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
/* no input, which is OK */
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (_own_output) {
|
||||
for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
|
||||
if ((*niter)->name() == "IO") {
|
||||
|
@ -215,10 +215,10 @@ IOProcessor::set_state (const XMLNode& node, int version)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (io_node) {
|
||||
_output->set_state(*io_node, version);
|
||||
|
||||
|
||||
// legacy sessions: use IO name
|
||||
if ((prop = node.property ("name")) == 0) {
|
||||
set_name (_output->name());
|
||||
|
|
|
@ -70,7 +70,7 @@ Port::Port (std::string const & n, DataType t, Flags f)
|
|||
}
|
||||
|
||||
if ((_jack_port = jack_port_register (_engine->jack (), _name.c_str (), t.to_jack_type (), _flags, 0)) == 0) {
|
||||
cerr << "Failed to register JACK port, reason is unknown from here\n";
|
||||
cerr << "Failed to register JACK port \"" << _name << "\", reason is unknown from here\n";
|
||||
throw failed_constructor ();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,8 +41,15 @@ using namespace std;
|
|||
using namespace ARDOUR;
|
||||
using namespace PBD;
|
||||
|
||||
string
|
||||
PortInsert::name_and_id_new_insert (Session& s, uint32_t& bitslot)
|
||||
{
|
||||
bitslot = s.next_insert_id ();
|
||||
return string_compose (_("insert %1"), bitslot+ 1);
|
||||
}
|
||||
|
||||
PortInsert::PortInsert (Session& s, boost::shared_ptr<Pannable> pannable, boost::shared_ptr<MuteMaster> mm)
|
||||
: IOProcessor (s, true, true, string_compose (_("insert %1"), (bitslot = s.next_insert_id()) + 1), "")
|
||||
: IOProcessor (s, true, true, name_and_id_new_insert (s, _bitslot), "")
|
||||
, _out (new Delivery (s, _output, pannable, mm, _name, Delivery::Insert))
|
||||
{
|
||||
_mtdm = 0;
|
||||
|
@ -51,9 +58,20 @@ PortInsert::PortInsert (Session& s, boost::shared_ptr<Pannable> pannable, boost:
|
|||
_measured_latency = 0;
|
||||
}
|
||||
|
||||
PortInsert::PortInsert (Session& s, const std::string& name, uint32_t bslot, boost::shared_ptr<Pannable> pannable, boost::shared_ptr<MuteMaster> mm)
|
||||
: IOProcessor (s, true, true, name, "")
|
||||
, _out (new Delivery (s, _output, pannable, mm, _name, Delivery::Insert))
|
||||
, _bitslot (bslot)
|
||||
{
|
||||
_mtdm = 0;
|
||||
_latency_detect = false;
|
||||
_latency_flush_frames = false;
|
||||
_measured_latency = 0;
|
||||
}
|
||||
|
||||
PortInsert::~PortInsert ()
|
||||
{
|
||||
_session.unmark_insert_id (bitslot);
|
||||
_session.unmark_insert_id (_bitslot);
|
||||
delete _mtdm;
|
||||
}
|
||||
|
||||
|
@ -164,7 +182,7 @@ PortInsert::state (bool full)
|
|||
XMLNode& node = IOProcessor::state(full);
|
||||
char buf[32];
|
||||
node.add_property ("type", "port");
|
||||
snprintf (buf, sizeof (buf), "%" PRIu32, bitslot);
|
||||
snprintf (buf, sizeof (buf), "%" PRIu32, _bitslot);
|
||||
node.add_property ("bitslot", buf);
|
||||
snprintf (buf, sizeof (buf), "%" PRId64, _measured_latency);
|
||||
node.add_property("latency", buf);
|
||||
|
@ -216,12 +234,14 @@ PortInsert::set_state (const XMLNode& node, int version)
|
|||
_measured_latency = latency;
|
||||
}
|
||||
|
||||
if ((prop = node.property ("bitslot")) == 0) {
|
||||
bitslot = _session.next_insert_id();
|
||||
} else {
|
||||
_session.unmark_insert_id (bitslot);
|
||||
sscanf (prop->value().c_str(), "%" PRIu32, &bitslot);
|
||||
_session.mark_insert_id (bitslot);
|
||||
if (!node.property ("ignore-bitslot")) {
|
||||
if ((prop = node.property ("bitslot")) == 0) {
|
||||
_bitslot = _session.next_insert_id();
|
||||
} else {
|
||||
_session.unmark_insert_id (_bitslot);
|
||||
sscanf (prop->value().c_str(), "%" PRIu32, &_bitslot);
|
||||
_session.mark_insert_id (_bitslot);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -295,3 +315,15 @@ PortInsert::deactivate ()
|
|||
|
||||
_out->deactivate ();
|
||||
}
|
||||
|
||||
/** Set up the XML description of a send so that we will not
|
||||
* reset its name or bitslot during ::set_state()
|
||||
* @param state XML insert state.
|
||||
*/
|
||||
|
||||
void
|
||||
PortInsert::make_unique (XMLNode &state)
|
||||
{
|
||||
state.add_property ("ignore-bitslot", "1");
|
||||
state.add_property ("ignore-name", "1");
|
||||
}
|
||||
|
|
|
@ -141,15 +141,15 @@ Processor::set_state_2X (const XMLNode & node, int /*version*/)
|
|||
XMLProperty const * prop;
|
||||
|
||||
XMLNodeList children = node.children ();
|
||||
|
||||
|
||||
for (XMLNodeIterator i = children.begin(); i != children.end(); ++i) {
|
||||
|
||||
if ((*i)->name() == X_("IO")) {
|
||||
|
||||
|
||||
if ((prop = (*i)->property ("name")) != 0) {
|
||||
set_name (prop->value ());
|
||||
}
|
||||
|
||||
|
||||
set_id (**i);
|
||||
|
||||
if ((prop = (*i)->property ("active")) != 0) {
|
||||
|
@ -177,17 +177,20 @@ Processor::set_state (const XMLNode& node, int version)
|
|||
|
||||
const XMLProperty *prop;
|
||||
const XMLProperty *legacy_active = 0;
|
||||
bool leave_name_alone = (node.property ("ignore-name") != 0);
|
||||
|
||||
// may not exist for legacy 3.0 sessions
|
||||
if ((prop = node.property ("name")) != 0) {
|
||||
/* don't let derived classes have a crack at set_name,
|
||||
as some (like Send) will screw with the one we suggest.
|
||||
*/
|
||||
Processor::set_name (prop->value());
|
||||
if (!leave_name_alone) {
|
||||
// may not exist for legacy 3.0 sessions
|
||||
if ((prop = node.property ("name")) != 0) {
|
||||
/* don't let derived classes have a crack at set_name,
|
||||
as some (like Send) will screw with the one we suggest.
|
||||
*/
|
||||
Processor::set_name (prop->value());
|
||||
}
|
||||
|
||||
set_id (node);
|
||||
}
|
||||
|
||||
set_id (node);
|
||||
|
||||
XMLNodeList nlist = node.children();
|
||||
XMLNodeIterator niter;
|
||||
|
||||
|
|
|
@ -38,9 +38,17 @@
|
|||
using namespace ARDOUR;
|
||||
using namespace PBD;
|
||||
|
||||
std::string
|
||||
Return::name_and_id_new_return (Session& s, uint32_t& bitslot)
|
||||
{
|
||||
bitslot = s.next_return_id();
|
||||
return string_compose (_("return %1"), bitslot + 1);
|
||||
}
|
||||
|
||||
|
||||
Return::Return (Session& s, bool internal)
|
||||
: IOProcessor (s, (internal ? false : true), false,
|
||||
string_compose (_("return %1"), (_bitslot = s.next_return_id()) + 1))
|
||||
name_and_id_new_return (s, _bitslot))
|
||||
, _metering (false)
|
||||
{
|
||||
/* never muted */
|
||||
|
@ -49,6 +57,17 @@ Return::Return (Session& s, bool internal)
|
|||
_meter.reset (new PeakMeter (_session));
|
||||
}
|
||||
|
||||
Return::Return (Session& s, const std::string& name, uint32_t bslot, bool internal)
|
||||
: IOProcessor (s, (internal ? false : true), false, name)
|
||||
, _metering (false)
|
||||
, _bitslot (bslot)
|
||||
{
|
||||
/* never muted */
|
||||
|
||||
_amp.reset (new Amp (_session));
|
||||
_meter.reset (new PeakMeter (_session));
|
||||
}
|
||||
|
||||
Return::~Return ()
|
||||
{
|
||||
_session.unmark_return_id (_bitslot);
|
||||
|
@ -92,12 +111,14 @@ Return::set_state (const XMLNode& node, int version)
|
|||
|
||||
IOProcessor::set_state (*insert_node, version);
|
||||
|
||||
if ((prop = node.property ("bitslot")) == 0) {
|
||||
_bitslot = _session.next_return_id();
|
||||
} else {
|
||||
_session.unmark_return_id (_bitslot);
|
||||
sscanf (prop->value().c_str(), "%" PRIu32, &_bitslot);
|
||||
_session.mark_return_id (_bitslot);
|
||||
if (!node.property ("ignore-bitslot")) {
|
||||
if ((prop = node.property ("bitslot")) == 0) {
|
||||
_bitslot = _session.next_return_id();
|
||||
} else {
|
||||
_session.unmark_return_id (_bitslot);
|
||||
sscanf (prop->value().c_str(), "%" PRIu32, &_bitslot);
|
||||
_session.mark_return_id (_bitslot);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -154,27 +175,15 @@ Return::configure_io (ChanCount in, ChanCount out)
|
|||
return true;
|
||||
}
|
||||
|
||||
/** Set up the XML description of a return so that its name is unique.
|
||||
/** Set up the XML description of a return so that we will not
|
||||
* reset its name or bitslot during ::set_state()
|
||||
* @param state XML return state.
|
||||
* @param session Session.
|
||||
*/
|
||||
void
|
||||
Return::make_unique (XMLNode &state, Session &session)
|
||||
Return::make_unique (XMLNode &state)
|
||||
{
|
||||
uint32_t const bitslot = session.next_return_id() + 1;
|
||||
|
||||
char buf[32];
|
||||
snprintf (buf, sizeof (buf), "%" PRIu32, bitslot);
|
||||
state.property("bitslot")->set_value (buf);
|
||||
|
||||
std::string const name = string_compose (_("return %1"), bitslot);
|
||||
|
||||
state.property("name")->set_value (name);
|
||||
|
||||
XMLNode* io = state.child ("IO");
|
||||
if (io) {
|
||||
io->property("name")->set_value (name);
|
||||
}
|
||||
state.add_property ("ignore-bitslot", "1");
|
||||
state.add_property ("ignore-name", "1");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -85,6 +85,26 @@ Send::Send (Session& s, boost::shared_ptr<Pannable> p, boost::shared_ptr<MuteMas
|
|||
add_control (_amp->gain_control ());
|
||||
}
|
||||
|
||||
Send::Send (Session& s, const std::string& name, uint32_t bslot, boost::shared_ptr<Pannable> p, boost::shared_ptr<MuteMaster> mm, Role r)
|
||||
: Delivery (s, p, mm, name, r)
|
||||
, _metering (false)
|
||||
, _bitslot (bslot)
|
||||
{
|
||||
if (_role == Listen) {
|
||||
/* we don't need to do this but it keeps things looking clean
|
||||
in a debugger. _bitslot is not used by listen sends.
|
||||
*/
|
||||
_bitslot = 0;
|
||||
}
|
||||
|
||||
boost_debug_shared_ptr_mark_interesting (this, "send");
|
||||
|
||||
_amp.reset (new Amp (_session));
|
||||
_meter.reset (new PeakMeter (_session));
|
||||
|
||||
add_control (_amp->gain_control ());
|
||||
}
|
||||
|
||||
Send::~Send ()
|
||||
{
|
||||
_session.unmark_send_id (_bitslot);
|
||||
|
@ -191,34 +211,37 @@ Send::set_state (const XMLNode& node, int version)
|
|||
|
||||
Delivery::set_state (node, version);
|
||||
|
||||
/* don't try to reset bitslot if there is a node for it already: this can cause
|
||||
issues with the session's accounting of send ID's
|
||||
*/
|
||||
if (node.property ("ignore-bitslot") == 0) {
|
||||
|
||||
if ((prop = node.property ("bitslot")) == 0) {
|
||||
if (_role == Delivery::Aux) {
|
||||
_bitslot = _session.next_aux_send_id ();
|
||||
} else if (_role == Delivery::Send) {
|
||||
_bitslot = _session.next_send_id ();
|
||||
/* don't try to reset bitslot if there is a node for it already: this can cause
|
||||
issues with the session's accounting of send ID's
|
||||
*/
|
||||
|
||||
if ((prop = node.property ("bitslot")) == 0) {
|
||||
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 but make it zero anyway
|
||||
_bitslot = 0;
|
||||
}
|
||||
} else {
|
||||
// bitslot doesn't matter but make it zero anyway
|
||||
_bitslot = 0;
|
||||
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 but make it zero anyway
|
||||
_bitslot = 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
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 but make it zero anyway
|
||||
_bitslot = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
XMLNodeList nlist = node.children();
|
||||
for (XMLNodeIterator i = nlist.begin(); i != nlist.end(); ++i) {
|
||||
if ((*i)->name() == X_("Processor")) {
|
||||
|
@ -292,28 +315,16 @@ Send::configure_io (ChanCount in, ChanCount out)
|
|||
return true;
|
||||
}
|
||||
|
||||
/** Set up the XML description of a send so that its name is unique.
|
||||
/** Set up the XML description of a send so that we will not
|
||||
* reset its name or bitslot during ::set_state()
|
||||
* @param state XML send state.
|
||||
* @param session Session.
|
||||
*/
|
||||
void
|
||||
Send::make_unique (XMLNode &state, Session &session)
|
||||
Send::make_unique (XMLNode &state)
|
||||
{
|
||||
uint32_t const bitslot = session.next_send_id() + 1;
|
||||
|
||||
char buf[32];
|
||||
snprintf (buf, sizeof (buf), "%" PRIu32, bitslot);
|
||||
state.property("bitslot")->set_value (buf);
|
||||
|
||||
string const name = string_compose (_("send %1"), bitslot);
|
||||
|
||||
state.property("name")->set_value (name);
|
||||
|
||||
XMLNode* io = state.child ("IO");
|
||||
|
||||
if (io) {
|
||||
io->property("name")->set_value (name);
|
||||
}
|
||||
state.add_property ("ignore-bitslot", "1");
|
||||
state.add_property ("ignore-name", "1");
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
Loading…
Reference in New Issue
Block a user