Exemplo n.º 1
0
bool DSPServer::deleteFactory(MHD_Connection* connection, dsp_server_connection_info* info)
{
    // Returns the factory (with incremented reference counter)
#ifdef LLVM_DSP_FACTORY
    dsp_factory* factory = getDSPFactoryFromSHAKey(info->fSHAKey);
#else
    dsp_factory* factory = getInterpreterDSPFactoryFromSHAKey(info->fSHAKey);
#endif
    
    if (factory) {
        // Remove from the list
        fFactories.erase(factory);
        // Has to be done twice since getDSPFactoryFromSHAKey has incremented once more...
    #ifdef LLVM_DSP_FACTORY
        deleteDSPFactory(dynamic_cast<llvm_dsp_factory*>(factory));
        deleteDSPFactory(dynamic_cast<llvm_dsp_factory*>(factory));
    #else
        deleteInterpreterDSPFactory(dynamic_cast<interpreter_dsp_factory*>(factory));
        deleteInterpreterDSPFactory(dynamic_cast<interpreter_dsp_factory*>(factory));
    #endif
        return sendPage(connection, "", MHD_HTTP_OK, "text/html");
    } else {
        return sendPage(connection, builtError(ERROR_FACTORY_NOTFOUND), MHD_HTTP_BAD_REQUEST, "text/html");
    }
}
Exemplo n.º 2
0
/* deinit function
   delete faust objects
*/
int delete_faustgen(CSOUND *csound, void *p) {
  faustgen *pp = (faustgen *) p;
  faustobj *fobj, *prv, **pfobj;
  pfobj = (faustobj **) csound->QueryGlobalVariable(csound,"::dsp");
  fobj = *pfobj;
  prv = fobj;
  while(fobj != NULL) {
    if(fobj->obj == (void *) pp->engine) {
      prv->nxt = fobj->nxt;
      break;
    }
    prv = fobj;
    fobj = fobj->nxt;
  }
  if(fobj == NULL) {
    if(fobj != NULL) {
      if(*pfobj == fobj) *pfobj = fobj->nxt;
      csound->Free(csound, fobj);
      delete pp->ctls;
      deleteDSPInstance(pp->engine);
    } else {
      csound->Warning(csound, "could not find DSP %p for deletion", pp->engine);
    }
  }
  if(pp->factory) deleteDSPFactory(pp->factory);
  return OK;
}
Exemplo n.º 3
0
bool DSPServer::deleteFactory(MHD_Connection* connection, dsp_server_connection_info* info)
{
    // Returns the factory (with incremented reference counter)
    llvm_dsp_factory* factory = getDSPFactoryFromSHAKey(info->fSHAKey);
    //llvm_dsp_factory* factory = getCDSPFactoryFromSHAKey(info->fSHAKey.c_str());
    
    if (factory) {
        // Remove from the list
        fFactories.erase(factory);
        // Has to be done twice since getDSPFactoryFromSHAKey has incremented once more...
        deleteDSPFactory(factory); 
        deleteDSPFactory(factory);
        return sendPage(connection, "", MHD_HTTP_OK, "text/html");
    } else {
        return sendPage(connection, builtError(ERROR_FACTORY_NOTFOUND), MHD_HTTP_BAD_REQUEST, "text/html");
    }
}
Exemplo n.º 4
0
DSPServer::~DSPServer() 
{
    for (FactoryTableIt it = fFactories.begin(); it != fFactories.end(); it++) {
    #ifdef LLVM_DSP_FACTORY
        deleteDSPFactory(dynamic_cast<llvm_dsp_factory*>(*it));
    #else
        deleteInterpreterDSPFactory(dynamic_cast<interpreter_dsp_factory*>(*it));
    #endif
    }
}
Exemplo n.º 5
0
void FaustgenFactory::freeDSPFactory()
{
  const ScopedLock lock(fDSPMutex);

  // Free all instances
  std::set<FaustAudioPluginInstance*>::const_iterator it;
  for (it = fInstances.begin(); it != fInstances.end(); it++) {
    (*it)->freeDSP();
  }

  deleteDSPFactory(fDSPfactory);
  fDSPfactory = nullptr;
}
Exemplo n.º 6
0
int delete_faustcompile(CSOUND *csound, void *p) {

  faustcompile *pp = (faustcompile *) p;
  faustobj *fobj, *prv, **pfobj;
  pfobj = (faustobj **) csound->QueryGlobalVariable(csound,"::factory");
  fobj = *pfobj;
  prv = fobj;
  while(fobj != NULL) {
    if(fobj->obj == (void *) pp->factory) {
      prv->nxt = fobj->nxt;
      break;
    }
    prv = fobj;
    fobj = fobj->nxt;
  }
  if(fobj != NULL) {
    if(*pfobj == fobj) *pfobj = fobj->nxt;
    deleteDSPFactory(pp->factory);
    csound->Free(csound, fobj);
  }
  return OK;
}
Exemplo n.º 7
0
// Create DSP Instance
bool DSPServer::createInstance(dsp_server_connection_info* con_info)
{
#ifdef LLVM_DSP_FACTORY
    dsp_factory* factory = getDSPFactoryFromSHAKey(con_info->fSHAKey);
#else
    dsp_factory* factory = getInterpreterDSPFactoryFromSHAKey(con_info->fSHAKey);
#endif

    audio_dsp* audio = NULL;
    dsp* dsp = NULL;
    
    if (factory) {
    
        try {
            if (con_info->fAudioType == "kNetJack") {
                std::cout << con_info->fPoly << " " << con_info->fVoices << " " << con_info->fGroup << std::endl;
            #ifdef NETJACK
                audio = new netjack_dsp(factory, 
                                        con_info->fCompression, 
                                        con_info->fIP, con_info->fPort, 
                                        con_info->fMTU, con_info->fLatency, 
                                        factory->getName(),
                                        con_info->fInstanceKey,
                                        con_info->fPoly, 
                                        con_info->fVoices, 
                                        con_info->fGroup, 
                                        fCreateDSPInstanceCb, fCreateDSPInstanceCb_arg,
                                        fDeleteDSPInstanceCb, fDeleteDSPInstanceCb_arg);
                pthread_t thread;
                AudioStarter* starter = new AudioStarter(this, audio);
                if (pthread_create(&thread, NULL, DSPServer::open, starter) != 0) {
                    goto error;
                }
                
            #endif
            } else if (con_info->fAudioType == "kLocalAudio") {
                
                /*
                 // Steph : 06/15
                if (!(dsp = factory->createDSPInstance())) {
                    return false;
                }
                
                if (fCreateDSPInstanceCb) {
                    fCreateDSPInstanceCb(dsp, fCreateDSPInstanceCb_arg);
                }
                */
                
                audio = new audio_dsp(factory,
                                    atoi(con_info->fPoly.c_str()),
                                    atoi(con_info->fVoices.c_str()),
                                    atoi(con_info->fGroup.c_str()),
                                    atoi(con_info->fOSC.c_str()),
                                    atoi(con_info->fHTTPD.c_str()),
                                    atoi(con_info->fMIDI.c_str()),
                                    factory->getName(),
                                    //getCName(factory),
                                    con_info->fInstanceKey,
                                    fCreateDSPInstanceCb, 
                                    fCreateDSPInstanceCb_arg,
                                    fDeleteDSPInstanceCb, 
                                    fDeleteDSPInstanceCb_arg);
                
                
                //if (audio->init(atoi(con_info->fSampleRate.c_str()), atoi(con_info->fBufferSize.c_str()))) {
                if (audio->init(22050, 1024)) {
                    fRunningDsp.push_back(audio);
                } else {
                    delete audio;
                }
                
            }
        } catch (...) {
             goto error;
        }
    
        // Not more use of the locally needed factory (actually only decrement it's reference counter...)
    #ifdef LLVM_DSP_FACTORY
        deleteDSPFactory(dynamic_cast<llvm_dsp_factory*>(factory));
    #else
        deleteInterpreterDSPFactory(dynamic_cast<interpreter_dsp_factory*>(factory));
    #endif
        return true;
        
    } else {
        con_info->fAnswer = builtError(ERROR_FACTORY_NOTFOUND);
        return false;
    }  
    
error:
    con_info->fAnswer = builtError(ERROR_INSTANCE_NOTCREATED);
    return false;
}
Exemplo n.º 8
0
int init_faustgen(CSOUND *csound, faustgen *p){
  OPARMS parms;
  std::string err_msg;
  int size;
  int argc = 3;
  const char* argv[argc];
  faustobj  **pfdsp, *fdsp;
  llvm_dsp  *dsp;
  controls  *ctls = new controls();
  const char *varname = "::dsp";
  argv[0] = "-vec";
  argv[1] = "-lv";
  argv[2] = " 1";

#ifdef USE_DOUBLE
  argv[3] = "-double";
  argc += 1;
#endif

  p->factory = createDSPFactoryFromString("faustop", (const char *) p->code->data, argc, argv, "", err_msg, 3);
  if(p->factory == NULL)
    return csound->InitError(csound,
                             Str("Faust compilation problem: %s\n"), err_msg.c_str());

  dsp = createDSPInstance(p->factory);
  if(dsp == NULL)
    return csound->InitError(csound, Str("Faust instantiation problem \n"));

  dsp->buildUserInterface(ctls);

  pfdsp = (faustobj **) csound->QueryGlobalVariable(csound,varname);
  if(pfdsp == NULL) {
    csound->CreateGlobalVariable(csound, varname, sizeof(faustobj *));
    pfdsp = (faustobj **) csound->QueryGlobalVariable(csound,varname);
    fdsp = (faustobj *) csound->Calloc(csound, sizeof(faustobj));
    fdsp->obj = dsp;
    fdsp->ctls = ctls;
    fdsp->nxt = NULL;
    fdsp->cnt = 0;
    *pfdsp = fdsp;
  }
  else {
    fdsp = *pfdsp;
    while(fdsp->nxt){
      fdsp = fdsp->nxt;
    }
    fdsp->nxt = (faustobj *) csound->Calloc(csound, sizeof(faustobj));
    fdsp->nxt->cnt = fdsp->cnt++;
    fdsp = fdsp->nxt;
    fdsp->obj = dsp;
    fdsp->ctls = ctls;
  }

  p->engine = dsp;
  dsp->buildUserInterface(ctls);
  dsp->init(csound->GetSr(csound));
  if(p->engine->getNumInputs() != p->INCOUNT-1) {
    deleteDSPInstance(p->engine);
    deleteDSPFactory(p->factory);
    return csound->InitError(csound, Str("wrong number of input args\n"));
  }
  if(p->engine->getNumOutputs() != p->OUTCOUNT-1){
    deleteDSPInstance(p->engine);
    deleteDSPFactory(p->factory);
    return csound->InitError(csound, Str("wrong number of output args\n"));
  }

  /* memory for sampAccurate offsets */
  csound->GetOParms(csound, &parms);
  if(parms.sampleAccurate){
    int size;
    size = p->engine->getNumInputs()*sizeof(MYFLT *);
    if(p->memin.auxp == NULL ||
       p->memin.size < size)
      csound->AuxAlloc(csound, size, &p->memin);
    size = p->engine->getNumOutputs()*sizeof(MYFLT *);
    if(p->memout.auxp == NULL ||
       p->memout.size < size)
      csound->AuxAlloc(csound, size, &p->memout);
  }
  p->ctls = ctls;
  *p->ohptr = (MYFLT) fdsp->cnt;
  csound->RegisterDeinitCallback(csound, p, delete_faustgen);
  return OK;
}
Exemplo n.º 9
0
Block::~Block()
{
    deleteDSPFactory(m_faustFactory);
}
Exemplo n.º 10
0
DSPServer::~DSPServer() 
{
    for (FactoryTableIt it = fFactories.begin(); it != fFactories.end(); it++) {
        deleteDSPFactory(*it);
    }
}