backport click latency correction change from a3

git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@11227 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2012-01-11 15:07:12 +00:00
parent 33e8abe6b3
commit bfd126e73b
3 changed files with 16 additions and 4 deletions

View file

@ -1729,6 +1729,7 @@ class Session : public PBD::StatefulDestructible
nframes_t click_length;
nframes_t click_emphasis_length;
mutable Glib::RWLock click_lock;
nframes_t _clicks_cleared;
static const Sample default_click[];
static const nframes_t default_click_length;

View file

@ -42,19 +42,28 @@ Session::click (nframes_t start, nframes_t nframes)
nframes_t end;
Sample *buf;
vector<Sample*> bufs;
nframes_t click_distance;
if (_click_io == 0) {
return;
}
Glib::RWLock::WriterLock clickm (click_lock, Glib::TRY_LOCK);
if (!clickm.locked() || _transport_speed != 1.0 || !_clicking || click_data == 0) {
click_distance = start - _clicks_cleared;
if (!clickm.locked() || _transport_speed != 1.0 || !_clicking || click_data == 0 || ((click_distance + nframes) < _worst_track_latency)) {
_click_io->silence (nframes);
return;
}
end = start + nframes;
if (start < _worst_track_latency) {
end = start + (_worst_track_latency - start);
start = 0;
} else {
start -= _worst_track_latency;
end = start + nframes;
}
buf = _passthru_buffers[0];
points = _tempo_map->get_points (start, end);
@ -221,4 +230,5 @@ Session::clear_clicks ()
}
clicks.clear ();
_clicks_cleared = _transport_frame;
}

View file

@ -203,6 +203,7 @@ Session::first_stage_init (string fullpath, string snapshot_name)
first_file_data_format_reset = true;
first_file_header_format_reset = true;
butler_thread = (pthread_t) 0;
_clicks_cleared = 0;
AudioDiskstream::allocate_working_buffers();