add new ::update_interval() method for transport masters, and use in shared ::speed_and_position() implementation
This commit is contained in:
parent
1dc35d157e
commit
22061310c0
|
@ -244,6 +244,14 @@ class LIBARDOUR_API TransportMaster : public PBD::Stateful {
|
|||
*/
|
||||
virtual samplecnt_t resolution() const = 0;
|
||||
|
||||
/**
|
||||
* @return - the expected update interval for the data source used by
|
||||
* this transport master. Even if the data is effectively continuous,
|
||||
* this number indicates how long it is between changes to the known
|
||||
* position of the master.
|
||||
*/
|
||||
virtual samplecnt_t update_interval() const = 0;
|
||||
|
||||
/**
|
||||
* @return - when returning true, ARDOUR will wait for seekahead_distance() before transport
|
||||
* starts rolling
|
||||
|
@ -409,6 +417,7 @@ class LIBARDOUR_API MTC_TransportMaster : public TimecodeTransportMaster, public
|
|||
bool ok() const;
|
||||
void handle_locate (const MIDI::byte*);
|
||||
|
||||
samplecnt_t update_interval () const;
|
||||
samplecnt_t resolution () const;
|
||||
bool requires_seekahead () const { return false; }
|
||||
samplecnt_t seekahead_distance() const;
|
||||
|
@ -474,6 +483,7 @@ public:
|
|||
bool locked() const;
|
||||
bool ok() const;
|
||||
|
||||
samplecnt_t update_interval () const;
|
||||
samplecnt_t resolution () const;
|
||||
bool requires_seekahead () const { return false; }
|
||||
samplecnt_t seekahead_distance () const { return 0; }
|
||||
|
@ -538,6 +548,7 @@ class LIBARDOUR_API MIDIClock_TransportMaster : public TransportMaster, public T
|
|||
bool ok() const;
|
||||
bool starting() const;
|
||||
|
||||
samplecnt_t update_interval () const;
|
||||
samplecnt_t resolution () const;
|
||||
bool requires_seekahead () const { return false; }
|
||||
void init ();
|
||||
|
@ -597,6 +608,7 @@ class LIBARDOUR_API Engine_TransportMaster : public TransportMaster
|
|||
bool starting() const { return _starting; }
|
||||
bool locked() const;
|
||||
bool ok() const;
|
||||
samplecnt_t update_interval () const;
|
||||
samplecnt_t resolution () const { return 1; }
|
||||
bool requires_seekahead () const { return false; }
|
||||
bool sample_clock_synced() const { return true; }
|
||||
|
|
|
@ -345,7 +345,9 @@ DiskReader::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_samp
|
|||
}
|
||||
|
||||
if ((speed > 0) && (start_sample != playback_sample)) {
|
||||
cerr << owner()->name() << " playback not aligned, jump ahead " << (start_sample - playback_sample) << endl;
|
||||
stringstream str;
|
||||
str << owner()->name() << " playback @ " << start_sample << " not aligned with " << playback_sample << " jump ahead " << (start_sample - playback_sample) << endl;
|
||||
cerr << str.str();
|
||||
|
||||
if (can_internal_playback_seek (start_sample - playback_sample)) {
|
||||
internal_playback_seek (start_sample - playback_sample);
|
||||
|
|
|
@ -125,3 +125,10 @@ Engine_TransportMaster::allow_request (TransportRequestSource src, TransportRequ
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
samplecnt_t
|
||||
Engine_TransportMaster::update_interval () const
|
||||
{
|
||||
return AudioEngine::instance()->samples_per_cycle();
|
||||
}
|
||||
|
||||
|
|
|
@ -142,6 +142,16 @@ LTC_TransportMaster::parameter_changed (std::string const & p)
|
|||
}
|
||||
}
|
||||
|
||||
ARDOUR::samplecnt_t
|
||||
LTC_TransportMaster::update_interval() const
|
||||
{
|
||||
if (timecode.rate) {
|
||||
return AudioEngine::instance()->sample_rate() / timecode.rate;
|
||||
}
|
||||
|
||||
return AudioEngine::instance()->sample_rate(); /* useless but what other answer is there? */
|
||||
}
|
||||
|
||||
ARDOUR::samplecnt_t
|
||||
LTC_TransportMaster::resolution () const
|
||||
{
|
||||
|
@ -459,7 +469,7 @@ LTC_TransportMaster::process_ltc(samplepos_t const now)
|
|||
samplepos_t cur_timestamp = sample.off_end + 1;
|
||||
double ltc_speed = current.speed;
|
||||
|
||||
DEBUG_TRACE (DEBUG::LTC, string_compose ("LTC S: %1 LS: %2 N: %3 L: %4\n", ltc_sample, current.position, cur_timestamp, current.timestamp));
|
||||
DEBUG_TRACE (DEBUG::LTC, string_compose ("LTC S: %1 LS: %2 N: %3 L: %4 span %5..%6\n", ltc_sample, current.position, cur_timestamp, current.timestamp, sample.off_start, sample.off_end));
|
||||
|
||||
if (cur_timestamp <= current.timestamp || current.timestamp == 0) {
|
||||
DEBUG_TRACE (DEBUG::LTC, string_compose ("LTC speed: UNCHANGED: %1\n", current.speed));
|
||||
|
@ -477,7 +487,7 @@ LTC_TransportMaster::process_ltc(samplepos_t const now)
|
|||
|
||||
DEBUG_TRACE (DEBUG::LTC, string_compose ("LTC speed: %1\n", ltc_speed));
|
||||
}
|
||||
|
||||
DEBUG_TRACE (DEBUG::LTC, string_compose ("update current to %1 %2 %3\n", ltc_sample, cur_timestamp, ltc_speed));
|
||||
current.update (ltc_sample, cur_timestamp, ltc_speed);
|
||||
|
||||
} /* end foreach decoded LTC sample */
|
||||
|
|
|
@ -375,6 +375,16 @@ MIDIClock_TransportMaster::starting() const
|
|||
return false;
|
||||
}
|
||||
|
||||
ARDOUR::samplecnt_t
|
||||
MIDIClock_TransportMaster::update_interval() const
|
||||
{
|
||||
if (one_ppqn_in_samples) {
|
||||
return resolution ();
|
||||
}
|
||||
|
||||
return AudioEngine::instance()->sample_rate() / 120 / 4; /* pure guesswork */
|
||||
}
|
||||
|
||||
ARDOUR::samplecnt_t
|
||||
MIDIClock_TransportMaster::resolution() const
|
||||
{
|
||||
|
|
|
@ -164,6 +164,16 @@ MTC_TransportMaster::parameter_changed (std::string const & p)
|
|||
}
|
||||
}
|
||||
|
||||
ARDOUR::samplecnt_t
|
||||
MTC_TransportMaster::update_interval() const
|
||||
{
|
||||
if (timecode.rate) {
|
||||
return AudioEngine::instance()->sample_rate() / timecode.rate;
|
||||
}
|
||||
|
||||
return AudioEngine::instance()->sample_rate(); /* useless but what other answer is there? */
|
||||
}
|
||||
|
||||
ARDOUR::samplecnt_t
|
||||
MTC_TransportMaster::resolution () const
|
||||
{
|
||||
|
|
|
@ -99,7 +99,7 @@ TransportMaster::speed_and_position (double& speed, samplepos_t& pos, samplepos_
|
|||
return false;
|
||||
}
|
||||
|
||||
if (last.timestamp && now > last.timestamp && now - last.timestamp > labs (seekahead_distance())) {
|
||||
if (last.timestamp && now > last.timestamp && now - last.timestamp > (2.0 * update_interval())) {
|
||||
/* no timecode for two cycles - conclude that it's stopped */
|
||||
|
||||
if (!Config->get_transport_masters_just_roll_when_sync_lost()) {
|
||||
|
@ -109,7 +109,7 @@ TransportMaster::speed_and_position (double& speed, samplepos_t& pos, samplepos_
|
|||
when = last.timestamp;
|
||||
_current_delta = 0;
|
||||
// queue_reset (false);
|
||||
DEBUG_TRACE (DEBUG::Slave, string_compose ("%1 not seen for 2 samples - reset pending, pos = %2\n", name(), pos));
|
||||
DEBUG_TRACE (DEBUG::Slave, string_compose ("%1 not seen since %2 vs %3 (%4) with seekahead = %5 reset pending, pos = %6\n", name(), last.timestamp, now, (now - last.timestamp), update_interval(), pos));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user