queue_event (ev);
}
-void
-Session::unset_preroll_record_punch ()
-{
- if (_preroll_record_punch_pos >= 0) {
- remove_event (_preroll_record_punch_pos, SessionEvent::RecordStart);
- }
- _preroll_record_punch_pos = -1;
-}
-
void
Session::unset_preroll_record_trim ()
{
_preroll_record_trim_len = 0;
}
-void
-Session::request_preroll_record_punch (samplepos_t rec_in, samplecnt_t preroll)
-{
- if (actively_recording ()) {
- return;
- }
- unset_preroll_record_punch ();
- unset_preroll_record_trim ();
- samplepos_t start = std::max ((samplepos_t)0, rec_in - preroll);
-
- _preroll_record_punch_pos = rec_in;
- if (_preroll_record_punch_pos >= 0) {
- replace_event (SessionEvent::RecordStart, _preroll_record_punch_pos);
- config.set_punch_in (false);
- config.set_punch_out (false);
- }
- maybe_enable_record ();
- request_locate (start, true);
- set_requested_return_sample (rec_in);
-}
-
void
Session::request_preroll_record_trim (samplepos_t rec_in, samplecnt_t preroll)
{
if (actively_recording ()) {
return;
}
- unset_preroll_record_punch ();
unset_preroll_record_trim ();
config.set_punch_in (false);
}
}
+samplecnt_t
+Session::worst_latency_preroll () const
+{
+ return _worst_output_latency + _worst_input_latency;
+}
+
int
Session::micro_locate (samplecnt_t distance)
{
// thread(s?) can restart.
g_atomic_int_inc (&_seek_counter);
_last_roll_or_reversal_location = target_sample;
- timecode_time(_transport_sample, transmitting_timecode_time);
+ _remaining_latency_preroll = worst_latency_preroll ();
+ timecode_time(_transport_sample, transmitting_timecode_time); // XXX here?
/* do "stopped" stuff if:
*
* we are rolling AND
- * no autoplay in effect AND
- * we're not going to keep rolling after the locate AND
- * !(playing a loop with JACK sync)
- *
+ * no autoplay in effect AND
+ * we're not going to keep rolling after the locate AND
+ * !(playing a loop with JACK sync)
+ *
*/
bool transport_was_stopped = !transport_rolling();
/* not zero, not 1.0 ... varispeed */
+ // TODO handled transport start.. _remaining_latency_preroll
+ // and reversal of playback direction.
+
if ((synced_to_engine()) && speed != 0.0 && speed != 1.0) {
warning << string_compose (
_("Global varispeed cannot be supported while %1 is connected to JACK transport control"),
boost::shared_ptr<RouteList> rl = routes.reader();
samplepos_t stop_target = audible_sample();
- for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
- boost::shared_ptr<Track> tr = boost::dynamic_pointer_cast<Track> (*i);
- if (tr) {
- tr->prepare_to_stop (_transport_sample, stop_target);
- }
- }
-
SubState new_bits;
if (actively_recording() && /* we are recording */
_last_roll_location = _transport_sample;
_last_roll_or_reversal_location = _transport_sample;
+ _remaining_latency_preroll = worst_latency_preroll ();
have_looped = false;
switch (record_status()) {
case Enabled:
- if (!config.get_punch_in() && !preroll_record_punch_enabled()) {
+ if (!config.get_punch_in()) {
+ /* This is only for UIs (keep blinking rec-en before
+ * punch-in, don't show rec-region etc). The UI still
+ * depends on SessionEvent::PunchIn and ensuing signals.
+ *
+ * The disk-writers handle punch in/out internally
+ * in their local delay-compensated timeframe.
+ */
enable_record ();
}
break;
_count_in_samples *= 1. + bar_fract;
}
+ if (_count_in_samples > _remaining_latency_preroll) {
+ _remaining_latency_preroll = _count_in_samples;
+ }
+
int clickbeat = 0;
samplepos_t cf = _transport_sample - _count_in_samples;
- while (cf < _transport_sample) {
- add_click (cf - _worst_track_latency, clickbeat == 0);
+ samplecnt_t offset = _click_io->connected_latency (true);
+ while (cf < _transport_sample + offset) {
+ add_click (cf, clickbeat == 0);
cf += dt;
clickbeat = fmod (clickbeat + 1, num);
}
+
+ if (_count_in_samples < _remaining_latency_preroll) {
+ _count_in_samples = _remaining_latency_preroll;
+ }
}
}