Skip to content

Commit 97a4b6d

Browse files
PlatformAudio requires audio device
1 parent b445f93 commit 97a4b6d

2 files changed

Lines changed: 53 additions & 15 deletions

File tree

src/tests/integration/test_platform_audio.cpp

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,19 @@ class PlatformTrackCollectorDelegate : public RoomDelegate {
7979
class PlatformAudioIntegrationTest : public LiveKitTestBase {};
8080

8181
// Publishing a platform-ADM-backed audio track should reach a remote
82-
// participant exactly like a manually fed AudioSource track. No real
83-
// microphone is required: the source captures silence on headless runners,
84-
// but the publish/subscribe round-trip still completes.
82+
// participant exactly like a manually fed AudioSource track. Unlike AudioSource,
83+
// PlatformAudio requires a working platform Audio Device Module: constructing it
84+
// throws PlatformAudioError when no ADM is available (e.g. a headless runner with
85+
// no audio subsystem), so the test is skipped in that environment.
8586
TEST_F(PlatformAudioIntegrationTest, PublishPlatformAudioTrackEndToEnd) {
8687
EXPECT_TRUE(config_.available) << "Missing integration configuration";
8788

8889
std::unique_ptr<PlatformAudio> platform_audio;
89-
EXPECT_NO_THROW(platform_audio = std::make_unique<PlatformAudio>());
90+
try {
91+
platform_audio = std::make_unique<PlatformAudio>();
92+
} catch (const PlatformAudioError& error) {
93+
GTEST_SKIP() << "PlatformAudio unavailable: " << error.what();
94+
}
9095

9196
RoomOptions options;
9297
options.auto_subscribe = true;
@@ -125,7 +130,11 @@ TEST_F(PlatformAudioIntegrationTest, UnpublishPlatformAudioTrackPropagates) {
125130
EXPECT_TRUE(config_.available) << "Missing integration configuration";
126131

127132
std::unique_ptr<PlatformAudio> platform_audio;
128-
EXPECT_NO_THROW(platform_audio = std::make_unique<PlatformAudio>());
133+
try {
134+
platform_audio = std::make_unique<PlatformAudio>();
135+
} catch (const PlatformAudioError& error) {
136+
GTEST_SKIP() << "PlatformAudio unavailable: " << error.what();
137+
}
129138

130139
RoomOptions options;
131140
options.auto_subscribe = true;
@@ -176,7 +185,11 @@ TEST_F(PlatformAudioIntegrationTest, MultipleSourcesFromOneManagerPublish) {
176185
EXPECT_TRUE(config_.available) << "Missing integration configuration";
177186

178187
std::unique_ptr<PlatformAudio> platform_audio;
179-
EXPECT_NO_THROW(platform_audio = std::make_unique<PlatformAudio>());
188+
try {
189+
platform_audio = std::make_unique<PlatformAudio>();
190+
} catch (const PlatformAudioError& error) {
191+
GTEST_SKIP() << "PlatformAudio unavailable: " << error.what();
192+
}
180193

181194
RoomOptions options;
182195
options.auto_subscribe = true;
@@ -221,14 +234,19 @@ TEST_F(PlatformAudioIntegrationTest, MultipleSourcesFromOneManagerPublish) {
221234

222235
// Audio captured by the platform Audio Device Module must actually stream to a
223236
// remote participant as decoded frames, not merely produce a subscribed track.
224-
// PlatformAudioSource captures the real microphone (silence on headless
225-
// runners), so this verifies frames *flow* end-to-end without asserting on
226-
// their content.
237+
// PlatformAudioSource captures the real microphone, so this verifies frames
238+
// *flow* end-to-end without asserting on their content. PlatformAudio requires a
239+
// working platform ADM, so the test is skipped when one is unavailable (e.g. a
240+
// headless runner with no audio subsystem).
227241
TEST_F(PlatformAudioIntegrationTest, PlatformAudioFramesReachRemote) {
228242
EXPECT_TRUE(config_.available) << "Missing integration configuration";
229243

230244
std::unique_ptr<PlatformAudio> platform_audio;
231-
EXPECT_NO_THROW(platform_audio = std::make_unique<PlatformAudio>());
245+
try {
246+
platform_audio = std::make_unique<PlatformAudio>();
247+
} catch (const PlatformAudioError& error) {
248+
GTEST_SKIP() << "PlatformAudio unavailable: " << error.what();
249+
}
232250

233251
RoomOptions options;
234252
options.auto_subscribe = true;

src/tests/unit/test_platform_audio.cpp

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,11 @@ TEST_F(PlatformAudioTest, DeviceInfoStoresStableId) {
5050

5151
TEST_F(PlatformAudioTest, CreateSourceAndTrackWhenAvailable) {
5252
std::unique_ptr<PlatformAudio> platform_audio;
53-
EXPECT_NO_THROW(platform_audio = std::make_unique<PlatformAudio>());
53+
try {
54+
platform_audio = std::make_unique<PlatformAudio>();
55+
} catch (const PlatformAudioError& error) {
56+
GTEST_SKIP() << "PlatformAudio unavailable: " << error.what();
57+
}
5458

5559
const auto source = platform_audio->createAudioSource();
5660
ASSERT_NE(source, nullptr);
@@ -64,7 +68,11 @@ TEST_F(PlatformAudioTest, CreateSourceAndTrackWhenAvailable) {
6468

6569
TEST_F(PlatformAudioTest, MovedFromManagerThrowsOnUseButCountsAreSafe) {
6670
std::unique_ptr<PlatformAudio> platform_audio;
67-
EXPECT_NO_THROW(platform_audio = std::make_unique<PlatformAudio>());
71+
try {
72+
platform_audio = std::make_unique<PlatformAudio>();
73+
} catch (const PlatformAudioError& error) {
74+
GTEST_SKIP() << "PlatformAudio unavailable: " << error.what();
75+
}
6876

6977
PlatformAudio moved_to = std::move(*platform_audio);
7078
PlatformAudio& moved_from = *platform_audio;
@@ -86,7 +94,11 @@ TEST_F(PlatformAudioTest, MovedFromManagerThrowsOnUseButCountsAreSafe) {
8694

8795
TEST_F(PlatformAudioTest, CopySharesHandleStateAndOutlivesOriginal) {
8896
std::unique_ptr<PlatformAudio> platform_audio;
89-
EXPECT_NO_THROW(platform_audio = std::make_unique<PlatformAudio>());
97+
try {
98+
platform_audio = std::make_unique<PlatformAudio>();
99+
} catch (const PlatformAudioError& error) {
100+
GTEST_SKIP() << "PlatformAudio unavailable: " << error.what();
101+
}
90102

91103
// A copy shares the underlying handle, so the cached counts agree.
92104
PlatformAudio copy = *platform_audio;
@@ -105,7 +117,11 @@ TEST_F(PlatformAudioTest, CopySharesHandleStateAndOutlivesOriginal) {
105117

106118
TEST_F(PlatformAudioTest, CreateSourceWithCustomOptions) {
107119
std::unique_ptr<PlatformAudio> platform_audio;
108-
EXPECT_NO_THROW(platform_audio = std::make_unique<PlatformAudio>());
120+
try {
121+
platform_audio = std::make_unique<PlatformAudio>();
122+
} catch (const PlatformAudioError& error) {
123+
GTEST_SKIP() << "PlatformAudio unavailable: " << error.what();
124+
}
109125

110126
PlatformAudioOptions options;
111127
options.echo_cancellation = false;
@@ -120,7 +136,11 @@ TEST_F(PlatformAudioTest, CreateSourceWithCustomOptions) {
120136

121137
TEST_F(PlatformAudioTest, EnumerateDevicesAndSelectWhenAvailable) {
122138
std::unique_ptr<PlatformAudio> platform_audio;
123-
EXPECT_NO_THROW(platform_audio = std::make_unique<PlatformAudio>());
139+
try {
140+
platform_audio = std::make_unique<PlatformAudio>();
141+
} catch (const PlatformAudioError& error) {
142+
GTEST_SKIP() << "PlatformAudio unavailable: " << error.what();
143+
}
124144

125145
// Enumeration must succeed even on headless runners (it may return empty).
126146
std::vector<AudioDeviceInfo> recording_devices;

0 commit comments

Comments
 (0)