Пример #1
0
  static uintptr_t recordThread_(void *recordData_)
  {
    recordData_t *recordData = (recordData_t *)recordData_;
    int retval = 0;
    const int bufsize = 4096;
    MYFLT buf[bufsize];
    _MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON);
    while (recordData->running) {
        pthread_mutex_lock(&recordData->mutex);
        pthread_cond_wait(&recordData->condvar, &recordData->mutex);
        int sampsread;
        do {
            sampsread = csoundReadCircularBuffer(NULL, recordData->cbuf, buf, bufsize);
#ifdef USE_DOUBLE
            sf_write_double((SNDFILE *) recordData->sfile,
                            buf, sampsread);
#else
            sf_write_float((SNDFILE *) recordData->sfile,
                           buf, sampsread);
#endif
        } while(sampsread != 0);
        pthread_mutex_unlock(&recordData->mutex);
    }
    return (uintptr_t) ((unsigned int) retval);
  }
Пример #2
0
void WebSocketOpcode_receiveOutputArgumentData(CSOUND *csound,
                                               WebSocketOpcode *self)
{
    int i;
    for (i = 0; i < self->outputArgumentCount; ++i) {

      OpcodeArgument *currentArgument = &self->outputArguments[i];

      if (currentArgument->iRateVarSent == true) {

        continue;
      }

      csoundReadCircularBuffer(csound, currentArgument->circularBuffer,
                               currentArgument->dataPointer,
                               currentArgument->itemsCount);
    }
}
Пример #3
0
void WebSocketOpcode_handleServerWritable(struct libwebsocket *websocket,
                                          WebSocketOpcode *self,
                                          CSOUND *csound, void *messageBuffer)
{
    const struct libwebsocket_protocols *protocol =
      libwebsockets_get_protocol(websocket);

    // If it's an output argument just return
    if (protocol->protocol_index < self->outputArgumentCount) {

      usleep(100);
      return;
    }

    int inputIndex = protocol->protocol_index - self->outputArgumentCount;
    OpcodeArgument *argument = &self->inputArguments[inputIndex];

    int readItems = 0;

    if (argument->bytesWritten == 0) {

      readItems =
        csoundReadCircularBuffer(csound, argument->circularBuffer,
                                 argument->readBuffer, argument->itemsCount);
    }
    if (readItems != 0 || argument->bytesWritten != 0) {

      WebSocketOpcode_writeMessage(self, argument, messageBuffer, websocket);

      if (argument->argumentType == IRATE_VAR ||
          argument->argumentType == IRATE_ARRAY) {

        argument->iRateVarSent = true;
      }
    }

    usleep(100);

    if (argument->iRateVarSent == false) {

      libwebsocket_callback_on_writable(self->webSocket->context, websocket);
    }
}