X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Ftrack.cc;h=ed52fd70a95cf1a608569d98caef96eb2d9a6343;hb=f2b007195cd75b195e38a4cd7757debac73e7792;hp=58d8c1b3065692320e1a4ad3230a8458afe8871b;hpb=81b9700c145abfb6f2e32d5a9bd13895e42b04e2;p=ardour.git diff --git a/libs/ardour/track.cc b/libs/ardour/track.cc index 58d8c1b306..ed52fd70a9 100644 --- a/libs/ardour/track.cc +++ b/libs/ardour/track.cc @@ -23,15 +23,14 @@ #include #include #include -#include +#include #include #include #include -#include +#include #include #include #include -#include #include "i18n.h" @@ -41,8 +40,7 @@ using namespace PBD; Track::Track (Session& sess, string name, Route::Flag flag, TrackMode mode, DataType default_type) : Route (sess, name, 1, -1, -1, -1, flag, default_type) - , _diskstream (0) - , _rec_enable_control (*this) + , _rec_enable_control (new RecEnableControllable(*this)) { _declickable = true; _freeze_record.state = NoFreeze; @@ -51,9 +49,8 @@ Track::Track (Session& sess, string name, Route::Flag flag, TrackMode mode, Data } Track::Track (Session& sess, const XMLNode& node, DataType default_type) - : Route (sess, "to be renamed", 0, 0, -1, -1, Route::Flag(0), default_type) - , _diskstream (0) - , _rec_enable_control (*this) + : Route (sess, node) + , _rec_enable_control (new RecEnableControllable(*this)) { _freeze_record.state = NoFreeze; _declickable = true; @@ -62,9 +59,6 @@ Track::Track (Session& sess, const XMLNode& node, DataType default_type) Track::~Track () { - if (_diskstream) { - _diskstream->unref(); - } } void @@ -88,31 +82,45 @@ Track::get_template () void Track::toggle_monitor_input () { - for (vector::iterator i = _inputs.begin(); i != _inputs.end(); ++i) { - (*i)->request_monitor_input(!(*i)->monitoring_input()); + for (PortSet::iterator i = _inputs.begin(); i != _inputs.end(); ++i) { + i->ensure_monitor_input(!i->monitoring_input()); } } -jack_nframes_t +ARDOUR::nframes_t Track::update_total_latency () { - _own_latency = 0; + nframes_t old = _own_latency; + + if (_user_latency) { + _own_latency = _user_latency; + } else { + _own_latency = 0; - for (RedirectList::iterator i = _redirects.begin(); i != _redirects.end(); ++i) { - if ((*i)->active ()) { - _own_latency += (*i)->latency (); + for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) { + if ((*i)->active ()) { + _own_latency += (*i)->signal_latency (); + } } } +#undef DEBUG_LATENCY +#ifdef DEBUG_LATENCY + cerr << _name << ": internal redirect (final) latency = " << _own_latency << endl; +#endif + set_port_latency (_own_latency); + if (old != _own_latency) { + signal_latency_changed (); /* EMIT SIGNAL */ + } + return _own_latency; } - Track::FreezeRecord::~FreezeRecord () { - for (vector::iterator i = insert_info.begin(); i != insert_info.end(); ++i) { + for (vector::iterator i = processor_info.begin(); i != processor_info.end(); ++i) { delete *i; } } @@ -124,7 +132,7 @@ Track::freeze_state() const } Track::RecEnableControllable::RecEnableControllable (Track& s) - : track (s) + : Controllable (X_("recenable")), track (s) { } @@ -152,8 +160,8 @@ bool Track::can_record() { bool will_record = true; - for (size_t i = 0; i < _inputs.size() && will_record; i++) { - if (!_inputs[i]->connected()) + for (PortSet::iterator i = _inputs.begin(); i != _inputs.end() && will_record; ++i) { + if (!i->connected()) will_record = false; } @@ -172,12 +180,6 @@ Track::set_record_enable (bool yn, void *src) return; } - // Do not set rec enabled if the track can't record. - if (yn && !can_record()) { - error << string_compose( _("Can not arm track '%1'. Check the input connections"), name() ) << endmsg; - return; - } - /* keep track of the meter point as it was before we rec-enabled */ if (!_diskstream->record_enabled()) { _saved_meter_point = _meter_point; @@ -191,45 +193,35 @@ Track::set_record_enable (bool yn, void *src) set_meter_point (_saved_meter_point, this); } - _rec_enable_control.Changed (); + _rec_enable_control->Changed (); } -void -Track::set_mode (TrackMode m) -{ - if (_diskstream) { - if (_mode != m) { - _mode = m; - _diskstream->set_destructive (m == Destructive); - ModeChanged(); - } - } -} -int -Track::set_name (string str, void *src) +bool +Track::set_name (const string& str) { - int ret; + bool ret; if (record_enabled() && _session.actively_recording()) { /* this messes things up if done while recording */ - return -1; + return false; } if (_diskstream->set_name (str)) { - return -1; + return false; } /* save state so that the statefile fully reflects any filename changes */ - if ((ret = IO::set_name (str, src)) == 0) { + if ((ret = IO::set_name (str)) == 0) { _session.save_state (""); } + return ret; } void -Track::set_latency_delay (jack_nframes_t longest_session_latency) +Track::set_latency_delay (nframes_t longest_session_latency) { Route::set_latency_delay (longest_session_latency); _diskstream->set_roll_delay (_roll_delay);