summaryrefslogtreecommitdiff
path: root/synth/in_synth_cli.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'synth/in_synth_cli.cpp')
-rw-r--r--synth/in_synth_cli.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/synth/in_synth_cli.cpp b/synth/in_synth_cli.cpp
index 7ca9c7d..fc24b03 100644
--- a/synth/in_synth_cli.cpp
+++ b/synth/in_synth_cli.cpp
@@ -10,11 +10,14 @@
#include "globals.h"
#include "load.h"
#include "lfos.h"
+#include "watch_files.h"
using namespace std;
#define PROMPT "> "
+pthread_mutex_t prog_load_mutex;
+
void signal_handler(int sig)
{
cout << endl << PROMPT << flush;
@@ -49,12 +52,18 @@ void do_request(int prg_no, bool susp)
void lock_and_load_program(int prg_no, string file)
{
+ pthread_mutex_lock(&prog_load_mutex);
+
+ remove_watch(prg_no);
+
do_request(prg_no, true);
if (load_program(file,program_settings[prg_no]))
{
cout << "success" << endl;
programfile[prg_no]=file;
+
+ add_watch(prg_no);
}
else
cout << "failed" << endl;
@@ -63,6 +72,32 @@ void lock_and_load_program(int prg_no, string file)
channel[i]->maybe_reload_program(prg_no);
do_request(prg_no, false);
+
+ pthread_mutex_unlock(&prog_load_mutex);
+}
+
+//only use this, if you don't want the file-watches to be updated
+//i.e., only when reloading a program!
+void lock_and_load_program_no_watch_updates(int prg_no, string file)
+{
+ pthread_mutex_lock(&prog_load_mutex);
+
+ do_request(prg_no, true);
+
+ if (load_program(file,program_settings[prg_no]))
+ {
+ cout << "success" << endl;
+ programfile[prg_no]=file;
+ }
+ else
+ cout << "failed" << endl;
+
+ for (int i=0;i<N_CHANNELS;++i)
+ channel[i]->maybe_reload_program(prg_no);
+
+ do_request(prg_no, false);
+
+ pthread_mutex_unlock(&prog_load_mutex);
}
void lock_and_change_lfo(int lfo_no, float freq)
@@ -83,6 +118,8 @@ void do_in_synth_cli()
string command;
string params;
int num;
+
+ pthread_mutex_init(&prog_load_mutex, NULL);
if (signal(2,signal_handler)==SIG_ERR)
output_warning("WARNING: failed to set signal handler in the in-synth-cli. pressing ctrl+c will\n"