Make audio much more defensive

This commit is contained in:
2026-08-14 23:42:02 -04:00
parent 1ff4fda55b
commit 644e99c295
2 changed files with 162 additions and 21 deletions
+5 -5
View File
@@ -138,7 +138,7 @@ impl EmulatorBuilder {
self.audio_on,
self.watch_rom,
self.linked,
)?;
);
if let Some(path) = self.rom {
emulator.load_cart(SimId::Player1, &path)?;
}
@@ -178,11 +178,11 @@ impl Emulator {
audio_on: Arc<[AtomicBool; 2]>,
watch_rom: Arc<[AtomicBool; 2]>,
linked: Arc<AtomicBool>,
) -> Result<Self> {
Ok(Self {
) -> Self {
Self {
sims: vec![],
carts: [None, None],
audio: Audio::init()?,
audio: Audio::init(),
commands,
sim_state,
state,
@@ -198,7 +198,7 @@ impl Emulator {
eye_contents: [vec![0u8; 384 * 224 * 2], vec![0u8; 384 * 224 * 2]],
audio_samples: Vec::with_capacity(EXPECTED_FRAME_SIZE),
buffer: vec![],
})
}
}
pub fn reload_cart(&mut self, sim_id: SimId) -> Result<()> {