Skip to content

Commit

Permalink
fix: routing assumption basis of microphone loopback detection (#2209)
Browse files Browse the repository at this point in the history
  • Loading branch information
xuan25 authored Jun 27, 2024
1 parent 8f01c18 commit 14a34b2
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions alvr/server/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -563,17 +563,27 @@ fn connection_pipeline(
.to_con()?;

#[cfg(not(target_os = "linux"))]
if let Switch::Enabled(microphone_desc) = &settings.audio.microphone {
if let Switch::Enabled(microphone_config) = &settings.audio.microphone {
let (sink, source) = AudioDevice::new_virtual_microphone_pair(
Some(settings.audio.linux_backend),
microphone_desc.devices.clone(),
microphone_config.devices.clone(),
)
.to_con()?;
if alvr_audio::is_same_device(&game_audio_device, &sink)
|| alvr_audio::is_same_device(&game_audio_device, &source)
{
con_bail!("Game audio and microphone cannot point to the same device!");
if matches!(
microphone_config.devices,
alvr_session::MicrophoneDevicesConfig::VBCable
) {
// VoiceMeeter and Custom devices may have arbitrary internal routing.
// Therefore, we cannot detect the loopback issue without knowing the routing.
if alvr_audio::is_same_device(&game_audio_device, &sink)
|| alvr_audio::is_same_device(&game_audio_device, &source)
{
con_bail!("Game audio and microphone cannot point to the same device!");
}
}
// else:
// Stream played via VA-CABLE-X will be directly routed to VA-CABLE-X's virtual microphone.
// Game audio will loop back to the game microphone if they are set to the same VA-CABLE-X device.
}

game_audio_device.input_sample_rate().to_con()?
Expand Down

0 comments on commit 14a34b2

Please sign in to comment.