Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
livekit_client: Always use output device's reported channels num (#51276)
Jakub Konkaa540b7c22761
diff --git a/crates/livekit_client/src/livekit_client/playback.rs b/crates/livekit_client/src/livekit_client/playback.rsindex 4933b05fc51..f62de78b4f9 100644--- a/crates/livekit_client/src/livekit_client/playback.rs+++ b/crates/livekit_client/src/livekit_client/playback.rs@@ -258,7 +258,7 @@ impl AudioStack {apm: Arc<Mutex<apm::AudioProcessingModule>>,mixer: Arc<Mutex<audio_mixer::AudioMixer>>,sample_rate: u32,- num_channels: u32,+ _num_channels: u32,output_audio_device: Option<DeviceId>,) -> Result<()> {// Prevent App Nap from throttling audio playback on macOS.@@ -270,6 +270,7 @@ impl AudioStack {let mut device_change_listener = DeviceChangeListener::new(false)?;let (output_device, output_config) =crate::default_device(false, output_audio_device.as_ref())?;+ info!("Output config: {output_config:?}");let (end_on_drop_tx, end_on_drop_rx) = std::sync::mpsc::channel::<()>();let mixer = mixer.clone();let apm = apm.clone();@@ -300,7 +301,12 @@ impl AudioStack {let sampled = resampler.remix_and_resample(mixed,sample_rate / 100,- num_channels,+ // We need to assume output number of channels as otherwise we will+ // crash in process_reverse_stream otherwise as livekit's audio resampler+ // does not seem to support non-matching channel counts.+ // NOTE: you can verify this by debug printing buf.len() after this stage.+ // For 2->4 channel upmix, we should see buf.len=1920, buf we get only 960.+ output_config.channels() as u32,sample_rate,output_config.channels() as u32,output_config.sample_rate(),