MCPcopy Create free account
hub / github.com/csound/csound / Perform

Method Perform

interfaces/csPerfThread.cpp:417–496  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

415 */
416
417int CsoundPerformanceThread::Perform()
418{
419 int retval = 0;
420 do {
421 while (firstMessage) {
422 csoundLockMutex(queueLock);
423 do {
424 CsoundPerformanceThreadMessage *msg;
425 // get oldest message
426 msg = (CsoundPerformanceThreadMessage*) firstMessage;
427 if (!msg)
428 break;
429 // unlink from FIFO
430 firstMessage = msg->nxt;
431 if (!msg->nxt)
432 lastMessage = (CsoundPerformanceThreadMessage*) 0;
433 // process and destroy message
434 retval = msg->run();
435 delete msg; // TODO: This should be moved out of the Perform function
436 } while (!retval);
437 if (paused)
438 csoundWaitThreadLock(pauseLock, (size_t) 0);
439 // mark queue as empty
440 csoundNotifyThreadLock(flushLock);
441 csoundUnlockMutex(queueLock);
442 // if error or end of score, return now
443 if (retval)
444 goto endOfPerf;
445 // fprintf(stderr, "Error or end of score, returning now.");
446 // if paused, wait until a new message is received, then loop back
447 if (!paused)
448 break;
449 // VL: if this is paused, then it will double lock.
450 csoundWaitThreadLockNoTimeout(pauseLock);
451 csoundNotifyThreadLock(pauseLock);
452 }
453 if(processcallback != NULL)
454 processcallback(cdata);
455 retval = csoundPerformKsmps(csound);
456 if (recordData.running) {
457 MYFLT *spout = csoundGetSpout(csound);
458 int len = csoundGetKsmps(csound) * csoundGetNchnls(csound);
459 if (csoundGet0dBFS(csound) != 1.0) {
460 MYFLT zdbfs = csoundGet0dBFS(csound);
461 MYFLT *modspout = spout;
462 for (int i = 0; i < len; i++) {
463 *modspout /= zdbfs;
464 modspout++;
465 }
466 }
467 int written = csoundWriteCircularBuffer(NULL, recordData.cbuf,
468 spout, len);
469 if (written != len) {
470 csoundMessage(csound, "perfThread record buffer overrun.\n");
471 }
472 }
473 csoundCondSignal(recordData.condvar); // Needs to be outside the if
474 // for the case where stop record was requested

Callers 3

mainFunction · 0.45
PerformMethod · 0.45
csoundPerformanceThread_Function · 0.45

Calls 15

csoundLockMutexFunction · 0.85
csoundWaitThreadLockFunction · 0.85
csoundNotifyThreadLockFunction · 0.85
csoundUnlockMutexFunction · 0.85
csoundMessageFunction · 0.85
csoundCondSignalFunction · 0.85
csoundPerformKsmpsFunction · 0.50
csoundGetSpoutFunction · 0.50
csoundGetKsmpsFunction · 0.50
csoundGetNchnlsFunction · 0.50

Tested by

no test coverage detected