test(audio): reduce wait time (#4247)
This commit is contained in:
@@ -18,7 +18,7 @@ struct AudioTest: PlatformTestSuite, testing::WithParamInterface<std::tuple<std:
|
|||||||
safe::mail_t m_mail;
|
safe::mail_t m_mail;
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr std::bitset<config_t::MAX_FLAGS> config_flags(int flag = -1) {
|
constexpr std::bitset<config_t::MAX_FLAGS> config_flags(const int flag = -1) {
|
||||||
std::bitset<3> result = std::bitset<config_t::MAX_FLAGS>();
|
std::bitset<3> result = std::bitset<config_t::MAX_FLAGS>();
|
||||||
if (flag >= 0) {
|
if (flag >= 0) {
|
||||||
result.set(flag);
|
result.set(flag);
|
||||||
@@ -42,22 +42,21 @@ INSTANTIATE_TEST_SUITE_P(
|
|||||||
|
|
||||||
TEST_P(AudioTest, TestEncode) {
|
TEST_P(AudioTest, TestEncode) {
|
||||||
std::thread timer([&] {
|
std::thread timer([&] {
|
||||||
// Terminate the audio capture after 5 seconds.
|
// Terminate the audio capture after 100 ms
|
||||||
std::this_thread::sleep_for(5s);
|
std::this_thread::sleep_for(100ms);
|
||||||
auto shutdown_event = m_mail->event<bool>(mail::shutdown);
|
const auto shutdown_event = m_mail->event<bool>(mail::shutdown);
|
||||||
auto audio_packets = m_mail->queue<packet_t>(mail::audio_packets);
|
const auto audio_packets = m_mail->queue<packet_t>(mail::audio_packets);
|
||||||
shutdown_event->raise(true);
|
shutdown_event->raise(true);
|
||||||
audio_packets->stop();
|
audio_packets->stop();
|
||||||
});
|
});
|
||||||
std::thread capture([&] {
|
std::thread capture([&] {
|
||||||
auto packets = m_mail->queue<packet_t>(mail::audio_packets);
|
const auto packets = m_mail->queue<packet_t>(mail::audio_packets);
|
||||||
auto shutdown_event = m_mail->event<bool>(mail::shutdown);
|
const auto shutdown_event = m_mail->event<bool>(mail::shutdown);
|
||||||
while (auto packet = packets->pop()) {
|
while (const auto packet = packets->pop()) {
|
||||||
if (shutdown_event->peek()) {
|
if (shutdown_event->peek()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
auto packet_data = packet->second;
|
if (auto packet_data = packet->second; packet_data.size() == 0) {
|
||||||
if (packet_data.size() == 0) {
|
|
||||||
FAIL() << "Empty packet data";
|
FAIL() << "Empty packet data";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user