dont fully reinitialise if u dont need to
This commit is contained in:
parent
11dec11079
commit
0f919c612c
|
@ -112,6 +112,13 @@ impl Plugin for GameboyEmu {
|
|||
verbose: false,
|
||||
cycle_count: false,
|
||||
};
|
||||
|
||||
if let Some(ref mut vars) = self.vars {
|
||||
let (output, rx) = AudioOutput::new_unfilled(buffer_config.sample_rate, false);
|
||||
|
||||
vars.emulator_core.replace_output(output);
|
||||
vars.rx = rx;
|
||||
} else {
|
||||
let (sender, receiver) = channel::<EmulatorMessage>();
|
||||
|
||||
let (output, rx) = AudioOutput::new_unfilled(buffer_config.sample_rate, false);
|
||||
|
@ -130,6 +137,7 @@ impl Plugin for GameboyEmu {
|
|||
sender,
|
||||
emulator_core,
|
||||
});
|
||||
}
|
||||
|
||||
true
|
||||
}
|
||||
|
|
|
@ -124,6 +124,10 @@ impl<ColourFormat: From<Colour> + Clone> EmulatorCore<ColourFormat> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn replace_output(&mut self, new: AudioOutput) {
|
||||
self.cpu.memory.replace_output(new);
|
||||
}
|
||||
|
||||
pub fn run(&mut self) {
|
||||
self.process_messages();
|
||||
self.cycle_num += 1;
|
||||
|
|
|
@ -226,6 +226,10 @@ impl<ColourFormat: From<Colour> + Clone> Memory<ColourFormat> {
|
|||
pub fn is_audio_buffer_full(&self) -> bool {
|
||||
self.apu.is_buffer_full()
|
||||
}
|
||||
|
||||
pub fn replace_output(&mut self, new: AudioOutput) {
|
||||
self.apu.replace_output(new);
|
||||
}
|
||||
}
|
||||
|
||||
impl<ColourFormat: From<Colour> + Clone> Cpu<ColourFormat> {
|
||||
|
|
|
@ -64,6 +64,11 @@ impl Apu {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn replace_output(&mut self, new: AudioOutput) {
|
||||
self.converter = Downsampler::new(new.sample_rate);
|
||||
self.output = new;
|
||||
}
|
||||
|
||||
pub fn div_apu_tick(&mut self) {
|
||||
self.div_apu = self.div_apu.wrapping_add(1);
|
||||
if self.div_apu % 8 == 0 {
|
||||
|
|
Loading…
Reference in a new issue