Beispiel #1
1
static bool setupParameters(const char *hostAPI, const char *inputDevice,
                            const char *outputDevice, PaStreamParameters *inputParams,
                            PaStreamParameters *outputParams)
{
    PaHostApiIndex hostAPIIndex;
    if (!findHostAPIInfo(hostAPI, &hostAPIIndex)) {
        return false;
    }

    const PaDeviceInfo *inputDeviceInfo = findDeviceInfo(hostAPIIndex,
                                          inputDevice, &inputParams->device);
    if (!inputDeviceInfo) {
        return false;
    }

    const PaDeviceInfo *outputDeviceInfo = findDeviceInfo(hostAPIIndex,
                                           outputDevice, &outputParams->device);
    if (!outputDeviceInfo) {
        return false;
    }

    /* TODO do all host APIs/devices support this? */
    PaSampleFormat sampleFormat = paFloat32 | paNonInterleaved;
    inputParams->sampleFormat = sampleFormat;
    outputParams->sampleFormat = sampleFormat;

    /* TODO support stereo and user-defined channel configuration */
    inputParams->channelCount = 1;
    outputParams->channelCount = 1;

    inputParams->suggestedLatency = inputDeviceInfo->defaultLowInputLatency;
    outputParams->suggestedLatency = outputDeviceInfo->defaultLowOutputLatency;

    inputParams->hostApiSpecificStreamInfo = NULL;
    outputParams->hostApiSpecificStreamInfo = NULL;
    return true;
}
Beispiel #2
0
static bool setupParameters(const char *hostAPI, const char *inputDevice,
    const char *outputDevice, PaStreamParameters *inputParams,
    PaStreamParameters *outputParams, double latency)
{
  PaHostApiIndex hostAPIIndex;
  if (!findHostAPIInfo(hostAPI, &hostAPIIndex)) {
    return false;
  }

  const PaDeviceInfo *inputDeviceInfo = findDeviceInfo(hostAPIIndex,
      inputDevice, &inputParams->device, true);
  if (!inputDeviceInfo) {
    return false;
  }

  const PaDeviceInfo *outputDeviceInfo = findDeviceInfo(hostAPIIndex,
      outputDevice, &outputParams->device, false);
  if (!outputDeviceInfo) {
    return false;
  }

  /* TODO do all host APIs/devices support this? */
  PaSampleFormat sampleFormat = paFloat32 | paNonInterleaved;
  inputParams->sampleFormat = sampleFormat;
  outputParams->sampleFormat = sampleFormat;

  /* TODO support user-defined channel configuration */
  if (inputDeviceInfo->maxInputChannels == 0 ||
      outputDeviceInfo->maxOutputChannels == 0) {
    return false;
  }
  inputParams->channelCount = inputDeviceInfo->maxInputChannels > 1 ? 2 : 1;
  outputParams->channelCount = outputDeviceInfo->maxOutputChannels;

  inputParams->suggestedLatency = latency;
  outputParams->suggestedLatency = latency;

  inputParams->hostApiSpecificStreamInfo = NULL;
  outputParams->hostApiSpecificStreamInfo = NULL;
  return true;
}