diff options
author | James <olpc@localhost.localdomain> | 2007-01-25 08:40:00 (GMT) |
---|---|---|
committer | James <olpc@localhost.localdomain> | 2007-01-25 08:40:00 (GMT) |
commit | eae4efe983b2aaf46338a6e2983f83ac5a3fe5f3 (patch) | |
tree | 3bb7df2a8ba597608ad386179bcb781d6503b259 /Util/Clooper | |
parent | 0701b52b495c7a3aaf62ecc4eab52ca1ddae136f (diff) |
SoundClient can disconnect, reconnect
Diffstat (limited to 'Util/Clooper')
-rw-r--r-- | Util/Clooper/SoundClient.cpp | 88 | ||||
-rwxr-xr-x | Util/Clooper/_SClient.so | bin | 158878 -> 158906 bytes | |||
-rwxr-xr-x | Util/Clooper/_ttest.so | bin | 39840 -> 39840 bytes |
3 files changed, 44 insertions, 44 deletions
diff --git a/Util/Clooper/SoundClient.cpp b/Util/Clooper/SoundClient.cpp index ff6e061..9e39e6d 100644 --- a/Util/Clooper/SoundClient.cpp +++ b/Util/Clooper/SoundClient.cpp @@ -145,6 +145,7 @@ struct TamTamSound { void * ThreadID; CSOUND * csound; + char * csound_orc; enum {CONTINUE, STOP} PERF_STATUS; int verbosity; FILE * _debug; @@ -153,32 +154,12 @@ struct TamTamSound EvLoop * loop; TamTamSound(char * orc) - : ThreadID(NULL), PERF_STATUS(STOP), verbosity(3), _debug(NULL), thread_playloop(0), thread_measurelag(0), loop(NULL) + : ThreadID(NULL), csound(NULL), PERF_STATUS(STOP), verbosity(3), _debug(NULL), thread_playloop(0), thread_measurelag(0), loop(NULL) { _debug = fopen("debug.log", "w"); csound = csoundCreate(NULL); - int argc = 2; - char * prog = "fake_progname"; - char ** argv = (char **) malloc(argc * sizeof(char*)); - argv[0] = prog; - argv[1] = orc; - - csoundInitialize(&argc, &argv, 0); - int result = csoundCompile( csound, argc, argv); - free(argv); - if (!result) - { - //PERF_STATUS = CONTINUE; - //ThreadID = csoundCreateThread(csThread, (void*)this); - } - else - { - fprintf(_debug, "ERROR: csoundCompile() returned %i\n", result); - csoundDestroy(csound); - csound = NULL; - ThreadID = NULL; - } + csound_orc = strdup(orc); loop = new EvLoop(csound); } @@ -190,6 +171,7 @@ struct TamTamSound delete loop; csoundDestroy(csound); } + free(csound_orc); fclose(_debug); } static double pytime(const struct timeval * tv) @@ -227,13 +209,51 @@ struct TamTamSound } ++loops; } - csoundDestroy(csound); - return 1; + return 0; } static uintptr_t csThread(void *clientData) { return ((TamTamSound*)clientData)->thread_fn(); } + void start() + { + if (!ThreadID) + { + int argc=3; + char **argv = (char**)malloc(argc*sizeof(char*)); + argv[0] = "csound"; + argv[1] ="-m0"; + argv[2] = csound_orc; + fprintf(_debug, "loading file %s\n", csound_orc); + + csoundInitialize(&argc, &argv, 0); + int result = csoundCompile(csound, argc, &(argv[0])); + free(argv); + + if (!result) + { + PERF_STATUS = CONTINUE; + ThreadID = csoundCreateThread(csThread, (void*)this); + } + else + { + fprintf(_debug, "ERROR: failed to compile orchestra\n"); + ThreadID = NULL; + } + } + } + void stop() + { + if (ThreadID) + { + PERF_STATUS = STOP; + if (verbosity > 0) fprintf(_debug, "INFO: stop()"); + uintptr_t rval = csoundJoinThread(ThreadID); + if (rval) fprintf(_debug, "WARNING: thread returned %zu\n", rval); + ThreadID = NULL; + csoundReset(csound); + } + } void scoreEvent(char type, MYFLT * p, int np) { @@ -314,26 +334,6 @@ struct TamTamSound fprintf(_debug, "ERROR: failed to set master volume\n"); } } - void start() - { - if (!ThreadID) - { - PERF_STATUS = CONTINUE; - ThreadID = csoundCreateThread(csThread, (void*)this); - } - } - void stop() - { - if (ThreadID) - { - PERF_STATUS = STOP; - if (verbosity > 0) fprintf(_debug, "INFO: stop()"); - uintptr_t rval = csoundJoinThread(ThreadID); - if (rval) fprintf(stderr, "INFO: thread returned %zu\n", rval); - ThreadID = NULL; - csoundReset(csound); - } - } }; diff --git a/Util/Clooper/_SClient.so b/Util/Clooper/_SClient.so Binary files differindex a6a60ba..85fbd32 100755 --- a/Util/Clooper/_SClient.so +++ b/Util/Clooper/_SClient.so diff --git a/Util/Clooper/_ttest.so b/Util/Clooper/_ttest.so Binary files differindex 6b14ebe..2019799 100755 --- a/Util/Clooper/_ttest.so +++ b/Util/Clooper/_ttest.so |