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