2014-02-27 19:26:24 +04:00
|
|
|
#ifdef NDEBUG
|
|
|
|
#undef NDEBUG
|
|
|
|
#endif
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <cubeb/cubeb.h>
|
|
|
|
#include <assert.h>
|
2014-04-17 17:42:00 +04:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#define LOG(msg) fprintf(stderr, "%s\n", msg);
|
2014-02-27 19:26:24 +04:00
|
|
|
|
|
|
|
int main(int argc, char * argv[])
|
|
|
|
{
|
|
|
|
cubeb * ctx = NULL;
|
|
|
|
int rv;
|
|
|
|
uint32_t max_channels;
|
|
|
|
uint32_t preferred_rate;
|
|
|
|
uint32_t latency_ms;
|
|
|
|
|
2014-04-17 17:42:00 +04:00
|
|
|
LOG("latency_test start");
|
2014-02-27 19:26:24 +04:00
|
|
|
rv = cubeb_init(&ctx, "Cubeb audio test");
|
|
|
|
assert(rv == CUBEB_OK && "Cubeb init failed.");
|
2014-04-17 17:42:00 +04:00
|
|
|
LOG("cubeb_init ok");
|
2014-02-27 19:26:24 +04:00
|
|
|
|
|
|
|
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.");
|
2014-04-17 17:42:00 +04:00
|
|
|
LOG("cubeb_get_max_channel_count ok");
|
2014-02-27 19:26:24 +04:00
|
|
|
|
|
|
|
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.");
|
2014-04-17 17:42:00 +04:00
|
|
|
LOG("cubeb_get_preferred_sample_rate ok");
|
2014-02-27 19:26:24 +04:00
|
|
|
|
|
|
|
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.");
|
2014-04-17 17:42:00 +04:00
|
|
|
LOG("cubeb_get_min_latency ok");
|
2014-02-27 19:26:24 +04:00
|
|
|
|
|
|
|
cubeb_destroy(ctx);
|
2014-04-17 17:42:00 +04:00
|
|
|
LOG("cubeb_destroy ok");
|
2014-02-27 19:26:24 +04:00
|
|
|
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|