13
0

Fix count-in/preroll recording offsets

Notably `Route::process_output_buffers` uses

```
  output_latency = speed * _output_latency;
```

here, speed already needs to be non-zero during count-in
and pre-roll.
This commit is contained in:
Robin Gareus 2024-09-30 23:36:06 +02:00
parent dab22a7c70
commit 1aad6805b3
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
3 changed files with 9 additions and 6 deletions

View File

@ -811,7 +811,7 @@ public:
double engine_speed() const { return _engine_speed; }
double actual_speed() const;
double transport_speed() const;
double transport_speed (bool incl_preroll = false) const;
/** @return true if the transport state (TFSM) is stopped */
bool transport_stopped() const;
/** @return true if the transport state (TFSM) is stopped or stopping */

View File

@ -410,7 +410,7 @@ Route::process_output_buffers (BufferSet& bufs,
_pannable->automation_run (start_sample, nframes);
}
const int speed = (is_auditioner() ? 1 : _session.transport_speed ());
const int speed = (is_auditioner() ? 1 : _session.transport_speed (true));
assert (speed == -1 || speed == 0 || speed == 1);
const samplecnt_t output_latency = speed * _output_latency;
@ -4050,7 +4050,7 @@ Route::latency_preroll (pframes_t nframes, samplepos_t& start_sample, samplepos_
return nframes;
}
if (!_disk_reader) {
if (_session.transport_speed() < 0) {
if (_session.transport_speed (true) < 0) {
start_sample += latency_preroll;
end_sample += latency_preroll;
} else {
@ -4060,12 +4060,12 @@ Route::latency_preroll (pframes_t nframes, samplepos_t& start_sample, samplepos_
return nframes;
}
if (latency_preroll > playback_latency ()) {
if (latency_preroll >= playback_latency ()) {
no_roll_unlocked (nframes, start_sample - latency_preroll, end_sample - latency_preroll, false);
return 0;
}
if (_session.transport_speed() < 0) {
if (_session.transport_speed (true) < 0) {
start_sample += latency_preroll;
end_sample += latency_preroll;
} else {

View File

@ -2142,11 +2142,14 @@ Session::transport_will_roll_forwards () const
}
double
Session::transport_speed() const
Session::transport_speed (bool incl_preroll) const
{
if (_transport_fsm->transport_speed() != _transport_fsm->transport_speed()) {
// cerr << "\n\n!!TS " << _transport_fsm->transport_speed() << " TFSM::speed " << _transport_fsm->transport_speed() << " via " << _transport_fsm->current_state() << endl;
}
if (incl_preroll) {
return _transport_fsm->transport_speed();
}
return _count_in_samples > 0 ? 0. : _transport_fsm->transport_speed();
}