| 41 | ); |
| 42 | |
| 43 | TEST_P(AudioTest, TestEncode) { |
| 44 | std::thread timer([&] { |
| 45 | // Terminate the audio capture after 100 ms |
| 46 | std::this_thread::sleep_for(100ms); |
| 47 | const auto shutdown_event = m_mail->event<bool>(mail::shutdown); |
| 48 | const auto audio_packets = m_mail->queue<packet_t>(mail::audio_packets); |
| 49 | shutdown_event->raise(true); |
| 50 | audio_packets->stop(); |
| 51 | }); |
| 52 | std::thread capture([&] { |
| 53 | const auto packets = m_mail->queue<packet_t>(mail::audio_packets); |
| 54 | const auto shutdown_event = m_mail->event<bool>(mail::shutdown); |
| 55 | while (const auto packet = packets->pop()) { |
| 56 | if (shutdown_event->peek()) { |
| 57 | break; |
| 58 | } |
| 59 | if (auto packet_data = packet->second; packet_data.size() == 0) { |
| 60 | FAIL() << "Empty packet data"; |
| 61 | } |
| 62 | } |
| 63 | }); |
| 64 | audio::capture(m_mail, m_config, nullptr); |
| 65 | |
| 66 | timer.join(); |
| 67 | capture.join(); |
| 68 | } |