mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-06 14:54:56 +01:00
Refactor send naming (#7905)
This allows users to rename sends without enforcing a numeric bitslot number. However this prevents a user to to use "send" names that are potentially used for new sends or inserts.
This commit is contained in:
parent
711f20a469
commit
6e0062d549
10 changed files with 88 additions and 36 deletions
|
|
@ -49,7 +49,7 @@ public:
|
||||||
ARDOUR::DataType default_type = DataType::AUDIO, bool sendish=false);
|
ARDOUR::DataType default_type = DataType::AUDIO, bool sendish=false);
|
||||||
|
|
||||||
IOProcessor (Session&, boost::shared_ptr<IO> input, boost::shared_ptr<IO> output,
|
IOProcessor (Session&, boost::shared_ptr<IO> input, boost::shared_ptr<IO> output,
|
||||||
const std::string& proc_name, ARDOUR::DataType default_type = DataType::AUDIO);
|
const std::string& proc_name, bool sendish=false);
|
||||||
|
|
||||||
virtual ~IOProcessor ();
|
virtual ~IOProcessor ();
|
||||||
|
|
||||||
|
|
@ -81,10 +81,16 @@ public:
|
||||||
|
|
||||||
static void prepare_for_reset (XMLNode& state, const std::string& name);
|
static void prepare_for_reset (XMLNode& state, const std::string& name);
|
||||||
|
|
||||||
|
uint32_t bit_slot() const { return _bitslot; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
boost::shared_ptr<IO> _input;
|
boost::shared_ptr<IO> _input;
|
||||||
boost::shared_ptr<IO> _output;
|
boost::shared_ptr<IO> _output;
|
||||||
|
|
||||||
|
/* used by PortInsert, Send & Return*/
|
||||||
|
std::string validate_name (std::string const& new_name, std::string const& canonical_name) const;
|
||||||
|
uint32_t _bitslot;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/* disallow copy construction */
|
/* disallow copy construction */
|
||||||
IOProcessor (const IOProcessor&);
|
IOProcessor (const IOProcessor&);
|
||||||
|
|
|
||||||
|
|
@ -71,8 +71,6 @@ public:
|
||||||
|
|
||||||
void set_pre_fader (bool);
|
void set_pre_fader (bool);
|
||||||
|
|
||||||
uint32_t bit_slot() const { return _bitslot; }
|
|
||||||
|
|
||||||
void start_latency_detection ();
|
void start_latency_detection ();
|
||||||
void stop_latency_detection ();
|
void stop_latency_detection ();
|
||||||
|
|
||||||
|
|
@ -90,7 +88,6 @@ private:
|
||||||
|
|
||||||
boost::shared_ptr<Delivery> _out;
|
boost::shared_ptr<Delivery> _out;
|
||||||
|
|
||||||
uint32_t _bitslot;
|
|
||||||
MTDM* _mtdm;
|
MTDM* _mtdm;
|
||||||
bool _latency_detect;
|
bool _latency_detect;
|
||||||
samplecnt_t _latency_flush_samples;
|
samplecnt_t _latency_flush_samples;
|
||||||
|
|
|
||||||
|
|
@ -41,8 +41,6 @@ public:
|
||||||
Return (Session&, bool internal = false);
|
Return (Session&, bool internal = false);
|
||||||
virtual ~Return ();
|
virtual ~Return ();
|
||||||
|
|
||||||
uint32_t bit_slot() const { return _bitslot; }
|
|
||||||
|
|
||||||
void run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_sample, double speed, pframes_t nframes, bool);
|
void run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_sample, double speed, pframes_t nframes, bool);
|
||||||
|
|
||||||
boost::shared_ptr<Amp> amp() const { return _amp; }
|
boost::shared_ptr<Amp> amp() const { return _amp; }
|
||||||
|
|
@ -74,8 +72,6 @@ private:
|
||||||
/* disallow copy construction */
|
/* disallow copy construction */
|
||||||
Return (const Return&);
|
Return (const Return&);
|
||||||
|
|
||||||
uint32_t _bitslot;
|
|
||||||
|
|
||||||
void collect_input (BufferSet& bufs, pframes_t nframes, ChanCount offset = ChanCount::ZERO);
|
void collect_input (BufferSet& bufs, pframes_t nframes, ChanCount offset = ChanCount::ZERO);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -68,8 +68,6 @@ public:
|
||||||
Send (Session&, boost::shared_ptr<Pannable> pannable, boost::shared_ptr<MuteMaster>, Delivery::Role r = Delivery::Send, bool ignore_bitslot = false);
|
Send (Session&, boost::shared_ptr<Pannable> pannable, boost::shared_ptr<MuteMaster>, Delivery::Role r = Delivery::Send, bool ignore_bitslot = false);
|
||||||
virtual ~Send ();
|
virtual ~Send ();
|
||||||
|
|
||||||
uint32_t bit_slot() const { return _bitslot; }
|
|
||||||
|
|
||||||
bool display_to_user() const;
|
bool display_to_user() const;
|
||||||
bool is_foldback () const { return _role == Foldback; }
|
bool is_foldback () const { return _role == Foldback; }
|
||||||
|
|
||||||
|
|
@ -128,7 +126,6 @@ private:
|
||||||
|
|
||||||
int set_state_2X (XMLNode const &, int);
|
int set_state_2X (XMLNode const &, int);
|
||||||
|
|
||||||
uint32_t _bitslot;
|
|
||||||
bool _remove_on_disconnect;
|
bool _remove_on_disconnect;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ bool Delivery::panners_legal = false;
|
||||||
|
|
||||||
Delivery::Delivery (Session& s, boost::shared_ptr<IO> io, boost::shared_ptr<Pannable> pannable,
|
Delivery::Delivery (Session& s, boost::shared_ptr<IO> io, boost::shared_ptr<Pannable> pannable,
|
||||||
boost::shared_ptr<MuteMaster> mm, const string& name, Role r)
|
boost::shared_ptr<MuteMaster> mm, const string& name, Role r)
|
||||||
: IOProcessor(s, boost::shared_ptr<IO>(), (role_requires_output_ports (r) ? io : boost::shared_ptr<IO>()), name)
|
: IOProcessor(s, boost::shared_ptr<IO>(), (role_requires_output_ports (r) ? io : boost::shared_ptr<IO>()), name, (r == Send || r == Aux || r == Foldback))
|
||||||
, _role (r)
|
, _role (r)
|
||||||
, _output_buffers (new BufferSet())
|
, _output_buffers (new BufferSet())
|
||||||
, _current_gain (GAIN_COEFF_ZERO)
|
, _current_gain (GAIN_COEFF_ZERO)
|
||||||
|
|
@ -81,7 +81,7 @@ Delivery::Delivery (Session& s, boost::shared_ptr<IO> io, boost::shared_ptr<Pann
|
||||||
/* deliver to a new IO object */
|
/* deliver to a new IO object */
|
||||||
|
|
||||||
Delivery::Delivery (Session& s, boost::shared_ptr<Pannable> pannable, boost::shared_ptr<MuteMaster> mm, const string& name, Role r)
|
Delivery::Delivery (Session& s, boost::shared_ptr<Pannable> pannable, boost::shared_ptr<MuteMaster> mm, const string& name, Role r)
|
||||||
: IOProcessor(s, false, (role_requires_output_ports (r) ? true : false), name, "", DataType::AUDIO, (r == Send))
|
: IOProcessor(s, false, (role_requires_output_ports (r) ? true : false), name, "", DataType::AUDIO, (r == Send || r == Aux || r == Foldback))
|
||||||
, _role (r)
|
, _role (r)
|
||||||
, _output_buffers (new BufferSet())
|
, _output_buffers (new BufferSet())
|
||||||
, _current_gain (GAIN_COEFF_ZERO)
|
, _current_gain (GAIN_COEFF_ZERO)
|
||||||
|
|
|
||||||
|
|
@ -398,7 +398,7 @@ bool
|
||||||
InternalSend::set_name (const string& str)
|
InternalSend::set_name (const string& str)
|
||||||
{
|
{
|
||||||
/* rules for external sends don't apply to us */
|
/* rules for external sends don't apply to us */
|
||||||
return IOProcessor::set_name (str);
|
return Delivery::set_name (str);
|
||||||
}
|
}
|
||||||
|
|
||||||
string
|
string
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@
|
||||||
#include "ardour/io_processor.h"
|
#include "ardour/io_processor.h"
|
||||||
#include "ardour/processor.h"
|
#include "ardour/processor.h"
|
||||||
#include "ardour/route.h"
|
#include "ardour/route.h"
|
||||||
|
#include "ardour/session.h"
|
||||||
#include "ardour/session_object.h"
|
#include "ardour/session_object.h"
|
||||||
#include "ardour/types.h"
|
#include "ardour/types.h"
|
||||||
|
|
||||||
|
|
@ -62,12 +63,15 @@ IOProcessor::IOProcessor (Session& s, bool with_input, bool with_output,
|
||||||
if (with_output) {
|
if (with_output) {
|
||||||
_output.reset (new IO(s, io_name.empty() ? proc_name : io_name, IO::Output, dtype, sendish));
|
_output.reset (new IO(s, io_name.empty() ? proc_name : io_name, IO::Output, dtype, sendish));
|
||||||
}
|
}
|
||||||
|
if (!sendish) {
|
||||||
|
_bitslot = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* create an IOProcessor that proxies to an existing IO object */
|
/* create an IOProcessor that proxies to an existing IO object */
|
||||||
|
|
||||||
IOProcessor::IOProcessor (Session& s, boost::shared_ptr<IO> in, boost::shared_ptr<IO> out,
|
IOProcessor::IOProcessor (Session& s, boost::shared_ptr<IO> in, boost::shared_ptr<IO> out,
|
||||||
const string& proc_name, DataType /*dtype*/)
|
const string& proc_name, bool sendish)
|
||||||
: Processor(s, proc_name)
|
: Processor(s, proc_name)
|
||||||
, _input (in)
|
, _input (in)
|
||||||
, _output (out)
|
, _output (out)
|
||||||
|
|
@ -83,6 +87,10 @@ IOProcessor::IOProcessor (Session& s, boost::shared_ptr<IO> in, boost::shared_pt
|
||||||
} else {
|
} else {
|
||||||
_own_output = true;
|
_own_output = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!sendish) {
|
||||||
|
_bitslot = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IOProcessor::~IOProcessor ()
|
IOProcessor::~IOProcessor ()
|
||||||
|
|
@ -244,6 +252,63 @@ IOProcessor::natural_input_streams () const
|
||||||
return _input ? _input->n_ports() : ChanCount::ZERO;
|
return _input ? _input->n_ports() : ChanCount::ZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string
|
||||||
|
IOProcessor::validate_name (std::string const& new_name, std::string const& canonical_name) const
|
||||||
|
{
|
||||||
|
/* For use by Send::set_name() and PortInsert::set_name()
|
||||||
|
*
|
||||||
|
* allow canonical name e.g.
|
||||||
|
* _("insert %1"), bitslot) // PortInsert::name_and_id_new_insert
|
||||||
|
* _("send %1"), bitslot) // Send::name_and_id_new_send
|
||||||
|
* do *not* allow to use use potential canonical names with different
|
||||||
|
* bitslot id.
|
||||||
|
*
|
||||||
|
* Next, ensure that port-name is unique. Since ::set_name() is used
|
||||||
|
* when converting old sessions, a unique name has to be generated
|
||||||
|
*/
|
||||||
|
|
||||||
|
bool ok = new_name == canonical_name;
|
||||||
|
|
||||||
|
if (!ok) {
|
||||||
|
string unique_base;
|
||||||
|
/* strip existing numeric part (bitslot) of the name */
|
||||||
|
string::size_type last_letter = new_name.find_last_not_of ("0123456789");
|
||||||
|
if (last_letter != string::npos) {
|
||||||
|
unique_base = new_name.substr (0, last_letter + 1);
|
||||||
|
}
|
||||||
|
ok = unique_base != _("send ") && unique_base != _("insert ") && unique_base != _("return ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ok || !_session.io_name_is_legal (new_name)) {
|
||||||
|
/* rip any existing numeric part of the name, and append the bitslot */
|
||||||
|
string unique_base;
|
||||||
|
string::size_type last_letter = new_name.find_last_not_of ("0123456789-");
|
||||||
|
if (last_letter != string::npos) {
|
||||||
|
unique_base = new_name.substr (0, last_letter + 1);
|
||||||
|
} else {
|
||||||
|
unique_base = new_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
int tries = 0;
|
||||||
|
std::string unique_name;
|
||||||
|
do {
|
||||||
|
unique_name = unique_base;
|
||||||
|
char buf[32];
|
||||||
|
if (tries > 0 || !ok) {
|
||||||
|
snprintf (buf, sizeof (buf), "%u-%u", _bitslot, tries + (ok ? 0 : 1));
|
||||||
|
} else {
|
||||||
|
snprintf (buf, sizeof (buf), "%u", _bitslot);
|
||||||
|
}
|
||||||
|
unique_name += buf;
|
||||||
|
if (25 == ++tries) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
} while (!_session.io_name_is_legal (unique_name));
|
||||||
|
return unique_name;
|
||||||
|
}
|
||||||
|
return new_name;
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
IOProcessor::set_name (const std::string& new_name)
|
IOProcessor::set_name (const std::string& new_name)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ string
|
||||||
PortInsert::name_and_id_new_insert (Session& s, uint32_t& bitslot)
|
PortInsert::name_and_id_new_insert (Session& s, uint32_t& bitslot)
|
||||||
{
|
{
|
||||||
bitslot = s.next_insert_id ();
|
bitslot = s.next_insert_id ();
|
||||||
return string_compose (_("insert %1"), bitslot+ 1);
|
return string_compose (_("insert %1"), bitslot);
|
||||||
}
|
}
|
||||||
|
|
||||||
PortInsert::PortInsert (Session& s, boost::shared_ptr<Pannable> pannable, boost::shared_ptr<MuteMaster> mm)
|
PortInsert::PortInsert (Session& s, boost::shared_ptr<Pannable> pannable, boost::shared_ptr<MuteMaster> mm)
|
||||||
|
|
@ -272,13 +272,15 @@ PortInsert::can_support_io_configuration (const ChanCount& in, ChanCount& out)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
PortInsert::set_name (const std::string& name)
|
PortInsert::set_name (const std::string& new_name)
|
||||||
{
|
{
|
||||||
bool ret = Processor::set_name (name);
|
string unique_name = validate_name (new_name, string_compose (_("insert %1"), _bitslot));
|
||||||
|
|
||||||
ret = (ret && _input->set_name (name) && _output->set_name (name));
|
if (unique_name.empty ()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return IOProcessor::set_name (unique_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ Return::name_and_id_new_return (Session& s, uint32_t& bitslot)
|
||||||
|
|
||||||
Return::Return (Session& s, bool internal)
|
Return::Return (Session& s, bool internal)
|
||||||
: IOProcessor (s, (internal ? false : true), false,
|
: IOProcessor (s, (internal ? false : true), false,
|
||||||
name_and_id_new_return (s, _bitslot))
|
name_and_id_new_return (s, _bitslot), "", DataType::AUDIO, true)
|
||||||
, _metering (false)
|
, _metering (false)
|
||||||
{
|
{
|
||||||
/* never muted */
|
/* never muted */
|
||||||
|
|
|
||||||
|
|
@ -485,22 +485,11 @@ Send::set_name (const string& new_name)
|
||||||
string unique_name;
|
string unique_name;
|
||||||
|
|
||||||
if (_role == Delivery::Send) {
|
if (_role == Delivery::Send) {
|
||||||
char buf[32];
|
unique_name = validate_name (new_name, string_compose (_("send %1"), _bitslot));
|
||||||
|
|
||||||
/* rip any existing numeric part of the name, and append the bitslot
|
if (unique_name.empty ()) {
|
||||||
*/
|
return false;
|
||||||
|
|
||||||
string::size_type last_letter = new_name.find_last_not_of ("0123456789");
|
|
||||||
|
|
||||||
if (last_letter != string::npos) {
|
|
||||||
unique_name = new_name.substr (0, last_letter + 1);
|
|
||||||
} else {
|
|
||||||
unique_name = new_name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf (buf, sizeof (buf), "%u", (_bitslot + 1));
|
|
||||||
unique_name += buf;
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
unique_name = new_name;
|
unique_name = new_name;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue