|
1 #ifdef NDEBUG |
|
2 #undef NDEBUG |
|
3 #endif |
|
4 #include <stdlib.h> |
|
5 #include <cubeb/cubeb.h> |
|
6 #include <assert.h> |
|
7 #include <stdio.h> |
|
8 |
|
9 #define LOG(msg) fprintf(stderr, "%s\n", msg); |
|
10 |
|
11 int main(int argc, char * argv[]) |
|
12 { |
|
13 cubeb * ctx = NULL; |
|
14 int rv; |
|
15 uint32_t max_channels; |
|
16 uint32_t preferred_rate; |
|
17 uint32_t latency_ms; |
|
18 |
|
19 LOG("latency_test start"); |
|
20 rv = cubeb_init(&ctx, "Cubeb audio test"); |
|
21 assert(rv == CUBEB_OK && "Cubeb init failed."); |
|
22 LOG("cubeb_init ok"); |
|
23 |
|
24 rv = cubeb_get_max_channel_count(ctx, &max_channels); |
|
25 assert(rv == CUBEB_OK && "Could not query the max channe count."); |
|
26 assert(max_channels > 0 && "Invalid max channel count."); |
|
27 LOG("cubeb_get_max_channel_count ok"); |
|
28 |
|
29 rv = cubeb_get_preferred_sample_rate(ctx, &preferred_rate); |
|
30 assert(rv == CUBEB_OK && "Could not query the preferred sample rate."); |
|
31 assert(preferred_rate && "Invalid preferred sample rate."); |
|
32 LOG("cubeb_get_preferred_sample_rate ok"); |
|
33 |
|
34 cubeb_stream_params params = { |
|
35 CUBEB_SAMPLE_FLOAT32NE, |
|
36 preferred_rate, |
|
37 max_channels |
|
38 }; |
|
39 rv = cubeb_get_min_latency(ctx, params, &latency_ms); |
|
40 assert(rv == CUBEB_OK && "Could not query the minimal latency."); |
|
41 assert(latency_ms && "Invalid minimal latency."); |
|
42 LOG("cubeb_get_min_latency ok"); |
|
43 |
|
44 cubeb_destroy(ctx); |
|
45 LOG("cubeb_destroy ok"); |
|
46 |
|
47 return EXIT_SUCCESS; |
|
48 } |