Cache the latency of the metronome's port
This commit is contained in:
parent
650b4a6900
commit
bebca37447
@ -2023,6 +2023,8 @@ private:
|
||||
samplecnt_t click_length;
|
||||
samplecnt_t click_emphasis_length;
|
||||
mutable Glib::Threads::RWLock click_lock;
|
||||
samplecnt_t _click_io_latency;
|
||||
PBD::ScopedConnection _click_io_connection;
|
||||
|
||||
static const Sample default_click[];
|
||||
static const samplecnt_t default_click_length;
|
||||
@ -2038,6 +2040,7 @@ private:
|
||||
void click (samplepos_t start, samplecnt_t nframes);
|
||||
void run_click (samplepos_t start, samplecnt_t nframes);
|
||||
void add_click (samplepos_t pos, bool emphasis);
|
||||
void click_io_resync_latency (bool);
|
||||
|
||||
/* range playback */
|
||||
|
||||
|
@ -599,6 +599,7 @@ Session::destroy ()
|
||||
|
||||
/* remove I/O objects that we (the session) own */
|
||||
_click_io.reset ();
|
||||
_click_io_connection.disconnect ();
|
||||
|
||||
{
|
||||
Glib::Threads::Mutex::Lock lm (controllables_lock);
|
||||
@ -828,6 +829,8 @@ Session::setup_click ()
|
||||
} else {
|
||||
setup_click_state (0);
|
||||
}
|
||||
click_io_resync_latency (true);
|
||||
LatencyUpdated.connect_same_thread (_click_io_connection, boost::bind (&Session::click_io_resync_latency, this, _1));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -76,7 +76,7 @@ Session::click (samplepos_t cycle_start, samplecnt_t nframes)
|
||||
* we need to prepare frames that the user will hear
|
||||
* in "output latency's" worth of time.
|
||||
*/
|
||||
samplecnt_t offset = _click_io->connected_latency (true);
|
||||
samplecnt_t offset = _click_io_latency;
|
||||
|
||||
Glib::Threads::RWLock::WriterLock clickm (click_lock, Glib::Threads::TRY_LOCK);
|
||||
|
||||
@ -159,7 +159,7 @@ Session::run_click (samplepos_t start, samplepos_t nframes)
|
||||
Glib::Threads::RWLock::ReaderLock clickm (click_lock, Glib::Threads::TRY_LOCK);
|
||||
|
||||
/* align to output */
|
||||
start += _click_io->connected_latency (true);
|
||||
start += _click_io_latency;
|
||||
|
||||
if (!clickm.locked() || click_data == 0) {
|
||||
_click_io->silence (nframes);
|
||||
@ -349,3 +349,13 @@ Session::clear_clicks ()
|
||||
clicks.clear ();
|
||||
_clicks_cleared = _transport_sample;
|
||||
}
|
||||
|
||||
void
|
||||
Session::click_io_resync_latency (bool playback)
|
||||
{
|
||||
if (deletion_in_progress() || !playback) {
|
||||
return;
|
||||
}
|
||||
|
||||
_click_io_latency = _click_io->connected_latency (true);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user