diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2019-07-25 17:49:16 +0200 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2019-09-28 20:37:47 +0200 |
commit | 9d1ea1e7cfa256c7f5cac027382d92f658734ccb (patch) | |
tree | 39ec7cdaa8ed571137430ccbbc0a391bb27427a3 /src/drumkitloader.cc | |
parent | cd9af98abdce1fe3759e786d6b010a7fe3395e2c (diff) |
Add generic logger interface for propagating messages while loading drumkits to the commandline
and/or plugin UI.
Diffstat (limited to 'src/drumkitloader.cc')
-rw-r--r-- | src/drumkitloader.cc | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/src/drumkitloader.cc b/src/drumkitloader.cc index 933e415..d9f65f0 100644 --- a/src/drumkitloader.cc +++ b/src/drumkitloader.cc @@ -50,6 +50,28 @@ DrumKitLoader::DrumKitLoader(Settings& settings, DrumKit& kit, , rand(rand) , audio_cache(audio_cache) { + logger = + [&](LogLevel level, const std::string& msg) + { + std::string message; + switch(level) + { + case LogLevel::Info: + //message = "[Info]"; + //break; + return; // Ignore info level messages + case LogLevel::Warning: + message = "[Warning]"; + break; + case LogLevel::Error: + message = "[Error]"; + break; + } + message += " " + msg + "\n"; + std::string status = settings.load_status_text.load(); + status += message; + settings.load_status_text.store(status); + }; } DrumKitLoader::~DrumKitLoader() @@ -108,6 +130,8 @@ bool DrumKitLoader::loadkit(const std::string& file) // Delete all Channels, Instruments, Samples and AudioFiles. kit.clear(); + settings.load_status_text.store(""); + settings.drumkit_load_status.store(LoadStatus::Loading); // Parse drumkit and instrument xml @@ -134,7 +158,7 @@ bool DrumKitLoader::loadkit(const std::string& file) std::vector<InstrumentDOM> instrumentdoms; std::string path = getPath(edited_filename); bool parseerror = false; - bool ret = parseDrumkitFile(edited_filename, drumkitdom); + bool ret = parseDrumkitFile(edited_filename, drumkitdom, logger); if(!ret) { WARN(drumkitloader, "Drumkit file parser error: '%s'", @@ -146,7 +170,8 @@ bool DrumKitLoader::loadkit(const std::string& file) for(const auto& ref : drumkitdom.instruments) { instrumentdoms.emplace_back(); - bool ret = parseInstrumentFile(path + "/" + ref.file, instrumentdoms.back()); + bool ret = parseInstrumentFile(path + "/" + ref.file, instrumentdoms.back(), + logger); if(!ret) { WARN(drumkitloader, "Instrument file parser error: '%s'", @@ -157,7 +182,7 @@ bool DrumKitLoader::loadkit(const std::string& file) } DOMLoader domloader(settings, rand); - ret = domloader.loadDom(path, drumkitdom, instrumentdoms, kit); + ret = domloader.loadDom(path, drumkitdom, instrumentdoms, kit, logger); if(!ret) { WARN(drumkitloader, "DOMLoader error"); @@ -339,7 +364,7 @@ void DrumKitLoader::thread_main() filename = audiofile->filename; try { - audiofile->load(preload_samples); + audiofile->load(logger, preload_samples); } catch(std::bad_alloc&) { |