From ad906c6eef29cb39bd674948e5ae27879ed51844 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sat, 12 Oct 2013 19:36:06 +0200 Subject: Don't send a message to the GUI on /each/ file that has been loaded. Decimation is the key. --- src/drumkitloader.cc | 14 +++++++++----- src/drumkitloader.h | 1 + 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 load_queue; size_t total_num_audiofiles; + size_t fraction; size_t loaded; }; -- cgit v1.2.3