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
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:
@@ -22,6 +22,8 @@ pub struct AudioSystem {
|
||||
|
||||
const SAMPLE_RATE: u32 = 48_000;
|
||||
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(
|
||||
state: TransmitState,
|
||||
@@ -184,7 +186,7 @@ impl AudioSystem {
|
||||
decoder,
|
||||
stream,
|
||||
buffer,
|
||||
tmp: vec![0; 2400],
|
||||
tmp: vec![0; MAX_DECODE_SAMPLES],
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -198,14 +200,12 @@ pub struct AudioPlayer {
|
||||
|
||||
impl AudioPlayer {
|
||||
pub fn play_opus(&mut self, payload: &[u8]) {
|
||||
let len = loop {
|
||||
match self.decoder.decode(payload, &mut self.tmp, false) {
|
||||
Ok(l) => break l,
|
||||
let len = match self.decoder.decode(payload, &mut self.tmp, false) {
|
||||
Ok(l) => l,
|
||||
Err(e) => {
|
||||
error!("opus decode error {e:?}");
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
let mut buffer = self.buffer.lock().unwrap();
|
||||
|
||||
Reference in New Issue
Block a user