make do_sleep pub & add a "stuff the buffer with silence" method useful when you wish to pause an interactive emulator
This commit is contained in:
parent
1b311837d4
commit
9d3e74b7cb
|
@ -101,6 +101,10 @@ impl SimpleSdl2AudioComponent {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn silence_buffer(&self) {
|
||||
let _ = self.audio_sender.try_send(vec![0; self.audio_spec.samples as usize * self.audio_spec.channels as usize]);
|
||||
}
|
||||
|
||||
fn send_audio_samples(&mut self) {
|
||||
let stereo_samples = self.audio_spec.samples as usize * 2;
|
||||
while self.audio_buffer.len() >= stereo_samples {
|
||||
|
|
|
@ -251,7 +251,7 @@ impl SleepFramerateLimitComponent {
|
|||
}
|
||||
}
|
||||
|
||||
fn do_sleep(&mut self) {
|
||||
pub fn do_sleep(&mut self) {
|
||||
// similar hack to the sample rate, make sure we don't divide by zero.
|
||||
let mut spf = 1.0 / self.fps;
|
||||
if spf.is_nan() || spf.is_infinite() {
|
||||
|
|
Loading…
Reference in New Issue