smol touch of polish on the sdl2 audio path
This commit is contained in:
parent
4e22289ef0
commit
ae4cebef6f
1 changed files with 6 additions and 7 deletions
|
@ -87,7 +87,9 @@ impl MyEmulator {
|
||||||
let mut audio_spec = None;
|
let mut audio_spec = None;
|
||||||
let audio_device = audio
|
let audio_device = audio
|
||||||
.open_playback(None, &desired_spec, |spec| {
|
.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());
|
audio_spec = Some(spec.clone());
|
||||||
MySdlAudio {
|
MySdlAudio {
|
||||||
audio_spec: spec,
|
audio_spec: spec,
|
||||||
|
@ -254,13 +256,10 @@ impl AudioCallback for MySdlAudio {
|
||||||
type Channel = i16;
|
type Channel = i16;
|
||||||
|
|
||||||
fn callback(&mut self, out: &mut [Self::Channel]) {
|
fn callback(&mut self, out: &mut [Self::Channel]) {
|
||||||
match self.audio_spec.format {
|
if self.audio_spec.format == AudioFormat::S16LSB {
|
||||||
AudioFormat::S16LSB | AudioFormat::U16LSB => {
|
if let Ok(samples) = self.audio_receiver.recv() {
|
||||||
if let Ok(samples) = self.audio_receiver.recv() {
|
out.copy_from_slice(&samples[..out.len()]);
|
||||||
out.copy_from_slice(&samples[..out.len()]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue