cache: streamlined audio into cache task

Since we always cache audio, it makes sense to lump it into the same auto-cache
task we use for everything else.
This commit is contained in:
itsmattkc
2020-05-27 00:09:09 +10:00
parent c907114b17
commit 0c7b3e1761
9 changed files with 133 additions and 100 deletions
+10 -3
View File
@@ -37,18 +37,20 @@ CacheTask::CacheTask(ViewerOutput* viewer, const VideoRenderingParams& vparams,
bool CacheTask::Run()
{
// Get list of invalidated ranges
TimeRangeList range_to_cache = viewer()->video_frame_cache()->GetInvalidatedRanges();
TimeRangeList video_range = viewer()->video_frame_cache()->GetInvalidatedRanges();
TimeRangeList audio_range = viewer()->audio_playback_cache()->GetInvalidatedRanges();
// If we're caching only in-out, limit the range to that
if (in_out_only_) {
Sequence* s = static_cast<Sequence*>(viewer()->parent());
if (s->workarea()->enabled()) {
range_to_cache = range_to_cache.Intersects(s->workarea()->range());
video_range = video_range.Intersects(s->workarea()->range());
audio_range = audio_range.Intersects(s->workarea()->range());
}
}
Render(range_to_cache, QMatrix4x4(), false, true);
Render(video_range, audio_range, QMatrix4x4(), true);
download_threads_.waitForDone();
@@ -67,4 +69,9 @@ void CacheTask::FrameDownloaded(const QByteArray &hash, const QLinkedList<ration
}
}
void CacheTask::AudioDownloaded(const TimeRange &range, SampleBufferPtr samples)
{
viewer()->audio_playback_cache()->WritePCM(range, samples);
}
OLIVE_NAMESPACE_EXIT