2016-11-11 05:01:56 +03:00
|
|
|
#include "gtest/gtest.h"
|
|
|
|
#include <stdlib.h>
|
2017-04-20 12:01:37 +03:00
|
|
|
#include <memory>
|
2016-11-11 05:01:56 +03:00
|
|
|
#include "cubeb/cubeb.h"
|
2018-10-20 01:00:20 +03:00
|
|
|
//#define ENABLE_NORMAL_LOG
|
|
|
|
//#define ENABLE_VERBOSE_LOG
|
2017-05-25 07:45:04 +03:00
|
|
|
#include "common.h"
|
2016-11-11 05:01:56 +03:00
|
|
|
|
|
|
|
TEST(cubeb, latency)
|
|
|
|
{
|
|
|
|
cubeb * ctx = NULL;
|
|
|
|
int r;
|
|
|
|
uint32_t max_channels;
|
|
|
|
uint32_t preferred_rate;
|
|
|
|
uint32_t latency_frames;
|
|
|
|
|
2017-05-25 07:45:04 +03:00
|
|
|
r = common_init(&ctx, "Cubeb audio test");
|
2016-11-11 05:01:56 +03:00
|
|
|
ASSERT_EQ(r, CUBEB_OK);
|
|
|
|
|
2017-04-20 12:01:37 +03:00
|
|
|
std::unique_ptr<cubeb, decltype(&cubeb_destroy)>
|
|
|
|
cleanup_cubeb_at_exit(ctx, cubeb_destroy);
|
|
|
|
|
2016-11-11 05:01:56 +03:00
|
|
|
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,
|
2017-01-19 19:02:42 +03:00
|
|
|
max_channels,
|
2017-12-05 21:11:01 +03:00
|
|
|
CUBEB_LAYOUT_UNDEFINED,
|
|
|
|
CUBEB_STREAM_PREF_NONE
|
2016-11-11 05:01:56 +03:00
|
|
|
};
|
2017-07-13 13:04:52 +03:00
|
|
|
r = cubeb_get_min_latency(ctx, ¶ms, &latency_frames);
|
2016-11-11 05:01:56 +03:00
|
|
|
ASSERT_TRUE(r == CUBEB_OK || r == CUBEB_ERROR_NOT_SUPPORTED);
|
|
|
|
if (r == CUBEB_OK) {
|
|
|
|
ASSERT_GT(latency_frames, 0u);
|
|
|
|
}
|
|
|
|
}
|