summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2013-10-12 19:36:06 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2013-10-12 19:36:06 +0200
commitad906c6eef29cb39bd674948e5ae27879ed51844 (patch)
tree55ad8d0c4af38439b2696b8ecd5737edf0865223
parentee18be9fad42203db5a6d25565d392093defccbe (diff)
Don't send a message to the GUI on /each/ file that has been loaded. Decimation is the key.
-rw-r--r--src/drumkitloader.cc14
-rw-r--r--src/drumkitloader.h1
2 files changed, 10 insertions, 5 deletions
diff --git a/src/drumkitloader.cc b/src/drumkitloader.cc
index 69f656b..a2e1923 100644
--- a/src/drumkitloader.cc
+++ b/src/drumkitloader.cc
@@ -86,6 +86,8 @@ void DrumKitLoader::loadKit(DrumKit *kit)
}
}
+ fraction = total_num_audiofiles / 200;
+
{ // Now actually queue them for loading:
Instruments::iterator i = kit->instruments.begin();
while(i != kit->instruments.end()) {
@@ -146,11 +148,13 @@ void DrumKitLoader::thread_main()
audiofile->load();
loaded++;
- LoadStatusMessage *ls = new LoadStatusMessage();
- ls->number_of_files = total_num_audiofiles;
- ls->numer_of_files_loaded = loaded;
- ls->current_file = audiofile->filename;
- msghandler.sendMessage(MSGRCV_UI, ls);
+ if(loaded % fraction == 0 || loaded == total_num_audiofiles) {
+ LoadStatusMessage *ls = new LoadStatusMessage();
+ ls->number_of_files = total_num_audiofiles;
+ ls->numer_of_files_loaded = loaded;
+ ls->current_file = audiofile->filename;
+ msghandler.sendMessage(MSGRCV_UI, ls);
+ }
}
DEBUG(loader, "Loader thread finished.");
diff --git a/src/drumkitloader.h b/src/drumkitloader.h
index be24812..0534de8 100644
--- a/src/drumkitloader.h
+++ b/src/drumkitloader.h
@@ -91,6 +91,7 @@ private:
volatile bool running;
std::list<AudioFile*> load_queue;
size_t total_num_audiofiles;
+ size_t fraction;
size_t loaded;
};