Send full MTC messages every 1/4 of a second when quarter-frame messages are suspended (due to out-of-range transport speed)

git-svn-id: svn://localhost/ardour2/branches/3.0@8429 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Carl Hetherington 2011-01-04 03:35:10 +00:00
parent 6933d6f945
commit 4273093d40
4 changed files with 28 additions and 10 deletions

View File

@ -960,6 +960,10 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
std::string _name;
bool _is_new;
bool _send_qf_mtc;
/** Number of process frames since the last MTC output (when sending MTC); used to
* know when to send full MTC messages every so often.
*/
pframes_t _pframes_since_last_mtc;
bool session_midi_feedback;
bool play_loop;
bool loop_changing;

View File

@ -400,6 +400,7 @@ Session::send_full_time_code (framepos_t const t)
return -1;
}
_pframes_since_last_mtc = 0;
return 0;
}

View File

@ -270,17 +270,29 @@ Session::process_with_events (pframes_t nframes)
bool const was_sending_qf_mtc = _send_qf_mtc;
double const tolerance = Config->get_mtc_qf_speed_tolerance() / 100.0;
_send_qf_mtc = (
Config->get_send_mtc () &&
_transport_speed >= (1 - tolerance) &&
_transport_speed <= (1 + tolerance)
);
if (_send_qf_mtc && !was_sending_qf_mtc) {
/* we will re-start quarter-frame MTC this cycle, so send a full update to set things up */
_send_timecode_update = true;
if (_transport_speed != 0) {
_send_qf_mtc = (
Config->get_send_mtc () &&
_transport_speed >= (1 - tolerance) &&
_transport_speed <= (1 + tolerance)
);
if (_send_qf_mtc && !was_sending_qf_mtc) {
/* we will re-start quarter-frame MTC this cycle, so send a full update to set things up */
_send_timecode_update = true;
}
if (Config->get_send_mtc() && !_send_qf_mtc && _pframes_since_last_mtc > (frame_rate () / 4)) {
/* we're sending MTC, but we're not sending QF MTC at the moment, and it's been
a quarter of a second since we sent anything at all, so send a full MTC update
this cycle.
*/
_send_timecode_update = true;
}
_pframes_since_last_mtc += nframes;
}
/* Events caused a transport change (or we re-started sending
* MTC), so send an MTC Full Frame (Timecode) message. This
* is sent whether rolling or not, to give slaves an idea of

View File

@ -207,6 +207,7 @@ Session::first_stage_init (string fullpath, string snapshot_name)
_was_seamless = Config->get_seamless_loop ();
_slave = 0;
_send_qf_mtc = false;
_pframes_since_last_mtc = 0;
g_atomic_int_set (&_playback_load, 100);
g_atomic_int_set (&_capture_load, 100);
_play_range = false;