Improve audio loading progress reporting

Even without the animation the reported progress was an average of 1.5
blocks behind the actual progress, and with the animation it was two
blocks behind. Assuming constant-speed audio decoding it should now be
nearly accurate (it still ignores that the last block may be smaller
than the rest).
This commit is contained in:
Thomas Goyne 2013-09-26 16:10:20 -07:00
parent 932747e70a
commit 07ad40dd3f

View file

@ -70,9 +70,9 @@ void RAMAudioProvider::FillCache(AudioProvider *source, agi::ProgressSink *ps) {
int64_t readsize = CacheBlockSize / source->GetBytesPerSample();
for (size_t i = 0; i < blockcache.size(); i++) {
ps->SetProgress(i + 1, blockcache.size());
source->GetAudio(&blockcache[i][0], i * readsize, std::min<int64_t>(readsize, num_samples - i * readsize));
ps->SetProgress(i, blockcache.size() - 1);
if (ps->IsCancelled()) {
return;
}