improve detection

This commit is contained in:
Skyler Lehmkuhl 2025-01-31 07:12:12 -05:00
parent 18fad499c5
commit ff76b93b9d
3 changed files with 29 additions and 18 deletions

View File

@ -57,6 +57,9 @@ impl StutterDetector {
scheduling_threshold: AtomicU32::new(1200), // 1.2 stored in fixed point
}
}
pub fn reset(&mut self) {
*self = Self::new();
}
fn get_scheduling_threshold(&self) -> f32 {
self.scheduling_threshold.load(Ordering::Relaxed) as f32 / 1000.0
}
@ -281,6 +284,14 @@ impl CpalAudioOutput {
.ok_or_else(|| "No output device available")?;
let supported_config = device.default_output_config()?;
{
let mut detector = self.stutter_detector.lock().unwrap();
let desired_buffer_size = detector.desired_buffer_size.load(Ordering::Relaxed);
detector.reset();
detector.desired_buffer_size.store(desired_buffer_size, Ordering::Relaxed);
}
// let mut history = detector.delay_history.lock().unwrap();
self._stream = Some(self.build_stream::<f32>(&device, supported_config)?);
// Restart playback if needed

View File

@ -624,7 +624,7 @@ function __wbg_get_imports() {
const ret = false;
return ret;
};
imports.wbg.__wbindgen_closure_wrapper207 = function(arg0, arg1, arg2) {
imports.wbg.__wbindgen_closure_wrapper208 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 82, __wbg_adapter_20);
return addHeapObject(ret);
};

Binary file not shown.