@@ -27,18 +27,6 @@ class PlatformAudioTest : public ::testing::Test {
2727protected:
2828 void SetUp () override { livekit::initialize (livekit::LogLevel::Info); }
2929 void TearDown () override { livekit::shutdown (); }
30-
31- // / Construct a PlatformAudio, or skip the calling test when the platform
32- // / Audio Device Module is unavailable (headless CI runners have no audio
33- // / hardware). Returns nullptr after recording the skip.
34- static std::unique_ptr<PlatformAudio> makePlatformAudioOrSkip () {
35- try {
36- return std::make_unique<PlatformAudio>();
37- } catch (const PlatformAudioError& error) {
38- GTEST_SKIP () << " PlatformAudio unavailable: " << error.what ();
39- }
40- return nullptr ;
41- }
4230};
4331
4432TEST_F (PlatformAudioTest, DefaultOptionsEnableVoiceProcessing) {
@@ -79,8 +67,12 @@ TEST_F(PlatformAudioTest, CreateSourceAndTrackWhenAvailable) {
7967}
8068
8169TEST_F (PlatformAudioTest, MovedFromManagerThrowsOnUseButCountsAreSafe) {
82- auto platform_audio = makePlatformAudioOrSkip ();
83- ASSERT_NE (platform_audio, nullptr );
70+ std::unique_ptr<PlatformAudio> platform_audio;
71+ try {
72+ platform_audio = std::make_unique<PlatformAudio>();
73+ } catch (const PlatformAudioError& error) {
74+ GTEST_SKIP () << " PlatformAudio unavailable: " << error.what ();
75+ }
8476
8577 PlatformAudio moved_to = std::move (*platform_audio);
8678 PlatformAudio& moved_from = *platform_audio;
@@ -101,8 +93,12 @@ TEST_F(PlatformAudioTest, MovedFromManagerThrowsOnUseButCountsAreSafe) {
10193}
10294
10395TEST_F (PlatformAudioTest, CopySharesHandleStateAndOutlivesOriginal) {
104- auto platform_audio = makePlatformAudioOrSkip ();
105- ASSERT_NE (platform_audio, nullptr );
96+ std::unique_ptr<PlatformAudio> platform_audio;
97+ try {
98+ platform_audio = std::make_unique<PlatformAudio>();
99+ } catch (const PlatformAudioError& error) {
100+ GTEST_SKIP () << " PlatformAudio unavailable: " << error.what ();
101+ }
106102
107103 // A copy shares the underlying handle, so the cached counts agree.
108104 PlatformAudio copy = *platform_audio;
@@ -120,8 +116,12 @@ TEST_F(PlatformAudioTest, CopySharesHandleStateAndOutlivesOriginal) {
120116}
121117
122118TEST_F (PlatformAudioTest, CreateSourceWithCustomOptions) {
123- auto platform_audio = makePlatformAudioOrSkip ();
124- ASSERT_NE (platform_audio, nullptr );
119+ std::unique_ptr<PlatformAudio> platform_audio;
120+ try {
121+ platform_audio = std::make_unique<PlatformAudio>();
122+ } catch (const PlatformAudioError& error) {
123+ GTEST_SKIP () << " PlatformAudio unavailable: " << error.what ();
124+ }
125125
126126 PlatformAudioOptions options;
127127 options.echo_cancellation = false ;
@@ -135,8 +135,12 @@ TEST_F(PlatformAudioTest, CreateSourceWithCustomOptions) {
135135}
136136
137137TEST_F (PlatformAudioTest, EnumerateDevicesAndSelectWhenAvailable) {
138- auto platform_audio = makePlatformAudioOrSkip ();
139- ASSERT_NE (platform_audio, nullptr );
138+ std::unique_ptr<PlatformAudio> platform_audio;
139+ try {
140+ platform_audio = std::make_unique<PlatformAudio>();
141+ } catch (const PlatformAudioError& error) {
142+ GTEST_SKIP () << " PlatformAudio unavailable: " << error.what ();
143+ }
140144
141145 // Enumeration must succeed even on headless runners (it may return empty).
142146 std::vector<AudioDeviceInfo> recording_devices;
0 commit comments