smol touch of polish on the sdl2 audio path
This commit is contained in:
parent
4e22289ef0
commit
ae4cebef6f
|
@ -87,7 +87,9 @@ impl MyEmulator {
|
|||
let mut audio_spec = None;
|
||||
let audio_device = audio
|
||||
.open_playback(None, &desired_spec, |spec| {
|
||||
println!("audio format {:?}", spec.format);
|
||||
if spec.format != AudioFormat::S16LSB {
|
||||
println!("unsupported audio format {:?}", spec.format);
|
||||
}
|
||||
audio_spec = Some(spec.clone());
|
||||
MySdlAudio {
|
||||
audio_spec: spec,
|
||||
|
@ -254,13 +256,10 @@ impl AudioCallback for MySdlAudio {
|
|||
type Channel = i16;
|
||||
|
||||
fn callback(&mut self, out: &mut [Self::Channel]) {
|
||||
match self.audio_spec.format {
|
||||
AudioFormat::S16LSB | AudioFormat::U16LSB => {
|
||||
if let Ok(samples) = self.audio_receiver.recv() {
|
||||
out.copy_from_slice(&samples[..out.len()]);
|
||||
}
|
||||
if self.audio_spec.format == AudioFormat::S16LSB {
|
||||
if let Ok(samples) = self.audio_receiver.recv() {
|
||||
out.copy_from_slice(&samples[..out.len()]);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue