From 16789b6a6e804a510694020a045d9db2d197e341 Mon Sep 17 00:00:00 2001 From: jofemodo Date: Thu, 26 Aug 2021 12:54:21 +0200 Subject: [PATCH] Add mutex lock on internal command line process. --- clients/jack_client.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/clients/jack_client.cpp b/clients/jack_client.cpp index 4de49455..799a6dbf 100644 --- a/clients/jack_client.cpp +++ b/clients/jack_client.cpp @@ -194,7 +194,7 @@ bool load_instrument(const char *fpath) { } -std::vector string_tokenize(std::string str) { +std::vector string_tokenize(const std::string str) { std::vector tokens; std::string part = ""; for (size_t i=0; i tokens = string_tokenize(args); if (kw=="load_instrument") { - //args.erase(std::remove(str.begin(), str.end(), '\"'), str.end()); - load_instrument(tokens[0].c_str()); + try { + std::lock_guard lock { processMutex }; + load_instrument(tokens[0].c_str()); + } catch (...) { + std::cout << "ERROR: Can't load instrument!\n"; + } } else if (kw=="set_oversampling") { try { + std::lock_guard lock { processMutex }; synth.setOversamplingFactor(stoi(args)); } catch (...) { std::cout << "ERROR: Can't set oversampling!\n"; @@ -242,6 +247,7 @@ void cli_thread_proc() { } else if (kw=="set_preload_size") { try { + std::lock_guard lock { processMutex }; synth.setPreloadSize(stoi(args)); } catch (...) { std::cout << "ERROR: Can't set preload size!\n"; @@ -249,6 +255,7 @@ void cli_thread_proc() { } else if (kw=="set_voices") { try { + std::lock_guard lock { processMutex }; synth.setNumVoices(stoi(args)); } catch (...) { std::cout << "ERROR: Can't set num of voices!\n";