move file init

This commit is contained in:
Alex Janka 2023-03-11 20:44:55 +11:00
parent 3d5ae32960
commit 0baf6dc436

View file

@ -106,6 +106,17 @@ impl Plugin for GameboyEmu {
buffer_config: &BufferConfig,
_context: &mut impl InitContext<Self>,
) -> bool {
if let Some(ref mut vars) = self.vars {
let (output, rx) = AudioOutput::new(
buffer_config.sample_rate,
false,
FRAMES_TO_BUFFER,
DOWNSAMPLE_TYPE,
);
vars.emulator_core.replace_output(output);
vars.rx = rx;
} else {
let bootrom = if INCLUDE_BOOTROM {
Some(RomFile::Raw(
include_bytes!("../../bootrom/dmg_boot.bin").to_vec(),
@ -127,17 +138,6 @@ impl Plugin for GameboyEmu {
verbose: false,
};
if let Some(ref mut vars) = self.vars {
let (output, rx) = AudioOutput::new(
buffer_config.sample_rate,
false,
FRAMES_TO_BUFFER,
DOWNSAMPLE_TYPE,
);
vars.emulator_core.replace_output(output);
vars.rx = rx;
} else {
let (sender, receiver) = channel::<EmulatorMessage>();
let (output, rx) = AudioOutput::new(