various: greatly simplified job times
Hopefully this doesn't break everything
This commit is contained in:
@@ -56,7 +56,7 @@ void AudioPlaybackCache::SetParameters(const AudioParams ¶ms)
|
||||
emit ParametersChanged();
|
||||
}
|
||||
|
||||
void AudioPlaybackCache::WritePCM(const TimeRange &range, SampleBufferPtr samples, const AudioVisualWaveform *waveform, const qint64 &job_time)
|
||||
void AudioPlaybackCache::WritePCM(const TimeRange &range, SampleBufferPtr samples, const AudioVisualWaveform *waveform, const JobTime &job_time)
|
||||
{
|
||||
QList<TimeRange> valid_ranges = GetValidRanges(range, job_time);
|
||||
if (valid_ranges.isEmpty()) {
|
||||
@@ -154,7 +154,7 @@ void AudioPlaybackCache::WritePCM(const TimeRange &range, SampleBufferPtr sample
|
||||
}
|
||||
}
|
||||
|
||||
void AudioPlaybackCache::WriteSilence(const TimeRange &range, qint64 job_time)
|
||||
void AudioPlaybackCache::WriteSilence(const TimeRange &range, JobTime job_time)
|
||||
{
|
||||
// WritePCM will automatically fill non-existent bytes with silence, so we just have to send
|
||||
// it an empty sample buffer
|
||||
@@ -391,7 +391,7 @@ void AudioPlaybackCache::UpdateOffsetsFrom(int index)
|
||||
}
|
||||
}
|
||||
|
||||
QList<TimeRange> AudioPlaybackCache::GetValidRanges(const TimeRange& range, const qint64& job_time)
|
||||
QList<TimeRange> AudioPlaybackCache::GetValidRanges(const TimeRange& range, const JobTime& job_time)
|
||||
{
|
||||
QList<TimeRange> valid_ranges;
|
||||
|
||||
|
||||
@@ -66,11 +66,11 @@ public:
|
||||
|
||||
void SetParameters(const AudioParams& params);
|
||||
|
||||
void WritePCM(const TimeRange &range, SampleBufferPtr samples, const AudioVisualWaveform *waveform, const qint64& job_time);
|
||||
void WritePCM(const TimeRange &range, SampleBufferPtr samples, const AudioVisualWaveform *waveform, const JobTime& job_time);
|
||||
|
||||
void WriteSilence(const TimeRange &range, qint64 job_time);
|
||||
void WriteSilence(const TimeRange &range, JobTime job_time);
|
||||
|
||||
QList<TimeRange> GetValidRanges(const TimeRange &range, const qint64 &job_time);
|
||||
QList<TimeRange> GetValidRanges(const TimeRange &range, const JobTime &job_time);
|
||||
|
||||
class Segment
|
||||
{
|
||||
|
||||
@@ -65,7 +65,7 @@ QByteArray FrameHashCache::GetHash(const rational &time)
|
||||
return GetHash(ToTimestamp(time));
|
||||
}
|
||||
|
||||
void FrameHashCache::SetHash(const rational &time, const QByteArray &hash, const qint64& job_time, bool frame_exists)
|
||||
void FrameHashCache::SetHash(const rational &time, const QByteArray &hash, const JobTime& job_time, bool frame_exists)
|
||||
{
|
||||
for (int i=jobs_.size()-1; i>=0; i--) {
|
||||
const JobIdentifier& job = jobs_.at(i);
|
||||
@@ -328,7 +328,7 @@ void FrameHashCache::HashDeleted(const QString& s, const QByteArray &hash)
|
||||
foreach (const TimeRange& range, ranges_to_invalidate) {
|
||||
// We set job time to 0 because the nodes haven't changed and any render job should be up
|
||||
// to date
|
||||
Invalidate(range, 0);
|
||||
Invalidate(range);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ public:
|
||||
static FramePtr LoadCacheFrame(const QString& fn);
|
||||
|
||||
public slots:
|
||||
void SetHash(const olive::rational &time, const QByteArray& hash, const qint64 &job_time, bool frame_exists);
|
||||
void SetHash(const olive::rational &time, const QByteArray& hash, const olive::JobTime &job_time, bool frame_exists);
|
||||
|
||||
protected:
|
||||
virtual void LengthChangedEvent(const rational& old, const rational& newlen) override;
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
namespace olive {
|
||||
|
||||
void PlaybackCache::Invalidate(const TimeRange &r, qint64 job_time)
|
||||
void PlaybackCache::Invalidate(const TimeRange &r)
|
||||
{
|
||||
if (r.in() == r.out()) {
|
||||
qWarning() << "Tried to invalidate zero-length range";
|
||||
@@ -37,7 +37,7 @@ void PlaybackCache::Invalidate(const TimeRange &r, qint64 job_time)
|
||||
invalidated_.insert(r);
|
||||
|
||||
RemoveRangeFromJobs(r);
|
||||
jobs_.append({r, job_time});
|
||||
jobs_.append({r, JobTime()});
|
||||
|
||||
InvalidateEvent(r);
|
||||
|
||||
@@ -50,7 +50,7 @@ void PlaybackCache::InvalidateAll()
|
||||
return;
|
||||
}
|
||||
|
||||
Invalidate(TimeRange(0, length_), 0);
|
||||
Invalidate(TimeRange(0, length_));
|
||||
}
|
||||
|
||||
void PlaybackCache::SetLength(const rational &r)
|
||||
@@ -70,7 +70,7 @@ void PlaybackCache::SetLength(const rational &r)
|
||||
} else if (r > length_) {
|
||||
// If new length is greater, simply extend the invalidated range for now
|
||||
invalidated_.insert(range_diff);
|
||||
jobs_.append({range_diff, 0});
|
||||
jobs_.append({range_diff, JobTime()});
|
||||
} else {
|
||||
// If new length is smaller, removed hashes
|
||||
invalidated_.remove(range_diff);
|
||||
@@ -105,8 +105,6 @@ void PlaybackCache::Shift(rational from, rational to)
|
||||
}
|
||||
}
|
||||
|
||||
qDebug() << "FIXME: 0 job time may cause cache desyncs";
|
||||
|
||||
// An region between `from` and `to` will be inserted or spliced out
|
||||
TimeRangeList ranges_to_shift = invalidated_.Intersects(TimeRange(from, RATIONAL_MAX));
|
||||
|
||||
@@ -119,7 +117,7 @@ void PlaybackCache::Shift(rational from, rational to)
|
||||
// (`diff` is POSITIVE when moving forward -> and NEGATIVE when moving backward <-)
|
||||
rational diff = to - from;
|
||||
foreach (const TimeRange& r, ranges_to_shift) {
|
||||
Invalidate(r + diff, 0);
|
||||
Invalidate(r + diff);
|
||||
}
|
||||
|
||||
ShiftEvent(from, to);
|
||||
@@ -128,7 +126,7 @@ void PlaybackCache::Shift(rational from, rational to)
|
||||
|
||||
if (diff > 0) {
|
||||
// If shifting forward, add this section to the invalidated region
|
||||
Invalidate(TimeRange(from, to), 0);
|
||||
Invalidate(TimeRange(from, to));
|
||||
}
|
||||
|
||||
// Emit signals
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <QMutex>
|
||||
#include <QObject>
|
||||
|
||||
#include "common/jobtime.h"
|
||||
#include "common/timerange.h"
|
||||
|
||||
namespace olive {
|
||||
@@ -63,7 +64,7 @@ public:
|
||||
QString GetCacheDirectory() const;
|
||||
|
||||
public slots:
|
||||
void Invalidate(const TimeRange& r, qint64 job_time);
|
||||
void Invalidate(const TimeRange& r);
|
||||
|
||||
void InvalidateAll();
|
||||
|
||||
@@ -93,7 +94,7 @@ protected:
|
||||
|
||||
struct JobIdentifier {
|
||||
TimeRange range;
|
||||
qint64 job_time;
|
||||
JobTime job_time;
|
||||
};
|
||||
|
||||
QList<JobIdentifier> jobs_;
|
||||
|
||||
@@ -15,9 +15,7 @@ PreviewAutoCacher::PreviewAutoCacher() :
|
||||
has_changed_(false),
|
||||
use_custom_range_(false),
|
||||
single_frame_render_(nullptr),
|
||||
last_update_time_(0),
|
||||
ignore_next_mouse_button_(false),
|
||||
last_conform_task_(0)
|
||||
ignore_next_mouse_button_(false)
|
||||
{
|
||||
paused_ = !Config::Current()[QStringLiteral("AutoCacheEnabled")].toBool(),
|
||||
|
||||
@@ -63,7 +61,7 @@ void PreviewAutoCacher::SetPaused(bool paused)
|
||||
paused_ = paused;
|
||||
}
|
||||
|
||||
void GenerateHashesInternal(ViewerOutput *viewer, FrameHashCache* cache, const QVector<rational> ×, qint64 job_time)
|
||||
void GenerateHashesInternal(ViewerOutput *viewer, FrameHashCache* cache, const QVector<rational> ×, JobTime job_time)
|
||||
{
|
||||
std::vector<QByteArray> existing_hashes;
|
||||
|
||||
@@ -86,12 +84,12 @@ void GenerateHashesInternal(ViewerOutput *viewer, FrameHashCache* cache, const Q
|
||||
QMetaObject::invokeMethod(cache, "SetHash", Qt::QueuedConnection,
|
||||
OLIVE_NS_ARG(rational, time),
|
||||
Q_ARG(QByteArray, hash),
|
||||
Q_ARG(qint64, job_time),
|
||||
OLIVE_NS_ARG(JobTime, job_time),
|
||||
Q_ARG(bool, hash_exists));
|
||||
}
|
||||
}
|
||||
|
||||
void PreviewAutoCacher::GenerateHashes(ViewerOutput *viewer, FrameHashCache* cache, TimeRangeListFrameIterator iterator, qint64 job_time)
|
||||
void PreviewAutoCacher::GenerateHashes(ViewerOutput *viewer, FrameHashCache* cache, TimeRangeListFrameIterator iterator, JobTime job_time)
|
||||
{
|
||||
QVector<rational> times = iterator.ToVector();
|
||||
|
||||
@@ -185,7 +183,7 @@ void PreviewAutoCacher::AudioRendered()
|
||||
if (watcher->GetTicket()->property("incomplete").toBool()) {
|
||||
if (last_conform_task_ > watcher->GetTicket()->GetJobTime()) {
|
||||
// Requeue now
|
||||
viewer_node_->audio_playback_cache()->Invalidate(range, QDateTime::currentMSecsSinceEpoch());
|
||||
viewer_node_->audio_playback_cache()->Invalidate(range);
|
||||
pcm_is_usable = false;
|
||||
} else {
|
||||
// Wait for conform
|
||||
@@ -398,7 +396,7 @@ void PreviewAutoCacher::InsertIntoCopyMap(Node *node, Node *copy)
|
||||
|
||||
void PreviewAutoCacher::UpdateLastSyncedValue()
|
||||
{
|
||||
last_update_time_ = QDateTime::currentMSecsSinceEpoch();
|
||||
last_update_time_.Acquire();
|
||||
}
|
||||
|
||||
void PreviewAutoCacher::CancelQueuedSingleFrameRender()
|
||||
@@ -613,11 +611,11 @@ void PreviewAutoCacher::RequeueFrames()
|
||||
|
||||
void PreviewAutoCacher::ConformFinished()
|
||||
{
|
||||
last_conform_task_ = QDateTime::currentMSecsSinceEpoch();
|
||||
last_conform_task_.Acquire();
|
||||
|
||||
if (viewer_node_) {
|
||||
foreach (const TimeRange &range, audio_needing_conform_) {
|
||||
viewer_node_->audio_playback_cache()->Invalidate(range, QDateTime::currentMSecsSinceEpoch());
|
||||
viewer_node_->audio_playback_cache()->Invalidate(range);
|
||||
}
|
||||
audio_needing_conform_.clear();
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ public:
|
||||
void ClearVideoDownloadQueue(bool wait = false);
|
||||
|
||||
private:
|
||||
static void GenerateHashes(ViewerOutput *viewer, FrameHashCache *cache, TimeRangeListFrameIterator times, qint64 job_time);
|
||||
static void GenerateHashes(ViewerOutput *viewer, FrameHashCache *cache, TimeRangeListFrameIterator times, JobTime job_time);
|
||||
|
||||
void TryRender();
|
||||
|
||||
@@ -161,7 +161,7 @@ private:
|
||||
QMap<RenderTicketWatcher*, QByteArray> video_download_tasks_;
|
||||
QMap<RenderTicketWatcher*, QVector<RenderTicketPtr> > video_immediate_passthroughs_;
|
||||
|
||||
qint64 last_update_time_;
|
||||
JobTime last_update_time_;
|
||||
|
||||
bool ignore_next_mouse_button_;
|
||||
|
||||
@@ -169,7 +169,7 @@ private:
|
||||
|
||||
TimeRangeList audio_needing_conform_;
|
||||
|
||||
qint64 last_conform_task_;
|
||||
JobTime last_conform_task_;
|
||||
|
||||
private slots:
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user