Logo Search packages:      
Sourcecode: jacktrip version File versions  Download package

void JackAudioInterface::setupClient (  ) [private]

Private method to setup a client of the Jack server.

Exceptions:
std::runtime_errorCan't start Jack.

This method is called by the class constructors. It does the following:

  • Connects to the JACK server
  • Sets the shutdown process callback
  • Creates the appropriate number of input and output channels

Todo:
Write better warning messages. This following line displays very verbose message, check how to desable them.

Definition at line 104 of file JackAudioInterface.cpp.

References createChannels(), getBufferSizeInSamples(), getNumInputChannels(), getNumOutputChannels(), getSizeInBytesPerChannel(), jackShutdown(), mClient, mClientName, mInBuffer, mInProcessBuffer, mInputPacket, mNumFrames, mNumInChans, mNumOutChans, mOutBuffer, mOutProcessBuffer, mOutputPacket, mSizeInBytesPerChannel, and sJackMutex.

Referenced by setup().

{
  const char* client_name = mClientName;
  const char* server_name = NULL;
  jack_options_t options = JackNoStartServer;
  jack_status_t status;

  // Try to connect to the server
  /// \todo Write better warning messages. This following line displays very
  /// verbose message, check how to desable them.
  {
    QMutexLocker locker(&sJackMutex);
    mClient = jack_client_open (client_name, options, &status, server_name);
  }  
  
  if (mClient == NULL) {
    //fprintf (stderr, "jack_client_open() failed, "
    //           "status = 0x%2.0x\n", status);
    if (status & JackServerFailed) {
      fprintf (stderr, "Unable to connect to JACK server\n");
      //std::cerr << "ERROR: Maybe the JACK server is not running?" << std::endl;
      //std::cerr << gPrintSeparator << std::endl;
    }
    //std::exit(1);
    throw std::runtime_error("Maybe the JACK server is not running?");
  }
  if (status & JackServerStarted) {
    fprintf (stderr, "JACK server started\n");
  }
  if (status & JackNameNotUnique) {
    client_name = jack_get_client_name(mClient);
    fprintf (stderr, "unique name `%s' assigned\n", client_name);
  }

  // Set function to call if Jack shuts down
  jack_on_shutdown (mClient, this->jackShutdown, 0);

  // Create input and output channels
  createChannels();

  // Allocate buffer memory to read and write
  mSizeInBytesPerChannel = getSizeInBytesPerChannel();
  int size_input  = mSizeInBytesPerChannel * getNumInputChannels();
  int size_output = mSizeInBytesPerChannel * getNumOutputChannels();
  mInputPacket = new int8_t[size_input];
  mOutputPacket = new int8_t[size_output];

  // Buffer size member
  mNumFrames = getBufferSizeInSamples(); 

  // Initialize Buffer array to read and write audio
  mInBuffer.resize(mNumInChans);
  mOutBuffer.resize(mNumOutChans);

  // Initialize and asign memory for ProcessPlugins Buffers
  mInProcessBuffer.resize(mNumInChans);
  mOutProcessBuffer.resize(mNumOutChans);

  int nframes = getBufferSizeInSamples();
  for (int i = 0; i < mNumInChans; i++) {
    mInProcessBuffer[i] = new sample_t[nframes];
    // set memory to 0
    std::memset(mInProcessBuffer[i], 0, sizeof(sample_t) * nframes);
  }
  for (int i = 0; i < mNumOutChans; i++) {
    mOutProcessBuffer[i] = new sample_t[nframes];
    // set memory to 0
    std::memset(mOutProcessBuffer[i], 0, sizeof(sample_t) * nframes);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index