diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /media/libcubeb/tests/test_latency.cpp | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'media/libcubeb/tests/test_latency.cpp')
-rw-r--r-- | media/libcubeb/tests/test_latency.cpp | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/media/libcubeb/tests/test_latency.cpp b/media/libcubeb/tests/test_latency.cpp new file mode 100644 index 000000000..0586b1a36 --- /dev/null +++ b/media/libcubeb/tests/test_latency.cpp @@ -0,0 +1,60 @@ +#ifdef NDEBUG +#undef NDEBUG +#endif +#include <stdlib.h> +#include "cubeb/cubeb.h" +#include <assert.h> +#include <stdio.h> +#ifdef CUBEB_GECKO_BUILD +#include "TestHarness.h" +#endif + +#define LOG(msg) fprintf(stderr, "%s\n", msg); + +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_frames; + + 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_frames); + assert(r == CUBEB_OK || r == CUBEB_ERROR_NOT_SUPPORTED); + if (r == CUBEB_OK) { + assert(latency_frames > 0 && "Invalid minimal latency."); + LOG("cubeb_get_min_latency ok"); + } + + cubeb_destroy(ctx); + LOG("cubeb_destroy ok"); + return EXIT_SUCCESS; +} |