Remember whether game is muted

This commit is contained in:
2025-11-23 13:37:35 -05:00
parent 8dd64598ed
commit e1d08672fb
6 changed files with 92 additions and 66 deletions
+9 -9
View File
@@ -96,7 +96,6 @@ impl EmulatorBuilder {
queue,
sim_state: builder.sim_state.clone(),
state: builder.state.clone(),
audio_on: builder.audio_on.clone(),
linked: builder.linked.clone(),
};
(builder, client)
@@ -116,6 +115,12 @@ impl EmulatorBuilder {
}
}
pub fn with_audio_on(self, p1: bool, p2: bool) -> Self {
self.audio_on[0].store(p1, Ordering::Relaxed);
self.audio_on[1].store(p2, Ordering::Relaxed);
self
}
pub fn build(self) -> Result<Emulator> {
let mut emulator = Emulator::new(
self.commands,
@@ -715,9 +720,8 @@ impl Emulator {
};
sim.watch_stdout(true);
}
EmulatorCommand::SetAudioEnabled(p1, p2) => {
self.audio_on[SimId::Player1.to_index()].store(p1, Ordering::Release);
self.audio_on[SimId::Player2.to_index()].store(p2, Ordering::Release);
EmulatorCommand::SetAudioEnabled(sim_id, enabled) => {
self.audio_on[sim_id.to_index()].store(enabled, Ordering::Release);
}
EmulatorCommand::Link => {
self.link_sims();
@@ -792,7 +796,7 @@ pub enum EmulatorCommand {
AddWatchpoint(SimId, u32, usize, VBWatchpointType),
RemoveWatchpoint(SimId, u32, usize, VBWatchpointType),
WatchStdout(SimId, mpsc::Sender<String>),
SetAudioEnabled(bool, bool),
SetAudioEnabled(SimId, bool),
Link,
Unlink,
Reset(SimId),
@@ -858,7 +862,6 @@ pub struct EmulatorClient {
queue: mpsc::Sender<EmulatorCommand>,
sim_state: Arc<[Atomic<SimState>; 2]>,
state: Arc<Atomic<EmulatorState>>,
audio_on: Arc<[AtomicBool; 2]>,
linked: Arc<AtomicBool>,
}
@@ -869,9 +872,6 @@ impl EmulatorClient {
pub fn emulator_state(&self) -> EmulatorState {
self.state.load(Ordering::Acquire)
}
pub fn is_audio_enabled(&self, sim_id: SimId) -> bool {
self.audio_on[sim_id.to_index()].load(Ordering::Acquire)
}
pub fn are_sims_linked(&self) -> bool {
self.linked.load(Ordering::Acquire)
}