Fix buffer bug in native audio.
Build Mumble Web 2 / linux_build (push) Successful in 5m5s
Build Mumble Web 2 / windows_build (push) Successful in 9m48s
Build Mumble Web 2 / android_build (push) Successful in 12m5s
Build android container / android-release-builder-container-build (push) Successful in 1s
Build Mumble Web 2 release builder containers / windows-release-builder-container-build (push) Successful in 13s

Setting this buffer to 2400 was only enough to store 50m of sound
at 48,000 samples/sec. I've also done a small refactor here to
make this buffer scale with sample rate.
This commit is contained in:
2026-02-06 17:47:55 -07:00
parent 2fcb853c30
commit 083a11274e
+8 -8
View File
@@ -22,6 +22,8 @@ pub struct AudioSystem {
const SAMPLE_RATE: u32 = 48_000; const SAMPLE_RATE: u32 = 48_000;
const PACKET_SAMPLES: u32 = 960; const PACKET_SAMPLES: u32 = 960;
// Divide by 1000 to get samples per ms, then multiply by 60ms for max Opus frame size.
const MAX_DECODE_SAMPLES: usize = SAMPLE_RATE as usize / 1000 * 60;
fn encode_and_send( fn encode_and_send(
state: TransmitState, state: TransmitState,
@@ -184,7 +186,7 @@ impl AudioSystem {
decoder, decoder,
stream, stream,
buffer, buffer,
tmp: vec![0; 2400], tmp: vec![0; MAX_DECODE_SAMPLES],
}) })
} }
} }
@@ -198,13 +200,11 @@ pub struct AudioPlayer {
impl AudioPlayer { impl AudioPlayer {
pub fn play_opus(&mut self, payload: &[u8]) { pub fn play_opus(&mut self, payload: &[u8]) {
let len = loop { let len = match self.decoder.decode(payload, &mut self.tmp, false) {
match self.decoder.decode(payload, &mut self.tmp, false) { Ok(l) => l,
Ok(l) => break l, Err(e) => {
Err(e) => { error!("opus decode error {e:?}");
error!("opus decode error {e:?}"); return;
return;
}
} }
}; };