waveform: shift track waveform alongside cache

This commit is contained in:
itsmattkc
2020-06-04 23:32:50 +10:00
parent 0e87762afa
commit 5eeef76b62
10 changed files with 109 additions and 37 deletions
+11 -2
View File
@@ -57,6 +57,10 @@ void PlaybackCache::SetLength(const rational &r)
void PlaybackCache::Shift(const rational &from, const rational &to)
{
if (from == to) {
return;
}
QMutexLocker locker(&lock_);
// An region between `from` and `to` will be inserted or spliced out
@@ -75,6 +79,8 @@ void PlaybackCache::Shift(const rational &from, const rational &to)
ShiftEvent(from, to);
length_ += diff;
if (diff > rational()) {
// If shifting forward, add this section to the invalidated region
TimeRange invalidate_range(from, to);
@@ -113,12 +119,15 @@ void PlaybackCache::NoLockSetLength(const rational &r)
return;
}
TimeRange range_diff(length_, r);
if (r > length_) {
// If new length is greater, simply extend the invalidated range for now
invalidated_.InsertTimeRange(TimeRange(length_, r));
invalidated_.InsertTimeRange(range_diff);
} else {
// If new length is smaller, removed hashes
invalidated_.RemoveTimeRange(TimeRange(r, length_));
invalidated_.RemoveTimeRange(range_diff);
RemoveRangeFromJobs(range_diff);
}
LengthChangedEvent(length_, r);