Add abstract API for latency compensated sends

This is in preparation for MixbusSends that are not derived from
Delivery : IOProcessor.
This commit is contained in:
Robin Gareus 2019-09-20 20:25:04 +02:00
parent 361727716f
commit e8822e76d6
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
4 changed files with 39 additions and 13 deletions

View File

@ -37,7 +37,32 @@ class Amp;
class GainControl;
class DelayLine;
class LIBARDOUR_API Send : public Delivery
/** Internal Abstraction for Sends (and MixbusSends) */
class LIBARDOUR_API LatentSend
{
public:
LatentSend ();
virtual ~LatentSend() {}
samplecnt_t get_delay_in () const { return _delay_in; }
samplecnt_t get_delay_out () const { return _delay_out; }
/* should only be called by Route::update_signal_latency */
virtual void set_delay_in (samplecnt_t) = 0;
/* should only be called by InternalReturn::set_playback_offset
* (via Route::update_signal_latency)
*/
virtual void set_delay_out (samplecnt_t, size_t bus = 0) = 0;
static PBD::Signal0<void> ChangedLatency;
protected:
samplecnt_t _delay_in;
samplecnt_t _delay_out;
};
class LIBARDOUR_API Send : public Delivery, public LatentSend
{
public:
Send (Session&, boost::shared_ptr<Pannable> pannable, boost::shared_ptr<MuteMaster>, Delivery::Role r = Delivery::Send, bool ignore_bitslot = false);
@ -69,14 +94,12 @@ public:
bool configure_io (ChanCount in, ChanCount out);
/* latency compensation */
void set_delay_in (samplecnt_t); // should only be called by Route::update_signal_latency
void set_delay_out (samplecnt_t); // should only be called by InternalReturn::set_playback_offset (via Route::update_signal_latency)
void set_delay_in (samplecnt_t);
void set_delay_out (samplecnt_t, size_t bus = 0);
samplecnt_t get_delay_in () const { return _delay_in; }
samplecnt_t get_delay_out () const { return _delay_out; }
samplecnt_t signal_latency () const;
static PBD::Signal0<void> ChangedLatency;
void activate ();
void deactivate ();
@ -106,8 +129,6 @@ private:
int set_state_2X (XMLNode const &, int);
uint32_t _bitslot;
samplecnt_t _delay_in;
samplecnt_t _delay_out;
bool _remove_on_disconnect;
};

View File

@ -4115,7 +4115,7 @@ Route::update_signal_latency (bool apply_to_delayline)
samplecnt_t l_in = 0;
samplecnt_t l_out = _output->effective_latency ();
for (ProcessorList::reverse_iterator i = _processors.rbegin(); i != _processors.rend(); ++i) {
if (boost::shared_ptr<Send> snd = boost::dynamic_pointer_cast<Send> (*i)) {
if (boost::shared_ptr<LatentSend> snd = boost::dynamic_pointer_cast<LatentSend> (*i)) {
snd->set_delay_in (l_out + _output->latency());
}
@ -4155,6 +4155,7 @@ Route::update_signal_latency (bool apply_to_delayline)
snd->output ()->set_private_port_latencies (capt_lat_in + l_in, false);
/* take send-target's playback latency into account */
snd->set_delay_out (snd->output ()->connected_latency (true));
/* InternalReturn::set_playback_offset() below, also calls set_delay_out() */
}
}

View File

@ -49,7 +49,13 @@ using namespace ARDOUR;
using namespace PBD;
using namespace std;
PBD::Signal0<void> Send::ChangedLatency;
PBD::Signal0<void> LatentSend::ChangedLatency;
LatentSend::LatentSend ()
: _delay_in (0)
, _delay_out (0)
{
}
string
Send::name_and_id_new_send (Session& s, Role r, uint32_t& bitslot, bool ignore_bitslot)
@ -83,8 +89,6 @@ Send::name_and_id_new_send (Session& s, Role r, uint32_t& bitslot, bool ignore_b
Send::Send (Session& s, boost::shared_ptr<Pannable> p, boost::shared_ptr<MuteMaster> mm, Role r, bool ignore_bitslot)
: Delivery (s, p, mm, name_and_id_new_send (s, r, _bitslot, ignore_bitslot), r)
, _metering (false)
, _delay_in (0)
, _delay_out (0)
, _remove_on_disconnect (false)
{
if (_role == Listen) {
@ -198,7 +202,7 @@ Send::set_delay_in (samplecnt_t delay)
}
void
Send::set_delay_out (samplecnt_t delay)
Send::set_delay_out (samplecnt_t delay, size_t /*bus*/)
{
if (_delay_out == delay) {
return;

View File

@ -460,7 +460,7 @@ Session::Session (AudioEngine &eng,
StartTimeChanged.connect_same_thread (*this, boost::bind (&Session::start_time_changed, this, _1));
EndTimeChanged.connect_same_thread (*this, boost::bind (&Session::end_time_changed, this, _1));
Send::ChangedLatency.connect_same_thread (*this, boost::bind (&Session::send_latency_compensation_change, this));
LatentSend::ChangedLatency.connect_same_thread (*this, boost::bind (&Session::send_latency_compensation_change, this));
emit_thread_start ();
auto_connect_thread_start ();