Example #1
0
void Algorithm::declareInput(SinkBase& sink, const std::string& name,
                             const std::string& desc) {
  sink.setName(name);
  sink.setParent(this);

  _inputs.insert(name, &sink);
  inputDescription.insert(name, desc);
}
Example #2
0
void Algorithm::declareInput(SinkBase& sink,
                             int acquireSize,
                             int releaseSize,
                             const std::string& name,
                             const std::string& desc) {
  sink.setAcquireSize(acquireSize);
  sink.setReleaseSize(releaseSize);
  declareInput(sink, name, desc);
}
Example #3
0
void disconnect(SourceBase& source, SinkBase& sink) {
  try {
    E_DEBUG(EConnectors, "Disconnecting " << source.fullName() << " from " << sink.fullName());

    source.disconnect(sink);
    sink.disconnect(source);
  }
  catch (const EssentiaException& e) {
    std::ostringstream msg;
    msg << "While disconnecting " << source.fullName()
        << " (output) from " << sink.fullName() << " (input):\n"
        << e.what();
    throw EssentiaException(msg);
  }
}
Example #4
0
// here we check the types as well
void connect(SourceBase& source, SinkBase& sink) {
  try {
    // NB: source needs to connect to sink first to have a ReaderID as soon as possible.
    //     this is a requirement for ProxyConnectors
    E_DEBUG(EConnectors, "Connecting " << source.fullName() << " to " << sink.fullName());
    source.connect(sink);
    sink.connect(source);
  }
  catch (EssentiaException& e) {
    std::ostringstream msg;
    msg << "While connecting " << source.fullName()
        << " to " << sink.fullName() << ":\n"
        << e.what();
    throw EssentiaException(msg);
  }
}
Example #5
0
void Network::checkBufferSizes() {
  // TODO: we should do this on the execution network, right?
  E_DEBUG(ENetwork, "checking buffer sizes");
  vector<Algorithm*> algos = depthFirstMap(_executionNetworkRoot, returnAlgorithm);

  for (int i=0; i<(int)algos.size(); i++) {
    Algorithm* algo = algos[i];

    for (Algorithm::OutputMap::const_iterator output = algo->outputs().begin();
         output != algo->outputs().end();
         ++output) {

      SourceBase* source = output->second;
      vector<SinkBase*>& sinks = source->sinks();

      BufferInfo sbuf = source->bufferInfo();

      if (sbuf.maxContiguousElements + 1 < source->acquireSize()) {
        E_INFO("On source " << source->fullName() << ":");
        E_INFO("BUFFER SIZE MISMATCH: max=" << sbuf.maxContiguousElements
                  << " - asked for write size " << source->acquireSize());
        sbuf.maxContiguousElements = (int)(source->acquireSize() * 1.1);
        sbuf.size = 8 * sbuf.maxContiguousElements;
        E_INFO("resizing buffer to " << sbuf.size << "/" << sbuf.maxContiguousElements);
      }

      for (vector<SinkBase*>::iterator it = sinks.begin(); it!=sinks.end(); ++it) {
        SinkBase* sink = *it;

        if (sbuf.maxContiguousElements + 1 < sink->acquireSize()) {
          E_INFO("On connection " << source->fullName() << " → " << sink->fullName() << ":");
          E_INFO("BUFFER SIZE MISMATCH: max=" << sbuf.maxContiguousElements
                    << " - asked for read size " << sink->acquireSize());
          sbuf.maxContiguousElements = (int)(sink->acquireSize() * 1.1);
          sbuf.size = 8 * sbuf.maxContiguousElements;
          E_INFO("resizing buffer to " << sbuf.size << "/" << sbuf.maxContiguousElements);
        }
      }
      source->setBufferInfo(sbuf);
    }
  }
  E_DEBUG(ENetwork, "checking buffer sizes ok");
}