Update indexing progress less often

wxTheApp->QueueEvent is sufficiently slow that updating the progress
could sometimes take longer than the actual indexing.
This commit is contained in:
Thomas Goyne 2013-09-25 14:34:07 -07:00
parent a28aafcdab
commit 382708132c
1 changed files with 10 additions and 4 deletions

View File

@ -103,13 +103,19 @@ FFMS_Index *FFmpegSourceProvider::DoIndexing(FFMS_Indexer *Indexer, agi::fs::pat
// index all audio tracks // index all audio tracks
FFMS_Index *Index; FFMS_Index *Index;
Progress.Run([&](agi::ProgressSink *ps) { Progress.Run([&](agi::ProgressSink *ps) {
struct progress {
agi::ProgressSink *ps;
int calls;
};
progress state = { ps, 0 };
Index = FFMS_DoIndexing(Indexer, Trackmask, FFMS_TRACKMASK_NONE, nullptr, nullptr, IndexEH, Index = FFMS_DoIndexing(Indexer, Trackmask, FFMS_TRACKMASK_NONE, nullptr, nullptr, IndexEH,
static_cast<TIndexCallback>([](int64_t Current, int64_t Total, void *Private) -> int { static_cast<TIndexCallback>([](int64_t Current, int64_t Total, void *Private) -> int {
agi::ProgressSink *ps = static_cast<agi::ProgressSink*>(Private); auto state = static_cast<progress *>(Private);
ps->SetProgress(Current, Total); if (++state->calls % 10 == 0)
return ps->IsCancelled(); state->ps->SetProgress(Current, Total);
return state->ps->IsCancelled();
}), }),
ps, &ErrInfo); &state, &ErrInfo);
}); });
if (Index == nullptr) { if (Index == nullptr) {