diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /third_party/rust/cubeb-sys/libcubeb/test/test_latency.cpp | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/cubeb-sys/libcubeb/test/test_latency.cpp')
-rw-r--r-- | third_party/rust/cubeb-sys/libcubeb/test/test_latency.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/third_party/rust/cubeb-sys/libcubeb/test/test_latency.cpp b/third_party/rust/cubeb-sys/libcubeb/test/test_latency.cpp new file mode 100644 index 0000000000..522851044a --- /dev/null +++ b/third_party/rust/cubeb-sys/libcubeb/test/test_latency.cpp @@ -0,0 +1,47 @@ +#include "gtest/gtest.h" +#include <stdlib.h> +#include <memory> +#include "cubeb/cubeb.h" +//#define ENABLE_NORMAL_LOG +//#define ENABLE_VERBOSE_LOG +#include "common.h" + +TEST(cubeb, latency) +{ + cubeb * ctx = NULL; + int r; + uint32_t max_channels; + uint32_t preferred_rate; + uint32_t latency_frames; + + r = common_init(&ctx, "Cubeb audio test"); + ASSERT_EQ(r, CUBEB_OK); + + std::unique_ptr<cubeb, decltype(&cubeb_destroy)> + cleanup_cubeb_at_exit(ctx, cubeb_destroy); + + r = cubeb_get_max_channel_count(ctx, &max_channels); + ASSERT_TRUE(r == CUBEB_OK || r == CUBEB_ERROR_NOT_SUPPORTED); + if (r == CUBEB_OK) { + ASSERT_GT(max_channels, 0u); + } + + r = cubeb_get_preferred_sample_rate(ctx, &preferred_rate); + ASSERT_TRUE(r == CUBEB_OK || r == CUBEB_ERROR_NOT_SUPPORTED); + if (r == CUBEB_OK) { + ASSERT_GT(preferred_rate, 0u); + } + + cubeb_stream_params params = { + CUBEB_SAMPLE_FLOAT32NE, + preferred_rate, + max_channels, + CUBEB_LAYOUT_UNDEFINED, + CUBEB_STREAM_PREF_NONE + }; + r = cubeb_get_min_latency(ctx, ¶ms, &latency_frames); + ASSERT_TRUE(r == CUBEB_OK || r == CUBEB_ERROR_NOT_SUPPORTED); + if (r == CUBEB_OK) { + ASSERT_GT(latency_frames, 0u); + } +} |