diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2021-04-22 18:18:53 +0200 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2021-04-22 18:45:49 +0200 |
commit | 28096a402947b05c7e923e075f926263a3279a42 (patch) | |
tree | 0dd68b8ab1f84e6fb5ec246ad0d456eb30ff5fd3 /drumgizmo/drumgizmoc.cc | |
parent | fcfaa7affa0ac8afeaf38346226beb30fca09733 (diff) |
Fix crash when doing async-load in cli.
Diffstat (limited to 'drumgizmo/drumgizmoc.cc')
-rw-r--r-- | drumgizmo/drumgizmoc.cc | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/drumgizmo/drumgizmoc.cc b/drumgizmo/drumgizmoc.cc index c6b43f0..cec96f7 100644 --- a/drumgizmo/drumgizmoc.cc +++ b/drumgizmo/drumgizmoc.cc @@ -326,6 +326,7 @@ int main(int argc, char* argv[]) } oe = factory.createOutput(engine); if(ie == NULL) + if(oe == NULL) { std::cerr << "Invalid output engine: " << engine << std::endl; return 1; @@ -700,6 +701,34 @@ int main(int argc, char* argv[]) } std::cout << "\ndone" << std::endl; } + else + { + // Async loading in progress + + // Wait until the loader has passed the kit parsing step before proceeding. + bool parsing_done{false}; + while(!parsing_done) + { + std::this_thread::sleep_for(std::chrono::milliseconds(10)); + + switch(settings.drumkit_load_status.load()) + { + case LoadStatus::Idle: + case LoadStatus::Parsing: + // Not yet past the parsing step + break; + case LoadStatus::Loading: + case LoadStatus::Done: + // Past parsing step + parsing_done = true; + break; + case LoadStatus::Error: + // Kit parser error? + std::cout << "\nFailed to load " << kitfile << std::endl; + return 1; + } + } + } gizmo.setSamplerate(oe->getSamplerate()); oe->onLatencyChange(gizmo.getLatency()); |