improve detection
This commit is contained in:
parent
18fad499c5
commit
ff76b93b9d
|
|
@ -57,6 +57,9 @@ impl StutterDetector {
|
||||||
scheduling_threshold: AtomicU32::new(1200), // 1.2 stored in fixed point
|
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 {
|
fn get_scheduling_threshold(&self) -> f32 {
|
||||||
self.scheduling_threshold.load(Ordering::Relaxed) as f32 / 1000.0
|
self.scheduling_threshold.load(Ordering::Relaxed) as f32 / 1000.0
|
||||||
}
|
}
|
||||||
|
|
@ -281,6 +284,14 @@ impl CpalAudioOutput {
|
||||||
.ok_or_else(|| "No output device available")?;
|
.ok_or_else(|| "No output device available")?;
|
||||||
let supported_config = device.default_output_config()?;
|
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)?);
|
self._stream = Some(self.build_stream::<f32>(&device, supported_config)?);
|
||||||
|
|
||||||
// Restart playback if needed
|
// Restart playback if needed
|
||||||
|
|
@ -289,7 +300,7 @@ impl CpalAudioOutput {
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AudioOutput for CpalAudioOutput {
|
impl AudioOutput for CpalAudioOutput {
|
||||||
|
|
|
||||||
|
|
@ -624,7 +624,7 @@ function __wbg_get_imports() {
|
||||||
const ret = false;
|
const ret = false;
|
||||||
return ret;
|
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);
|
const ret = makeMutClosure(arg0, arg1, 82, __wbg_adapter_20);
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Binary file not shown.
Loading…
Reference in New Issue