BlueGit

ict rusty-teams

fix(diagnostics): drop Linux audio-device enumeration lines (#140)

Co-authored-by: Matteo Lombardi <93079933+matteolomba@users.noreply.github.com>

metis Joe Mild · pushed by metis

Authored 2026-11-28 · 3 days ago

Hash
f8f077fe69f6547fb49eb8cb136ab2b05f857eb8
Parent
e9c36599
1 file changed +100 −0
crates/app-base/src/diagnostics.rs +100 −0
@@ -271,6 +271,38 @@ fn keeps_webrtc_line(level: log::Level, text: &str) -> bool {
271 271 .any(|marker| text.contains(marker))
272 272 && !WEBRTC_SKIPPED.iter().any(|skipped| text.contains(skipped))
273 273 && !is_endpoint_dump(text)
274 && !is_adm_enumeration_dump(text)
275 }
276
277 /// Device-name lines from each `list_devices` poll. Linux prints the function
278 /// name; MSVC prefixes it with `virtual webrtc::AudioDeviceModuleImpl::`.
279 /// Numeric `output:` / `input:` lines are return values (`Recording`, `Playing`)
280 /// and stay. `Initialized:` is the per-poll flag, not that return value.
281 fn is_adm_enumeration_dump(text: &str) -> bool {
282 let Some(message) = text
283 .split_once("audio_device_impl.cc:")
284 .and_then(|(_, rest)| rest.split_once("): ").map(|(_, message)| message))
285 else {
286 return false;
287 };
288 let head = adm_function_name(message);
289 const CALLS: [&str; 4] = [
290 "PlayoutDeviceName",
291 "RecordingDeviceName",
292 "PlayoutDevices",
293 "RecordingDevices",
294 ];
295 const DUMPS: [&str; 4] = ["output: name", "output: guid", "input: name", "input: guid"];
296 CALLS.iter().any(|prefix| head.starts_with(prefix))
297 || DUMPS.iter().any(|prefix| head.starts_with(prefix))
298 || head.starts_with("Initialized")
299 }
300
301 /// Drops an optional MSVC `__FUNCTION__` prefix so Linux and Windows share one check.
302 fn adm_function_name(message: &str) -> &str {
303 let rest = message.strip_prefix("virtual ").unwrap_or(message);
304 rest.strip_prefix("webrtc::AudioDeviceModuleImpl::")
305 .unwrap_or(rest)
274 306 }
275 307
276 308 fn is_endpoint_dump(text: &str) -> bool {
@@ -299,6 +331,74 @@ mod tests {
299 331 log::Level::Debug,
300 332 "(audio_device_impl.cc:123): Init"
301 333 ));
334 assert!(!keeps_webrtc_line(
335 log::Level::Debug,
336 "(audio_device_impl.cc:655): PlayoutDeviceName(0, ...)"
337 ));
338 assert!(!keeps_webrtc_line(
339 log::Level::Debug,
340 "(audio_device_impl.cc:632): PlayoutDevices"
341 ));
342 assert!(!keeps_webrtc_line(
343 log::Level::Debug,
344 "(audio_device_impl.cc:640): RecordingDevices"
345 ));
346 assert!(!keeps_webrtc_line(
347 log::Level::Debug,
348 "(audio_device_impl.cc:648): RecordingDeviceName(1, ...)"
349 ));
350 assert!(!keeps_webrtc_line(
351 log::Level::Debug,
352 "(audio_device_impl.cc:664): output: name = Headset Game"
353 ));
354 assert!(!keeps_webrtc_line(
355 log::Level::Debug,
356 "(audio_device_impl.cc:667): output: guid = "
357 ));
358 assert!(!keeps_webrtc_line(
359 log::Level::Debug,
360 "(audio_device_impl.cc:680): input: name = Headset Chat"
361 ));
362 assert!(!keeps_webrtc_line(
363 log::Level::Debug,
364 "(audio_device_impl.cc:683): input: guid = "
365 ));
366 assert!(!keeps_webrtc_line(
367 log::Level::Debug,
368 "(audio_device_impl.cc:620): Initialized: 1"
369 ));
370 assert!(keeps_webrtc_line(
371 log::Level::Debug,
372 "(audio_device_impl.cc:700): output: 1"
373 ));
374 assert!(keeps_webrtc_line(
375 log::Level::Debug,
376 "(audio_device_impl.cc:710): input: 0"
377 ));
378 assert!(!keeps_webrtc_line(
379 log::Level::Debug,
380 "(audio_device_impl.cc:655): virtual webrtc::AudioDeviceModuleImpl::PlayoutDeviceName(0, ...)"
381 ));
382 assert!(!keeps_webrtc_line(
383 log::Level::Debug,
384 "(audio_device_impl.cc:632): virtual webrtc::AudioDeviceModuleImpl::PlayoutDevices"
385 ));
386 assert!(keeps_webrtc_line(
387 log::Level::Debug,
388 "(audio_device_impl.cc:635): output: 4"
389 ));
390 assert!(keeps_webrtc_line(
391 log::Level::Debug,
392 "(audio_device_pulse_linux.cc:1161): disconnected recording"
393 ));
394 assert!(keeps_webrtc_line(
395 log::Level::Debug,
396 "(audio_device_pulse_linux.cc:1366): failed"
397 ));
398 assert!(keeps_webrtc_line(
399 log::Level::Debug,
400 "(audio_device_pulse_linux.cc:1735): PulseAudio terminated"
401 ));
302 402 assert!(keeps_webrtc_line(
303 403 log::Level::Debug,
304 404 "(webrtc_voice_engine.cc:10): WebRtcVoiceEngine::Init"
@@ -271,6 +271,38 @@ fn keeps_webrtc_line(level: log::Level, text: &str) -> bool {
271 .any(|marker| text.contains(marker))
271 .any(|marker| text.contains(marker))
272 && !WEBRTC_SKIPPED.iter().any(|skipped| text.contains(skipped))
272 && !WEBRTC_SKIPPED.iter().any(|skipped| text.contains(skipped))
273 && !is_endpoint_dump(text)
273 && !is_endpoint_dump(text)
274 && !is_adm_enumeration_dump(text)
275}
276
277/// Device-name lines from each `list_devices` poll. Linux prints the function
278/// name; MSVC prefixes it with `virtual webrtc::AudioDeviceModuleImpl::`.
279/// Numeric `output:` / `input:` lines are return values (`Recording`, `Playing`)
280/// and stay. `Initialized:` is the per-poll flag, not that return value.
281fn is_adm_enumeration_dump(text: &str) -> bool {
282 let Some(message) = text
283 .split_once("audio_device_impl.cc:")
284 .and_then(|(_, rest)| rest.split_once("): ").map(|(_, message)| message))
285 else {
286 return false;
287 };
288 let head = adm_function_name(message);
289 const CALLS: [&str; 4] = [
290 "PlayoutDeviceName",
291 "RecordingDeviceName",
292 "PlayoutDevices",
293 "RecordingDevices",
294 ];
295 const DUMPS: [&str; 4] = ["output: name", "output: guid", "input: name", "input: guid"];
296 CALLS.iter().any(|prefix| head.starts_with(prefix))
297 || DUMPS.iter().any(|prefix| head.starts_with(prefix))
298 || head.starts_with("Initialized")
299}
300
301/// Drops an optional MSVC `__FUNCTION__` prefix so Linux and Windows share one check.
302fn adm_function_name(message: &str) -> &str {
303 let rest = message.strip_prefix("virtual ").unwrap_or(message);
304 rest.strip_prefix("webrtc::AudioDeviceModuleImpl::")
305 .unwrap_or(rest)
274}
306}
275
307
276fn is_endpoint_dump(text: &str) -> bool {
308fn is_endpoint_dump(text: &str) -> bool {
@@ -299,6 +331,74 @@ mod tests {
299 log::Level::Debug,
331 log::Level::Debug,
300 "(audio_device_impl.cc:123): Init"
332 "(audio_device_impl.cc:123): Init"
301 ));
333 ));
334 assert!(!keeps_webrtc_line(
335 log::Level::Debug,
336 "(audio_device_impl.cc:655): PlayoutDeviceName(0, ...)"
337 ));
338 assert!(!keeps_webrtc_line(
339 log::Level::Debug,
340 "(audio_device_impl.cc:632): PlayoutDevices"
341 ));
342 assert!(!keeps_webrtc_line(
343 log::Level::Debug,
344 "(audio_device_impl.cc:640): RecordingDevices"
345 ));
346 assert!(!keeps_webrtc_line(
347 log::Level::Debug,
348 "(audio_device_impl.cc:648): RecordingDeviceName(1, ...)"
349 ));
350 assert!(!keeps_webrtc_line(
351 log::Level::Debug,
352 "(audio_device_impl.cc:664): output: name = Headset Game"
353 ));
354 assert!(!keeps_webrtc_line(
355 log::Level::Debug,
356 "(audio_device_impl.cc:667): output: guid = "
357 ));
358 assert!(!keeps_webrtc_line(
359 log::Level::Debug,
360 "(audio_device_impl.cc:680): input: name = Headset Chat"
361 ));
362 assert!(!keeps_webrtc_line(
363 log::Level::Debug,
364 "(audio_device_impl.cc:683): input: guid = "
365 ));
366 assert!(!keeps_webrtc_line(
367 log::Level::Debug,
368 "(audio_device_impl.cc:620): Initialized: 1"
369 ));
370 assert!(keeps_webrtc_line(
371 log::Level::Debug,
372 "(audio_device_impl.cc:700): output: 1"
373 ));
374 assert!(keeps_webrtc_line(
375 log::Level::Debug,
376 "(audio_device_impl.cc:710): input: 0"
377 ));
378 assert!(!keeps_webrtc_line(
379 log::Level::Debug,
380 "(audio_device_impl.cc:655): virtual webrtc::AudioDeviceModuleImpl::PlayoutDeviceName(0, ...)"
381 ));
382 assert!(!keeps_webrtc_line(
383 log::Level::Debug,
384 "(audio_device_impl.cc:632): virtual webrtc::AudioDeviceModuleImpl::PlayoutDevices"
385 ));
386 assert!(keeps_webrtc_line(
387 log::Level::Debug,
388 "(audio_device_impl.cc:635): output: 4"
389 ));
390 assert!(keeps_webrtc_line(
391 log::Level::Debug,
392 "(audio_device_pulse_linux.cc:1161): disconnected recording"
393 ));
394 assert!(keeps_webrtc_line(
395 log::Level::Debug,
396 "(audio_device_pulse_linux.cc:1366): failed"
397 ));
398 assert!(keeps_webrtc_line(
399 log::Level::Debug,
400 "(audio_device_pulse_linux.cc:1735): PulseAudio terminated"
401 ));
302 assert!(keeps_webrtc_line(
402 assert!(keeps_webrtc_line(
303 log::Level::Debug,
403 log::Level::Debug,
304 "(webrtc_voice_engine.cc:10): WebRtcVoiceEngine::Init"
404 "(webrtc_voice_engine.cc:10): WebRtcVoiceEngine::Init"