Ejemplo n.º 1
0
    int run()
    {

      CsoundPerformanceThreadMessage::lockRecord();
      recordData_t *recordData = CsoundPerformanceThreadMessage::getRecordData();
      if (recordData->running) {
          recordData->running = false;
          csoundJoinThread(recordData->thread);
          sf_close((SNDFILE *) recordData->sfile);
      }

      CsoundPerformanceThreadMessage::unlockRecord();

      return 0;
    }
Ejemplo n.º 2
0
 int stop()
 {
     if (!csound) {
         ll->printf(1, "skipping %s, csound==NULL\n", __FUNCTION__);
         return 1;
     }
     if (ThreadID)
     {
         PERF_STATUS = STOP;
         ll->printf( "INFO(%s:%i) aclient joining performance thread\n", __FILE__, __LINE__ );
         uintptr_t rval = csoundJoinThread(ThreadID);
         ll->printf( "INFO(%s:%i) ... joined\n", __FILE__, __LINE__ );
         if (rval)  ll->printf( "WARNING: thread returned %zu\n", rval);
         ThreadID = NULL;
         return 0;
     }
     return 1;
 }
Ejemplo n.º 3
0
int main(int arg, char** argv) {
  void* thread;

  csoundInitialize(CSOUNDINIT_NO_ATEXIT);

  CSOUND* csound = csoundCreate(NULL);

  /* Using SetOption() to configure Csound 
  Note: use only one commandline flag at a time */
  csoundSetOption(csound, "-odac");

  /* Compile the Csound Orchestra string */
  csoundCompileOrc(csound, orc);

  /* Compile the Csound SCO String */
  csoundReadScore(csound, (char*)sco);

  /* When compiling from strings, this call is necessary 
   * before doing any performing */
  csoundStart(csound);

  /* Create a new thread that will use our performance function and 
   * pass in our CSOUND structure. This call is asynchronous and 
   * will immediately return back here to continue code execution
   */
  thread = csoundCreateThread(&performance_function, (void*)csound);
 
  /* Join will wait for the other thread to complete. If we did not 
   * call csoundJoinThread(), after csoundCreateThread() returns we 
   * would immediately move to the next line, csoundStop().  That 
   * would stop Csound without really giving it time to run.
   */
  csoundJoinThread(thread);

  csoundStop(csound);

  /* clean up Csound; this is useful if you're going to reuse a Csound 
   * instance 
   */
  csoundCleanup(csound);

  return 0;
}
Ejemplo n.º 4
0
int CsoundPerformanceThread::Join()
{
    int retval;
    retval = status;

    if (perfThread) {
      pthread_cond_signal(&recordData.condvar);
      retval = csoundJoinThread(perfThread);
      perfThread = (void*) 0;
    }

    // delete any pending messages
    {
      CsoundPerformanceThreadMessage *msg;
      msg = (CsoundPerformanceThreadMessage*) firstMessage;
      firstMessage = (CsoundPerformanceThreadMessage*) 0;
      lastMessage = (CsoundPerformanceThreadMessage*) 0;
      while (msg) {
        CsoundPerformanceThreadMessage *nxt = msg->nxt;
        delete msg;
        msg = nxt;
      }
    }
    // delete all thread locks
    if (queueLock) {
      csoundDestroyMutex(queueLock);
      queueLock = (void*) 0;
    }
    if (pauseLock) {
      csoundNotifyThreadLock(pauseLock);
      csoundDestroyThreadLock(pauseLock);
      pauseLock = (void*) 0;
    }
    if (flushLock) {
      csoundNotifyThreadLock(flushLock);
      csoundDestroyThreadLock(flushLock);
      flushLock = (void*) 0;
    }

    return retval;
}