sdl2: Add silent mode
Former-commit-id: b8e3a8809501f32f819b74a1e4dd094d77a4b367 Former-commit-id: 027be1f05ae9f274e6a3527d209ac5ff696d8c56
This commit is contained in:
parent
67c071595a
commit
2ec52fb722
|
@ -11,6 +11,10 @@ struct GbaAudioCallback {
|
|||
spec: AudioSpec,
|
||||
}
|
||||
|
||||
pub struct DummyAudioPlayer {}
|
||||
|
||||
impl AudioInterface for DummyAudioPlayer {}
|
||||
|
||||
pub struct Sdl2AudioPlayer {
|
||||
_device: AudioDevice<GbaAudioCallback>,
|
||||
producer: Producer<StereoSample<i16>>,
|
||||
|
@ -87,3 +91,8 @@ pub fn create_audio_player(sdl: &sdl2::Sdl) -> Sdl2AudioPlayer {
|
|||
producer: producer.unwrap(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn create_dummy_player() -> DummyAudioPlayer {
|
||||
info!("Dummy audio device");
|
||||
DummyAudioPlayer {}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,9 @@ args:
|
|||
- debug:
|
||||
long: debug
|
||||
help: Use the custom debugger
|
||||
- silent:
|
||||
long: silent
|
||||
help: Do not output sound
|
||||
- with_gdbserver:
|
||||
long: with-gdbserver
|
||||
help: Start with experimental gdbserver
|
||||
|
|
|
@ -36,7 +36,7 @@ mod audio;
|
|||
mod input;
|
||||
mod video;
|
||||
|
||||
use audio::create_audio_player;
|
||||
use audio::{create_audio_player, create_dummy_player};
|
||||
use input::create_input;
|
||||
use video::{create_video_interface, SCREEN_HEIGHT, SCREEN_WIDTH};
|
||||
|
||||
|
@ -131,6 +131,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
let skip_bios = matches.occurrences_of("skip_bios") != 0;
|
||||
|
||||
let debug = matches.occurrences_of("debug") != 0;
|
||||
let silent = matches.occurrences_of("silent") != 0;
|
||||
let with_gdbserver = matches.occurrences_of("with_gdbserver") != 0;
|
||||
|
||||
info!("Initializing SDL2 context");
|
||||
|
@ -183,7 +184,11 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
};
|
||||
|
||||
let video = Rc::new(RefCell::new(create_video_interface(canvas)));
|
||||
let audio = Rc::new(RefCell::new(create_audio_player(&sdl_context)));
|
||||
let audio: Rc<RefCell<dyn AudioInterface>> = if silent {
|
||||
Rc::new(RefCell::new(create_dummy_player()))
|
||||
} else {
|
||||
Rc::new(RefCell::new(create_audio_player(&sdl_context)))
|
||||
};
|
||||
let input = Rc::new(RefCell::new(create_input()));
|
||||
|
||||
let mut savestate_path = get_savestate_path(&Path::new(&rom_path));
|
||||
|
|
Reference in a new issue