Beispiel #1
0
int main(int argc, char * argv[])
{
  cubeb * ctx = NULL;
  int rv;
  uint32_t max_channels;
  uint32_t preferred_rate;
  uint32_t latency_ms;

  rv = cubeb_init(&ctx, "Cubeb audio test");
  assert(rv == CUBEB_OK && "Cubeb init failed.");

  rv = cubeb_get_max_channel_count(ctx, &max_channels);
  assert(rv == CUBEB_OK && "Could not query the max channe count.");
  assert(max_channels > 0 && "Invalid max channel count.");

  rv = cubeb_get_preferred_sample_rate(ctx, &preferred_rate);
  assert(rv == CUBEB_OK && "Could not query the preferred sample rate.");
  assert(preferred_rate && "Invalid preferred sample rate.");

  cubeb_stream_params params = {
    CUBEB_SAMPLE_FLOAT32NE,
    preferred_rate,
    max_channels
  };
  rv = cubeb_get_min_latency(ctx, params, &latency_ms);
  assert(rv == CUBEB_OK && "Could not query the minimal latency.");
  assert(latency_ms && "Invalid minimal latency.");

  cubeb_destroy(ctx);

  return EXIT_SUCCESS;
}
Beispiel #2
0
/*static*/ int AudioStream::MaxNumberOfChannels()
{
  cubeb* cubebContext = GetCubebContext();
  uint32_t maxNumberOfChannels;
  if (cubebContext &&
      cubeb_get_max_channel_count(cubebContext,
                                  &maxNumberOfChannels) == CUBEB_OK) {
    return static_cast<int>(maxNumberOfChannels);
  }

  return 0;
}
int AudioStream::MaxNumberOfChannels()
{
  uint32_t maxNumberOfChannels, rv;

  rv = cubeb_get_max_channel_count(GetCubebContext(), &maxNumberOfChannels);

  if (rv != CUBEB_OK) {
    return 0;
  }

  return static_cast<int>(maxNumberOfChannels);
}
Beispiel #4
0
uint32_t MaxNumberOfChannels()
{
  cubeb* cubebContext = GetCubebContext();
  uint32_t maxNumberOfChannels;
  if (cubebContext &&
      cubeb_get_max_channel_count(cubebContext,
                                  &maxNumberOfChannels) == CUBEB_OK) {
    return maxNumberOfChannels;
  }

  return 0;
}
Beispiel #5
0
int main(int argc, char * argv[])
{
#ifdef CUBEB_GECKO_BUILD
  ScopedXPCOM xpcom("test_latency");
#endif

  cubeb * ctx = NULL;
  int r;
  uint32_t max_channels;
  uint32_t preferred_rate;
  uint32_t latency_ms;

  LOG("latency_test start");
  r = cubeb_init(&ctx, "Cubeb audio test");
  assert(r == CUBEB_OK && "Cubeb init failed.");
  LOG("cubeb_init ok");

  r = cubeb_get_max_channel_count(ctx, &max_channels);
  assert(r == CUBEB_OK || r == CUBEB_ERROR_NOT_SUPPORTED);
  if (r == CUBEB_OK) {
    assert(max_channels > 0 && "Invalid max channel count.");
    LOG("cubeb_get_max_channel_count ok");
  }

  r = cubeb_get_preferred_sample_rate(ctx, &preferred_rate);
  assert(r == CUBEB_OK || r == CUBEB_ERROR_NOT_SUPPORTED);
  if (r == CUBEB_OK) {
    assert(preferred_rate > 0 && "Invalid preferred sample rate.");
    LOG("cubeb_get_preferred_sample_rate ok");
  }

  cubeb_stream_params params = {
    CUBEB_SAMPLE_FLOAT32NE,
    preferred_rate,
    max_channels
  };
  r = cubeb_get_min_latency(ctx, params, &latency_ms);
  assert(r == CUBEB_OK || r == CUBEB_ERROR_NOT_SUPPORTED);
  if (r == CUBEB_OK) {
    assert(latency_ms > 0 && "Invalid minimal latency.");
    LOG("cubeb_get_min_latency ok");
  }

  cubeb_destroy(ctx);
  LOG("cubeb_destroy ok");
  return EXIT_SUCCESS;
}