Tests: Wait for PulseAudio context destruction in TestPlaybackStream

The stream was being kept alive until the moment before we check if the
context is still alive. The stream's control thread holds a reference
to the PulseAudioContext, so that should almost never be destroyed
before the VERIFY in the test. Instead, wait at most 100ms for it to be
destroyed.
This commit is contained in:
Zaggy1024 2025-11-25 12:42:19 -06:00 committed by Gregory Bertilson
parent 69cede4a0f
commit 6790a695da
Notes: github-actions[bot] 2025-11-25 19:15:24 +00:00

View file

@ -38,10 +38,15 @@ TEST_CASE(create_and_destroy_playback_stream)
return buffer.trim(writing_stream.offset());
});
EXPECT_EQ(!stream_result.is_error(), has_implementation);
MUST(Core::System::sleep_ms(100));
}
#if defined(HAVE_PULSEAUDIO)
VERIFY(!Audio::PulseAudioContext::is_connected());
// The PulseAudio context is kept alive by the PlaybackStream's control thread, which blocks on
// some operations, so it won't necessarily be destroyed immediately.
auto wait_start = MonotonicTime::now_coarse();
while (Audio::PulseAudioContext::is_connected()) {
if (MonotonicTime::now_coarse() - wait_start > AK::Duration::from_milliseconds(100))
VERIFY_NOT_REACHED();
}
#endif
}