From e32591388a18c8226e61b8f88b031ed7c88ca153 Mon Sep 17 00:00:00 2001 From: Florian Jung Date: Mon, 10 Jan 2011 20:20:10 +0100 Subject: Improved in-synth-cli, still TODO The CLI can now prepare loading a note without actually loading it --- synth/in_synth_cli.cpp | 55 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 50 insertions(+), 5 deletions(-) (limited to 'synth/in_synth_cli.cpp') diff --git a/synth/in_synth_cli.cpp b/synth/in_synth_cli.cpp index 7aa1d8e..4334978 100644 --- a/synth/in_synth_cli.cpp +++ b/synth/in_synth_cli.cpp @@ -1,9 +1,13 @@ #include #include #include +#include +#include #include "in_synth_cli.h" #include "util.h" +#include "communication.h" +#include "globals.h" using namespace std; @@ -14,16 +18,53 @@ void signal_handler(int sig) cout << endl << PROMPT << flush; } +void do_request(int prg_no, bool susp) +{ + pthread_mutex_lock(&suspend_request_mutex); + + suspend_request.prog=prg_no; + suspend_request.suspend=susp; + suspend_request.done=false; + + pthread_mutex_unlock(&suspend_request_mutex); + + + + while (true) + { + usleep(100000); + + pthread_mutex_lock(&suspend_request_mutex); + if (suspend_request.done) + { + pthread_mutex_unlock(&suspend_request_mutex); + break; + } + else + pthread_mutex_unlock(&suspend_request_mutex); + } +} + +void lock_and_load_program(int prg_no, string file) +{ + do_request(prg_no, true); + + //TODO load the program + usleep(5000000); + + do_request(prg_no, false); +} + void do_in_synth_cli() { string input; string command; string params; + int num; if (signal(2,signal_handler)==SIG_ERR) - { - cout << "WARNING: failed to set signal handler!" << endl; - } + output_warning("WARNING: failed to set signal handler in the in-synth-cli. pressing enter will\n" + " kill the synth, so be careful. this is not fatal"); while (true) @@ -43,7 +84,8 @@ void do_in_synth_cli() cout << "error: expected program-number, found '"<