Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions tests/unit/test_audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ struct AudioTest: PlatformTestSuite, testing::WithParamInterface<std::tuple<std:
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>();
if (flag >= 0) {
result.set(flag);
Expand All @@ -42,22 +42,21 @@ INSTANTIATE_TEST_SUITE_P(

TEST_P(AudioTest, TestEncode) {
std::thread timer([&] {
// Terminate the audio capture after 5 seconds.
std::this_thread::sleep_for(5s);
auto shutdown_event = m_mail->event<bool>(mail::shutdown);
auto audio_packets = m_mail->queue<packet_t>(mail::audio_packets);
// Terminate the audio capture after 100 ms
std::this_thread::sleep_for(100ms);
const auto shutdown_event = m_mail->event<bool>(mail::shutdown);
const auto audio_packets = m_mail->queue<packet_t>(mail::audio_packets);
shutdown_event->raise(true);
audio_packets->stop();
});
std::thread capture([&] {
auto packets = m_mail->queue<packet_t>(mail::audio_packets);
auto shutdown_event = m_mail->event<bool>(mail::shutdown);
while (auto packet = packets->pop()) {
const auto packets = m_mail->queue<packet_t>(mail::audio_packets);
const auto shutdown_event = m_mail->event<bool>(mail::shutdown);
while (const auto packet = packets->pop()) {
if (shutdown_event->peek()) {
break;
}
auto packet_data = packet->second;
if (packet_data.size() == 0) {
if (auto packet_data = packet->second; packet_data.size() == 0) {
FAIL() << "Empty packet data";
}
}
Expand Down
Loading